1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-02-11 17:41:20 +00:00

25 lines
719 B
Python
Raw Normal View History

2020-04-30 01:20:50 +02: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 15:29:01 +02:00
from django.views.generic import CreateView
2020-04-29 04:06:02 +02:00
2020-04-29 15:29:01 +02:00
from .forms import SignUpForm
2020-04-30 01:20:50 +02:00
from .models import TFJMUser, Document
2020-04-29 15:29:01 +02:00
class CreateUserView(CreateView):
model = TFJMUser
form_class = SignUpForm
template_name = "registration/signup.html"
2020-04-30 01:20:50 +02: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")