25 lines
719 B
Python
25 lines
719 B
Python
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
from django.core.exceptions import PermissionDenied
|
|
from django.http import FileResponse
|
|
from django.views import View
|
|
from django.views.generic import CreateView
|
|
|
|
from .forms import SignUpForm
|
|
from .models import TFJMUser, Document
|
|
|
|
|
|
class CreateUserView(CreateView):
|
|
model = TFJMUser
|
|
form_class = SignUpForm
|
|
template_name = "registration/signup.html"
|
|
|
|
|
|
class DocumentView(LoginRequiredMixin, View):
|
|
def get(self, request, *args, **kwargs):
|
|
doc = Document.objects.get(file=self.kwargs["file"])
|
|
|
|
if not request.user.admin:
|
|
raise PermissionDenied
|
|
|
|
return FileResponse(doc.file, content_type="application/pdf")
|