Commit ce196335 authored by Tom van Bussel's avatar Tom van Bussel
Browse files

Merge branch 'fix/education-membership-required' into 'master'

Add membership decorator and require an active membership to download exams/summaries

See merge request !814
parents d100b118 3ce929b2
......@@ -32,6 +32,14 @@ members\.apps module
members\.decorators module
.. automodule:: members.decorators
members\.emails module
......@@ -10,6 +10,7 @@ from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from sendfile import sendfile
from members.decorators import membership_required
from .forms import AddExamForm, AddSummaryForm
from .models import Category, Course, Exam, Summary
......@@ -60,6 +61,7 @@ def course(request, id):
def exam(request, id):
Fetches and outputs the specified exam
......@@ -79,6 +81,7 @@ def exam(request, id):
def summary(request, id):
Fetches and outputs the specified summary
from django.core.exceptions import PermissionDenied
def membership_required(view_function):
return ActiveMembershipRequired(view_function)
class ActiveMembershipRequired(object):
def __init__(self, view_function):
self.view_function = view_function
def __call__(self, request, *args, **kwargs):
if request.member and request.member.has_active_membership():
return self.view_function(request, *args, **kwargs)
raise PermissionDenied
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment