diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index f84b096..103c899 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
276 | 276 | opts = self.opts |
277 | 277 | return request.user.has_perm(opts.app_label + '.' + opts.get_add_permission()) |
278 | 278 | |
279 | | def has_change_permission(self, request, obj): |
| 279 | def has_change_permission(self, request, obj=None): |
280 | 280 | """ |
281 | 281 | Returns True if the given request has permission to change the given |
282 | 282 | Django model instance. |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
287 | 287 | opts = self.opts |
288 | 288 | return request.user.has_perm(opts.app_label + '.' + opts.get_change_permission()) |
289 | 289 | |
290 | | def has_delete_permission(self, request, obj): |
| 290 | def has_delete_permission(self, request, obj=None): |
291 | 291 | """ |
292 | 292 | Returns True if the given request has permission to change the given |
293 | 293 | Django model instance. |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
452 | 452 | request.user.message_set.create(message=msg) |
453 | 453 | return HttpResponseRedirect("../") |
454 | 454 | |
455 | | def render_change_form(self, model, context, add=False, change=False, form_url=''): |
| 455 | def render_change_form(self, request, model, context, add=False, change=False, form_url='', obj=None): |
456 | 456 | opts = model._meta |
457 | 457 | app_label = opts.app_label |
458 | 458 | ordered_objects = opts.get_ordered_objects() |
459 | 459 | extra_context = { |
460 | 460 | 'add': add, |
461 | 461 | 'change': change, |
462 | | 'has_delete_permission': context['perms'][app_label][opts.get_delete_permission()], |
463 | | 'has_change_permission': context['perms'][app_label][opts.get_change_permission()], |
| 462 | 'has_add_permission': self.has_add_permission(request), |
| 463 | 'has_change_permission': self.has_change_permission(request, obj), |
| 464 | 'has_delete_permission': self.has_delete_permission(request, obj), |
464 | 465 | 'has_file_field': True, # FIXME - this should check if form or formsets have a FileField, |
465 | 466 | 'has_absolute_url': hasattr(model, 'get_absolute_url'), |
466 | 467 | 'ordered_objects': ordered_objects, |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
525 | 526 | 'media': mark_safe(media), |
526 | 527 | 'inline_admin_formsets': inline_admin_formsets, |
527 | 528 | }) |
528 | | return self.render_change_form(model, c, add=True) |
529 | | |
| 529 | return self.render_change_form(request, model, c, add=True) |
| 530 | |
530 | 531 | def change_view(self, request, object_id): |
531 | 532 | "The 'change' admin view for this model." |
532 | 533 | model = self.model |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
600 | 601 | 'media': mark_safe(media), |
601 | 602 | 'inline_admin_formsets': inline_admin_formsets, |
602 | 603 | }) |
603 | | return self.render_change_form(model, c, change=True) |
| 604 | return self.render_change_form(request, model, c, change=True, obj=obj) |
604 | 605 | |
605 | 606 | def changelist_view(self, request): |
606 | 607 | "The 'change list' admin view for this model." |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
626 | 627 | 'is_popup': cl.is_popup, |
627 | 628 | 'cl': cl, |
628 | 629 | }) |
629 | | c.update({'has_add_permission': c['perms'][app_label][opts.get_add_permission()]}), |
| 630 | c.update({'has_add_permission': self.has_add_permission(request)}), |
630 | 631 | return render_to_response(['admin/%s/%s/change_list.html' % (app_label, opts.object_name.lower()), |
631 | 632 | 'admin/%s/change_list.html' % app_label, |
632 | 633 | 'admin/change_list.html'], context_instance=c) |
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index 06d1a04..471678f 100644
a
|
b
|
class AdminSite(object):
|
263 | 263 | |
264 | 264 | if has_module_perms: |
265 | 265 | perms = { |
266 | | 'add': user.has_perm("%s.%s" % (app_label, model._meta.get_add_permission())), |
267 | | 'change': user.has_perm("%s.%s" % (app_label, model._meta.get_change_permission())), |
268 | | 'delete': user.has_perm("%s.%s" % (app_label, model._meta.get_delete_permission())), |
| 266 | 'add': model_admin.has_add_permission(request), |
| 267 | 'change': model_admin.has_change_permission(request), |
| 268 | 'delete': model_admin.has_delete_permission(request), |
269 | 269 | } |
270 | 270 | |
271 | 271 | # Check whether user has any perm for this module. |
diff --git a/django/contrib/admin/templatetags/admin_modify.py b/django/contrib/admin/templatetags/admin_modify.py
index c1dbfaa..ed3768b 100644
a
|
b
|
def submit_row(context):
|
29 | 29 | 'show_delete_link': (not is_popup and context['has_delete_permission'] |
30 | 30 | and (change or context['show_delete'])), |
31 | 31 | 'show_save_as_new': not is_popup and change and save_as, |
32 | | 'show_save_and_add_another': not is_popup and (not save_as or context['add']), |
| 32 | 'show_save_and_add_another': context['has_add_permission'] and |
| 33 | not is_popup and (not save_as or context['add']), |
33 | 34 | 'show_save_and_continue': not is_popup and context['has_change_permission'], |
34 | 35 | 'show_save': True |
35 | 36 | } |