deprecated url support

This commit is contained in:
Valentin Moguérou 2024-05-17 01:29:21 +02:00
parent 3554d4fbcc
commit eb84355d17
5 changed files with 92 additions and 1234 deletions

View File

@ -0,0 +1,71 @@
{% extends "base.html" %}
{% load static %}
{% load extras %}
{% block title %}Tableau de bord{% endblock title %}
{% block main %}
{% block intro %}
{% endblock %}
{% if colles %}
{% regroup colles by week_number as week_list %}
{% for week in week_list %}
<h3 class="week" id="week-no-{{ week.grouper }}">
<a href="#week-no-{{ week.grouper }}">Semaine {{ week.grouper }}</a>
</h3>
<div class="colle-wrapper">
{% for colle in week.list %}
<div class="colle">
<ul>
<li><i class="fa-solid fa-graduation-cap"></i> {{ colle.slot.subject }}</li>
<li><i class="fa-solid fa-person-chalkboard"></i> {{ colle.slot.colleur }}</li>
<li><i class="fa-solid fa-clock"></i> {{ colle.datetime|date:"l"|title }} {{ colle.datetime|date:"DATETIME_FORMAT" }}</li>
<li>
<details>
<summary><i class="fa-solid fa-users"></i>
{{ colle.groups.all | print_manager | safe }}
({{ colle.volume }} / {{ colle.slot.capacity }})</summary>
{% if colle.final_group.exists %}
<ul>
{% for member in colle.final_group.all %}
<li>{{ member }}</li>
{% endfor %}
</ul>
{% else %}
Personne n'est inscrit à cette colle.
{% endif %}
</details>
</li>
<li><i class="fa-solid fa-earth-americas"></i> {{ colle.slot.room }}</li>
{% if False %}
<li><i class="fa-solid fa-circle-exclamation"></i>
<form
action="{% url "colloscope:withdraw" %}"
method="POST"
onsubmit="return confirm('Êtes-vous sûr de vouloir vous désinscrire de la colle {{ colle }} ');">
{% csrf_token %}
<input type="hidden" name="colle_id" value="{{ colle.id }}">
<button type="submit">Rendre disponible</button>
</form>
</li>
{% endif %}
</ul>
</div>
{% endfor %}
</div>
{% endfor %}
{% else %}
Aucune colle.
{% endif %}
{% endblock main %}

View File

@ -15,7 +15,7 @@ urlpatterns = [
path("marketplace", views.marketplace, name="marketplace"), path("marketplace", views.marketplace, name="marketplace"),
path("action/enroll", views.enroll, name="enroll"), path("action/enroll", views.enroll, name="enroll"),
path("action/withdraw", views.withdraw, name="withdraw"), path("action/withdraw", views.withdraw, name="withdraw"),
path("colles/", ColleListView.as_view(), name="colles"), path("listing/", ColleListView.as_view(), name="colles"),
path("colles/by_subject/<int:subject>/", ColleListView.as_view(), name="colles_by_subject"), path("listing/by_subject/<int:subject>/", ColleListView.as_view(), name="colles_by_subject"),
path("colles/by_colleur/<int:colleur>/", ColleListView.as_view(), name="colles_by_colleur"), path("listing/by_colleur/<int:colleur>/", ColleListView.as_view(), name="colles_by_colleur"),
] ]

View File

@ -1,6 +1,7 @@
from uuid import uuid4 from uuid import uuid4
from django import forms from django import forms
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from django.http import HttpResponse, HttpResponseRedirect from django.http import HttpResponse, HttpResponseRedirect
from django.template import loader from django.template import loader
@ -48,11 +49,24 @@ def select_profile(request):
return HttpResponse(template.render(context)) return HttpResponse(template.render(context))
class ColleListView(ListView): class ColleListView(LoginRequiredMixin, ListView):
model = Colle model = Colle
context_object_name = "colles"
def get_queryset(self): def get_queryset(self):
pass student = Profile.from_request(self.request)
base_query = (student.cls
.current_term()
.query_colles()
.filter(datetime__gte=date.today()))
if self.kwargs.get("subject") is not None:
base_query = base_query.filter(slot__subject__id=self.kwargs.get("subject"))
if self.kwargs.get("colleur") is not None:
base_query = base_query.filter(slot__colleur__id=self.kwargs.get("colleur"))
return base_query
@login_required @login_required
def dashboard(request): def dashboard(request):
@ -141,7 +155,7 @@ def colloscope(request):
.prefetch_related("student__cls__term_set")) .prefetch_related("student__cls__term_set"))
) )
except ValueError: except ValueError:
return redirect("colloscope.select_profile") return redirect("colloscope:select_profile")
if not isinstance(student, Student): if not isinstance(student, Student):
return HttpResponse("pas encore supporté") return HttpResponse("pas encore supporté")

View File

@ -125,6 +125,7 @@ LANGUAGE_CODE = 'fr'
TIME_ZONE = 'Europe/Paris' TIME_ZONE = 'Europe/Paris'
USE_I18N = True USE_I18N = True
USE_L10N = True
USE_TZ = True USE_TZ = True

File diff suppressed because it is too large Load Diff