1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-04 00:02:55 +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

@ -127,10 +127,10 @@ class TFJMUser(AbstractUser):
role = models.CharField(
max_length=16,
choices=[
("0admin", _("admin")),
("1volunteer", _("organizer")),
("2coach", _("coach")),
("3participant", _("participant")),
("0admin", _("Admin")),
("1volunteer", _("Organizer")),
("2coach", _("Coach")),
("3participant", _("Participant")),
]
)

View File

@ -6,4 +6,7 @@ from member.models import TFJMUser
class UserTable(tables.Table):
class Meta:
model = TFJMUser
fields = ("last_name", "first_name", "role",)
fields = ("last_name", "first_name", "role", "date_joined", )
attrs = {
'class': 'table table-condensed table-striped table-hover'
}

View File

@ -1,7 +1,7 @@
from django.urls import path
from django.views.generic import RedirectView
from .views import CreateUserView, DocumentView
from .views import CreateUserView, ProfileListView, OrphanedProfileListView, OrganizersListView
app_name = "member"
@ -12,7 +12,7 @@ urlpatterns = [
path("join-team/", RedirectView.as_view(pattern_name="index"), name="join_team"),
path("my-team/", RedirectView.as_view(pattern_name="index"), name="my_team"),
path("my-team/update/", RedirectView.as_view(pattern_name="index"), name="update_my_team"),
path("profiles/", RedirectView.as_view(pattern_name="index"), name="all_profiles"),
path("orphaned-profiles/", RedirectView.as_view(pattern_name="index"), name="orphaned_profiles"),
path("organizers/", RedirectView.as_view(pattern_name="index"), name="organizers"),
path("profiles/", ProfileListView.as_view(), name="all_profiles"),
path("orphaned-profiles/", OrphanedProfileListView.as_view(), name="orphaned_profiles"),
path("organizers/", OrganizersListView.as_view(), name="organizers"),
]

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"))