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 each other's urls.
Fixes #326
- Loading branch information
1 parent
3804832
commit cf35353
Showing
5 changed files
with
67 additions
and
34 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
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,22 @@ | ||
{% extends "vms/base.html" %} | ||
|
||
{% load i18n %} | ||
|
||
{% block content %} | ||
<div class="spacer"></div> | ||
|
||
{% csrf_token %} | ||
<div class="panel panel-danger"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">{% trans "No Access" %}</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<br> | ||
{% trans "You don't have the necessary rights to access this page." %} | ||
<br> | ||
<br> | ||
<input type="button" class="btn btn-default" value="{% blocktrans %}Return to Previous Page{% endblocktrans %}" onClick="javascript:history.go(-1);"> | ||
</div> | ||
</div> | ||
|
||
{% endblock %} |
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,19 @@ | ||
from functools import wraps | ||
from django.shortcuts import render | ||
from django.http import Http404 | ||
from volunteer.services import get_volunteer_by_id | ||
|
||
def vol_id_check(func): | ||
@wraps(func) | ||
def wrapped_view(request, volunteer_id): | ||
vol = getattr(request.user, 'volunteer', hasattr(request.user, 'administrator')) | ||
if not vol: | ||
return render(request, 'vms/no_volunteer_access.html', status=403) | ||
elif vol != True: | ||
volunteer = get_volunteer_by_id(volunteer_id) | ||
if not volunteer: | ||
raise Http404 | ||
if not int(volunteer.id) == vol.id: | ||
return render(request, 'vms/no_volunteer_access.html', status=403) | ||
return func(request, volunteer_id=volunteer_id) | ||
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