Opened 11 years ago
Closed 11 years ago
#20828 closed New feature (fixed)
@permission_required should accept a list of permissions
Reported by: | Giggaflop | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
This would remove the requirement to double wrap functions in permissions_required decorators to apply multiple permissions to a view.
This use case occurs when a view sits on modification of multiple models and therefore it is required that multiple permissions are checked.
Example of change:
User must be a manager with the authority to manage invoices to create/update invoices.
@permission_required(['order.invoice','auth.manager']) def purchase_request(request, item_uuid, quantity): item = models.Item.objects.get(pk=item_uuid) invoice, created = models.Invoice.objects.get_or_create(item=item, user=request.user, quantity=quantity) return render(request, 'order/invoice.html', {'item':item, 'invoice':invoice, 'created':created})
Change History (5)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Component: | Uncategorized → contrib.auth |
---|---|
Triage Stage: | Unreviewed → Accepted |
Version: | → master |
Looks like a sensible request.
comment:3 by , 11 years ago
I've added a pull request : https://github.com/django/django/pull/1448 . Could someone take a look at it?
comment:4 by , 11 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
possible implementation, not tested.