Ticket #6327: has_module_permission.diff

File has_module_permission.diff, 1.2 KB (added by chrj, 8 years ago)
  • django/contrib/admin/options.py

     
    270270       
    271271        return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js])
    272272    media = property(_media)
     273
     274    def has_module_permission(self, request):
     275        "Returns True if the given request has permission the the module."
     276        opts = self.opts
     277        return request.user.has_module_perms(opts.app_label)
    273278   
    274279    def has_add_permission(self, request):
    275280        "Returns True if the given request has permission to add an object."
  • django/contrib/admin/sites.py

     
    261261        user = request.user
    262262        for model, model_admin in self._registry.items():
    263263            app_label = model._meta.app_label
    264             has_module_perms = user.has_module_perms(app_label)
     264            has_module_perms = model_admin.has_module_permission(request)
    265265
    266266            if has_module_perms:
    267267                perms = {
Back to Top