Created
May 23, 2012 08:20
-
-
Save h4/2773863 to your computer and use it in GitHub Desktop.
Проверка вхождения пользователя в группу в Django
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not request.user.is_authenticated(): | |
return redirect('/login/?next=%s' % request.path) | |
else: | |
for group in request.user.groups.values_list(): | |
if (u'profsoux' in group) or request.user.is_staff: | |
break | |
else: | |
if not request.user.is_staff: | |
return render(request, 'denied.html', {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
вЧоНадо = reduce(lambda (id, name), tail: name == 'чонадо' or False, request.user.groups.values_list())