Last active
March 15, 2020 09:10
-
-
Save LouisdeBruijn/4c7e18c71dd5e9defb2edc90027634e4 to your computer and use it in GitHub Desktop.
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
| @require_http_methods(["GET"]) | |
| @login_required(login_url='/login', redirect_field_name='') | |
| def index(request): | |
| # Verbose user permission authentication! | |
| groups = [group.name for group in request.user.groups.all()] | |
| if not any(x in groups for x in ['PERMISSION_GR_1', 'PERMISSION_GR_2']): | |
| messages.add_message(request, messages.WARNING, '{0} does not have permission.'.format(request.user)) | |
| return redirect('home') | |
| # Do something meaningful on this route | |
| return render(request, 'pages/index.html', {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment