plateforme-tfjm2/apps/member/views.py

25 lines
719 B
Python
Raw Normal View History

2020-04-29 23:20:50 +00:00
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.http import FileResponse
from django.views import View
2020-04-29 13:29:01 +00:00
from django.views.generic import CreateView
2020-04-29 02:06:02 +00:00
2020-04-29 13:29:01 +00:00
from .forms import SignUpForm
2020-04-29 23:20:50 +00:00
from .models import TFJMUser, Document
2020-04-29 13:29:01 +00:00
class CreateUserView(CreateView):
model = TFJMUser
form_class = SignUpForm
template_name = "registration/signup.html"
2020-04-29 23:20:50 +00:00
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")