1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-08-05 01:43:45 +02:00

Profile list

This commit is contained in:
Yohann D'ANELLO
2020-04-30 21:07:12 +02:00
parent f70f6f16f0
commit 03f47f996b
8 changed files with 124 additions and 52 deletions

View File

@@ -1,11 +1,16 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import PermissionDenied
from django.db.models import Q
from django.http import FileResponse
from django.utils.translation import gettext_lazy as _
from django.views import View
from django.views.generic import CreateView
from django_tables2 import SingleTableView
from tournament.views import AdminMixin
from .forms import SignUpForm
from .models import TFJMUser, Document
from .tables import UserTable
class CreateUserView(CreateView):
@@ -22,3 +27,29 @@ class DocumentView(LoginRequiredMixin, View):
raise PermissionDenied
return FileResponse(doc.file, content_type="application/pdf")
class ProfileListView(LoginRequiredMixin, AdminMixin, SingleTableView):
model = TFJMUser
queryset = TFJMUser.objects.order_by("role", "last_name", "first_name")
table_class = UserTable
template_name = "member/profile_list.html"
extra_context = dict(title=_("All profiles"))
class OrphanedProfileListView(LoginRequiredMixin, AdminMixin, SingleTableView):
model = TFJMUser
queryset = TFJMUser.objects.filter((Q(role="2coach") | Q(role="3participant")) & Q(team__isnull=True))\
.order_by("role", "last_name", "first_name")
table_class = UserTable
template_name = "member/profile_list.html"
extra_context = dict(title=_("Orphaned profiles"))
class OrganizersListView(LoginRequiredMixin, AdminMixin, SingleTableView):
model = TFJMUser
queryset = TFJMUser.objects.filter(Q(role="0admin") | Q(role="1volunteer"))\
.order_by("role", "last_name", "first_name")
table_class = UserTable
template_name = "member/profile_list.html"
extra_context = dict(title=_("Organizers"))