Ticket #7150: django-svn-view-permission.patch

File django-svn-view-permission.patch, 4.8 KB (added by Antonio Gallo <gallo@…>, 16 years ago)
  • django/db/models/options.py

     
    293293    def get_delete_permission(self):
    294294        return 'delete_%s' % self.object_name.lower()
    295295
     296    def get_view_permission(self):
     297        return 'view_%s' % self.object_name.lower()
     298
    296299    def get_all_related_objects(self, local_only=False):
    297300        try:
    298301            self._related_objects_cache
  • django/contrib/admin/templatetags/adminapplist.py

     
    3232                            'add': user.has_perm("%s.%s" % (app_label, m._meta.get_add_permission())),
    3333                            'change': user.has_perm("%s.%s" % (app_label, m._meta.get_change_permission())),
    3434                            '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())),
    3536                        }
    3637
    3738                        # Check whether user has any perm for this module.
  • django/contrib/admin/views/main.py

     
    315315    opts = model._meta
    316316
    317317    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
    319320
    320321    if request.POST and "_saveasnew" in request.POST:
    321322        return add_stage(request, app_label, model_name, form_url='../../add/')
     
    752753    if model is None:
    753754        raise Http404("App %r, model %r, not found" % (app_label, model_name))
    754755    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
    756758    try:
    757759        cl = ChangeList(request, model)
    758760    except IncorrectLookupParameters:
  • django/contrib/admin/templates/admin/index.html

     
    2020            <tr>
    2121            {% if model.perms.change %}
    2222                <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>
    2325            {% else %}
    2426                <th scope="row">{{ model.name }}</th>
    25             {% endif %}
     27            {% endif %}{% endif %}
    2628
    2729            {% if model.perms.add %}
    2830                <td><a href="{{ model.admin_url }}add/" class="addlink">{% trans 'Add' %}</a></td>
  • django/contrib/auth/management.py

     
    1212def _get_all_permissions(opts):
    1313    "Returns (codename, name) for all permissions in the given opts."
    1414    perms = []
    15     for action in ('add', 'change', 'delete'):
     15    for action in ('add', 'change', 'delete', 'view'):
    1616        perms.append((_get_permission_codename(action, opts), u'Can %s %s' % (action, opts.verbose_name_raw)))
    1717    return perms + list(opts.permissions)
    1818
  • django/contrib/auth/models.py

     
    6565        - The "add" permission limits the user's ability to view the "add" form and add an object.
    6666        - The "change" permission limits a user's ability to view the change list, view the "change" form and change an object.
    6767        - 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)
    6869
    6970    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."
    7071
Back to Top