﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
15215	API for simpler (permission or any) checks for generic view classes	Jari Pennanen	nobody	"The generic class based views are difficult and cumbersome to decorate, why even trying to reuse the decorator functions? Why not implement simple functions that would do the checking.

I propose following API for checking the class based views (in this case just permissions):

{{{
from django.contrib.auth.viewchecks import login_required, has_perms

class ProtectedView(TemplateView):
    template_name = 'secret.html'
    dispatch_checks = (login_required, has_perms('auth.change_user'),)
}}}
(Notice that I used hypothetical `django.contrib.auth.viewchecks`)

`dispatch_checks` is list of ''functions'' `(request, *args, **kwargs)` -> `bool` if allowed to dispatch. Thus the `has_perms('auth.change_user')` should return ''function''.

Above would also allow overriding the `dispatch_checks` tuple in subclassed views which I think is very important.

I'm working on a simple patch for `django.contrib.auth` and to `View` class to allow this, these checker functions should be reusable in decorators."	New feature	closed	Generic views	dev	Normal	duplicate		Tom Christie Selwin Ong amirouche.boubekki@…	Accepted	0	0	0	0	0	0
