Code

Ticket #3817: admin_modify.2.diff

File admin_modify.2.diff, 2.0 KB (added by reza@…, 7 years ago)

backward-compatibility and view changes

Line 
1Index: django/contrib/admin/templatetags/admin_modify.py
2===================================================================
3--- django/contrib/admin/templatetags/admin_modify.py   (revision 4828)
4+++ django/contrib/admin/templatetags/admin_modify.py   (working copy)
5@@ -38,14 +38,15 @@
6     opts = context['opts']
7     change = context['change']
8     is_popup = context['is_popup']
9+    has_add_permission = context.has_key('has_add_permission') and context['has_add_permission'] or False
10     return {
11         'onclick_attrib': (opts.get_ordered_objects() and change
12                             and 'onclick="submitOrderForm();"' or ''),
13         'show_delete_link': (not is_popup and context['has_delete_permission']
14                               and (change or context['show_delete'])),
15         'show_save_as_new': not is_popup and change and opts.admin.save_as,
16-        'show_save_and_add_another': not is_popup and (not opts.admin.save_as or context['add']),
17+        'show_save_and_add_another': not is_popup and (not opts.admin.save_as or context['add']) and has_add_permission,
18         'show_save_and_continue': not is_popup and context['has_change_permission'],
19         'show_save': True
20     }
21 submit_row = register.inclusion_tag('admin/submit_line.html', takes_context=True)(submit_row)
22Index: django/contrib/admin/views/main.py
23===================================================================
24--- django/contrib/admin/views/main.py  (revision 4828)
25+++ django/contrib/admin/views/main.py  (working copy)
26@@ -201,6 +201,7 @@
27         'change': change,
28         'has_delete_permission': context['perms'][app_label][opts.get_delete_permission()],
29         'has_change_permission': context['perms'][app_label][opts.get_change_permission()],
30+        'has_add_permission': context['perms'][app_label][opts.get_add_permission()],
31         'has_file_field': opts.has_field_type(models.FileField),
32         'has_absolute_url': hasattr(model, 'get_absolute_url'),
33         'auto_populated_fields': auto_populated_fields,