﻿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
33299	Add @request_passes_test decorator.	Iago González	nobody	"The `user_passes_test` is a little bit limited when used for restricting the views. For example: you cannot use the Django messages framework, because you cannot access the `request` object.

I suggest creating a `request_passes_test` to allow the creation of more advanced restrictions and logic.

Other developers that use Django also need this feature:
[https://stackoverflow.com/questions/11872560/how-to-pass-django-request-object-in-user-passes-test-decorator-callable-functio]
[https://stackoverflow.com/questions/16375023/show-error-message-when-decorator-fails]

I will add three solutions for this problem. These were quick solutions not tested, so they can have some errors; but I'm willing to open a Pull Request and improve the better approach. My favourite one is the solution 1, because it uses an abstract function that could be reused for creating both `user_passes_test` and `request_passes_test`. The other 2 solutions are uglier, but I add them just in case.

Thanks!"	New feature	closed	contrib.auth	3.2	Normal	wontfix	user_passes_test, request, Auth	Iago González	Unreviewed	0	0	0	0	1	0
