forked from jayesh92/vms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop volunteers from accessing admin urls.
Fixes #325
- Loading branch information
1 parent
e73efc9
commit d899878
Showing
6 changed files
with
36 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from functools import wraps | ||
from django.shortcuts import render | ||
|
||
def admin_required(func): | ||
@wraps(func) | ||
def wrapped_view(request, *args, **kwargs): | ||
admin = hasattr(request.user, 'administrator') | ||
if not admin: | ||
return render(request, 'vms/no_admin_rights.html', status=403) | ||
return func(request, *args, **kwargs) | ||
return wrapped_view |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from functools import wraps | ||
from django.shortcuts import render | ||
|
||
def volunteer_denied(func): | ||
@wraps(func) | ||
def wrapper(request, *args, **kwargs): | ||
if request.user.is_authenticated(): | ||
if not hasattr(request.user, 'administrator'): | ||
return render(request, 'vms/no_admin_rights.html', status=403) | ||
return func(request, *args, **kwargs) | ||
return wrapper | ||
|
This file contains 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
This file contains 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