Ticket #15809: add_object_has_add_perm.diff

File add_object_has_add_perm.diff, 1.7 KB (added by EnTeQuAk, 4 years ago)
  • docs/ref/contrib/admin/index.txt

     
    954954                        kwargs['choices'] += (('ready', 'Ready for deployment'),)
    955955                return super(MyModelAdmin, self).formfield_for_choice_field(db_field, request, **kwargs)
    956956
    957 .. method:: ModelAdmin.has_add_permission(self, request)
     957.. method:: ModelAdmin.has_add_permission(self, request, obj=None)
    958958
    959959    Should return ``True`` if adding an object is permitted, ``False``
    960960    otherwise.
  • django/contrib/admin/options.py

     
    347347        return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])
    348348    media = property(_media)
    349349
    350     def has_add_permission(self, request):
     350    def has_add_permission(self, request, obj=None):
    351351        """
    352352        Returns True if the given request has permission to add an object.
    353353        Can be overriden by the user in subclasses.
     
    682682        context.update({
    683683            'add': add,
    684684            'change': change,
    685             'has_add_permission': self.has_add_permission(request),
     685            'has_add_permission': self.has_add_permission(request, obj),
    686686            'has_change_permission': self.has_change_permission(request, obj),
    687687            'has_delete_permission': self.has_delete_permission(request, obj),
    688688            'has_file_field': True, # FIXME - this should check if form or formsets have a FileField,
Back to Top