Ticket #7150: django-svn-view-permission.patch
File django-svn-view-permission.patch, 4.8 KB (added by , 17 years ago) |
---|
-
django/db/models/options.py
293 293 def get_delete_permission(self): 294 294 return 'delete_%s' % self.object_name.lower() 295 295 296 def get_view_permission(self): 297 return 'view_%s' % self.object_name.lower() 298 296 299 def get_all_related_objects(self, local_only=False): 297 300 try: 298 301 self._related_objects_cache -
django/contrib/admin/templatetags/adminapplist.py
32 32 'add': user.has_perm("%s.%s" % (app_label, m._meta.get_add_permission())), 33 33 'change': user.has_perm("%s.%s" % (app_label, m._meta.get_change_permission())), 34 34 'delete': user.has_perm("%s.%s" % (app_label, m._meta.get_delete_permission())), 35 'view': user.has_perm("%s.%s" % (app_label, m._meta.get_view_permission())), 35 36 } 36 37 37 38 # Check whether user has any perm for this module. -
django/contrib/admin/views/main.py
315 315 opts = model._meta 316 316 317 317 if not request.user.has_perm(app_label + '.' + opts.get_change_permission()): 318 raise PermissionDenied 318 if not request.user.has_perm(app_label + '.' + opts.get_view_permission()): 319 raise PermissionDenied 319 320 320 321 if request.POST and "_saveasnew" in request.POST: 321 322 return add_stage(request, app_label, model_name, form_url='../../add/') … … 752 753 if model is None: 753 754 raise Http404("App %r, model %r, not found" % (app_label, model_name)) 754 755 if not request.user.has_perm(app_label + '.' + model._meta.get_change_permission()): 755 raise PermissionDenied 756 if not request.user.has_perm(app_label + '.' + model._meta.get_view_permission()): 757 raise PermissionDenied 756 758 try: 757 759 cl = ChangeList(request, model) 758 760 except IncorrectLookupParameters: -
django/contrib/admin/templates/admin/index.html
20 20 <tr> 21 21 {% if model.perms.change %} 22 22 <th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th> 23 {% else %}{% if model.perms.view %} 24 <th scope="row"><a href="{{ model.admin_url }}">{{ model.name }}</a></th> 23 25 {% else %} 24 26 <th scope="row">{{ model.name }}</th> 25 {% endif %} 27 {% endif %}{% endif %} 26 28 27 29 {% if model.perms.add %} 28 30 <td><a href="{{ model.admin_url }}add/" class="addlink">{% trans 'Add' %}</a></td> -
django/contrib/auth/management.py
12 12 def _get_all_permissions(opts): 13 13 "Returns (codename, name) for all permissions in the given opts." 14 14 perms = [] 15 for action in ('add', 'change', 'delete' ):15 for action in ('add', 'change', 'delete', 'view'): 16 16 perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw))) 17 17 return perms + list(opts.permissions) 18 18 -
django/contrib/auth/models.py
65 65 - The "add" permission limits the user's ability to view the "add" form and add an object. 66 66 - The "change" permission limits a user's ability to view the change list, view the "change" form and change an object. 67 67 - The "delete" permission limits the ability to delete an object. 68 - The "view" permission limits the ability to view data (if none of the above is missing) 68 69 69 70 Permissions are set globally per type of object, not per specific object instance. It is possible to say "Mary may change news stories," but it's not currently possible to say "Mary may change news stories, but only the ones she created herself" or "Mary may only change news stories that have a certain status or publication date." 70 71