#20921: Creating a decorator any_permission_required
-------------------------+-------------------------------------------------
     Reporter:           |      Owner:  fabiobatalha
  fabiobatalha@…         |     Status:  new
         Type:  New      |    Version:  1.5
  feature                |   Keywords:  auth perms required_permission
    Component:           |  has_perms
  contrib.auth           |  Has patch:  0
     Severity:  Normal   |      UI/UX:  0
 Triage Stage:           |
  Unreviewed             |
Easy pickings:  0        |
-------------------------+-------------------------------------------------
 When decorating a view with required_permission the developer can
 authorize a user to execute a view only if the user have all the perms
 informed is the decorator.

 In some situations it is necessary to allow the user to execute a view if
 the user have at least one of the allowed permissions. It could happen
 when some authorizations are controlled in the template level.

 For example:

 views.py
 @any_permission_required(['journalmanager.list_journal',
 'journalmanager.list_editor_journal'], login_url=AUTHZ_REDIRECT_URL)
 def dash_journal(request, journal_id=None):
     journal = get_object_or_404(models.Journal, id=journal_id)
     return render_to_response('journalmanager/journal_dash.html', {
                               'journal': journal,
                               }, context_instance=RequestContext(request))

 template:
         {% if perms.journalmanager.list_journal %}
                INTERFACE FEATURES FOR USERS WITH SIMPLE PERMS
         {% endif %}
         {% if perms.journalmanager.list_editor_journal %}
                INTERFACE FEATURES FOR USERS WITH EDITORS PERMS
         {% endif %}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20921>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.7dac0def891414c0695bd3f9ef799d6a%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to