Ticket #820: view_permission_patch_1.patch
File view_permission_patch_1.patch, 4.2 KB (added by , 19 years ago) |
---|
-
django/contrib/admin/templatetags/adminapplist.py
23 23 'add': user.has_perm("%s.%s" % (app_label, m._meta.get_add_permission())), 24 24 'change': user.has_perm("%s.%s" % (app_label, m._meta.get_change_permission())), 25 25 'delete': user.has_perm("%s.%s" % (app_label, m._meta.get_delete_permission())), 26 'view': user.has_perm("%s.%s" % (app_label, m._meta.get_view_permission())), 26 27 } 27 28 28 29 # Check whether user has any perm for this module. -
django/contrib/admin/views/main.py
74 74 IS_POPUP_VAR = 'pop' 75 75 76 76 mod, opts = _get_mod_opts(app_label, module_name) 77 if not request.user.has_perm(app_label + '.' + opts.get_change_permission()):77 if not (request.user.has_perm(app_label + '.' + opts.get_view_permission()) or request.user.has_perm(app_label + '.' + opts.get_change_permission())): 78 78 raise PermissionDenied 79 79 80 80 lookup_mod, lookup_opts = mod, opts … … 446 446 result_repr = ' ' 447 447 if j == 0: # First column is a special case 448 448 result_id = getattr(result, pk) 449 raw_template.append('<th%s><a href="%s/"%s>%s</a></th>' % \ 450 (row_class, result_id, (is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr)) 449 if request.user.has_perm(app_label + '.' + opts.get_change_permission()): 450 raw_template.append('<th%s><a href="%s/"%s>%s</a></th>' % \ 451 (row_class, result_id, (is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr)) 452 else: 453 raw_template.append('<th%s>%s</th>' % (row_class, result_repr)) 451 454 else: 452 455 raw_template.append('<td%s>%s</td>' % (row_class, result_repr)) 453 456 raw_template.append('</tr>\n') -
django/contrib/admin/templates/admin/index.html
17 17 <table> 18 18 {% for model in app.models %} 19 19 <tr> 20 {% if model.perms. change%}20 {% if model.perms.view %} 21 21 <th><a href="{{ model.admin_url }}">{{ model.name }}</a></th> 22 22 {% else %} 23 23 <th>{{ model.name }}</th> -
django/core/meta/__init__.py
268 268 def get_delete_permission(self): 269 269 return 'delete_%s' % self.object_name.lower() 270 270 271 def get_view_permission(self): 272 return 'view_%s' % self.object_name.lower() 273 271 274 def get_rel_object_method_name(self, rel_opts, rel_field): 272 275 # This method encapsulates the logic that decides what name to give a 273 276 # method that retrieves related many-to-one objects. Usually it just -
django/core/management.py
31 31 "Returns (codename, name) for all permissions in the given opts." 32 32 perms = [] 33 33 if opts.admin: 34 for action in ('add', 'change', 'delete' ):34 for action in ('add', 'change', 'delete', 'view'): 35 35 perms.append((_get_permission_codename(action, opts), 'Can %s %s' % (action, opts.verbose_name))) 36 36 return perms + list(opts.permissions) 37 37