Ticket #2927: fix_admin_add_buttons.2.patch
File fix_admin_add_buttons.2.patch, 4.0 KB (added by , 18 years ago) |
---|
-
django/contrib/admin/templates/widget/foreign.html
7 7 <a href="{{ bound_field.related_url }}" class="related-lookup" id="lookup_{{ bound_field.element_id }}" onclick="return showRelatedObjectLookupPopup(this);"> <img src="{% admin_media_prefix %}img/admin/selector-search.gif" width="16" height="16" alt="Lookup"></a> 8 8 {% endif %} 9 9 {% else %} 10 {% if bound_field.needs_add_label %}10 {% if bound_field.needs_add_label and has_add_permission %} 11 11 <a href="{{ bound_field.related_url }}add/" class="add-another" id="add_{{ bound_field.element_id }}" onclick="return showAddAnotherPopup(this);"> <img src="{% admin_media_prefix %}img/admin/icon_addlink.gif" width="10" height="10" alt="Add Another"/></a> 12 12 {% endif %}{% endif %} 13 13 {% if change %} -
django/contrib/admin/templatetags/admin_modify.py
42 42 'show_delete_link': (not is_popup and context['has_delete_permission'] 43 43 and (change or context['show_delete'])), 44 44 'show_save_as_new': not is_popup and change and opts.admin.save_as, 45 'show_save_and_add_another': not is_popup and (not opts.admin.save_as or context['add']), 45 'show_save_and_add_another': not is_popup and (not opts.admin.save_as or context['add']) 46 and context['has_add_permission'], 46 47 'show_save_and_continue': not is_popup and context['has_change_permission'], 47 48 'show_save': True 48 49 } … … 95 96 def render(self, context): 96 97 bound_field = template.resolve_variable(self.bound_field_var, context) 97 98 99 # Pass through the add permission for related fields. 100 opts = bound_field.field.rel and bound_field.field.rel.to._meta 101 user = context.get('user', None) 102 103 has_add_permission = opts and user and user.has_perm('%s.%s' % (opts.app_label, opts.get_add_permission())) 104 105 106 #raise TypeError, '%s.%s' % (opts.app_label, opts.get_add_permission()) 107 98 108 context.push() 99 109 context['bound_field'] = bound_field 110 context['has_add_permission'] = has_add_permission 100 111 101 112 output = self.get_nodelist(bound_field.field.__class__).render(context) 102 113 context.pop() … … 239 250 return { 240 251 'add': context['add'], 241 252 'change': context['change'], 253 'user': context['user'], 242 254 'bound_fields': bound_fields, 243 255 'class_names': " ".join(class_names), 244 256 } -
django/contrib/admin/views/auth.py
31 31 'is_popup': request.REQUEST.has_key('_popup'), 32 32 'add': True, 33 33 'change': False, 34 'has_add_permission': True, 34 35 'has_delete_permission': False, 35 36 'has_change_permission': True, 36 37 'has_file_field': False, -
django/contrib/admin/views/main.py
199 199 extra_context = { 200 200 'add': add, 201 201 'change': change, 202 'has_add_permission': context['perms'][app_label][opts.get_add_permission()], 202 203 'has_delete_permission': context['perms'][app_label][opts.get_delete_permission()], 203 204 'has_change_permission': context['perms'][app_label][opts.get_change_permission()], 204 205 'has_file_field': opts.has_field_type(models.FileField),