From f18b2cc4f4aa7b2ed2d7801c19ddf75acbb6abc2 Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Thu, 7 Sep 2017 22:22:46 +0200
Subject: Remplacement de la page d’acceuil par la liste des années, menant sur
une liste de mentions, puis une liste de groupes, etc etc.
---
views.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index 176f174..363fddb 100644
--- a/views.py
+++ b/views.py
@@ -18,12 +18,21 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.core.mail import send_mail
from django.conf import settings
from django.template import Context, loader
+from django.db.models import Count
from .forms import SubscribeForm
from .models import Timetable, LastUpdate, Group, Subscription, Course
from .utils import get_current_week, get_week, group_courses
def index(request):
+ years = Timetable.objects.order_by("year").values("year").annotate(count=Count("year"))
+ return render(request, "index.html", {"years": years})
+
+def mention_list(request, year):
+ timetables = Timetable.objects.order_by("name").filter(year=year)
+ return render(request, "mention_list.html", {"year": year, "timetables": timetables})
+
+def timetables_list(request):
timetables = Timetable.objects.order_by("name")
groups = Group.objects.get_relevant_groups().order_by("name")
@@ -44,7 +53,7 @@ def index(request):
if hasattr(group, "weeks"):
group.weeks.sort()
- return render(request, "index.html", {"timetables": timetables, "groups": groups})
+ return render(request, "timetables_list.html", {"timetables": timetables, "groups": groups})
def timetable(request, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None:
--
cgit v1.2.1
From 36b4c60aacae827b5ff8b6125bdfd70d7cf2a3a0 Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Thu, 7 Sep 2017 22:40:57 +0200
Subject: J’ai fait des trucs mais je me suis rendu compte que c’est pas
terrible, du coup je fais un commit tout pété mais ça va vite changer vous
inquiétez pas.
---
views.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index 363fddb..141dde8 100644
--- a/views.py
+++ b/views.py
@@ -32,9 +32,9 @@ def mention_list(request, year):
timetables = Timetable.objects.order_by("name").filter(year=year)
return render(request, "mention_list.html", {"year": year, "timetables": timetables})
-def timetables_list(request):
- timetables = Timetable.objects.order_by("name")
- groups = Group.objects.get_relevant_groups().order_by("name")
+def group_list(request, year, timetable_slug):
+ timetable = get_object_or_404(Timetable, slug=timetable_slug)
+ groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
year, week = get_current_week()
start, _ = get_week(year, week)
@@ -53,7 +53,7 @@ def timetables_list(request):
if hasattr(group, "weeks"):
group.weeks.sort()
- return render(request, "timetables_list.html", {"timetables": timetables, "groups": groups})
+ return render(request, "group_list.html", {"timetables": timetables, "groups": groups})
def timetable(request, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None:
--
cgit v1.2.1
From 5767fe2b49858dd8174193ffa8c2e8b3fda1fc6c Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Thu, 7 Sep 2017 23:12:57 +0200
Subject: Utilisation du modèle Year où nécessaire
---
views.py | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index 141dde8..ea3a5be 100644
--- a/views.py
+++ b/views.py
@@ -21,24 +21,27 @@ from django.template import Context, loader
from django.db.models import Count
from .forms import SubscribeForm
-from .models import Timetable, LastUpdate, Group, Subscription, Course
+from .models import Timetable, LastUpdate, Group, Subscription, Course, Year
from .utils import get_current_week, get_week, group_courses
def index(request):
- years = Timetable.objects.order_by("year").values("year").annotate(count=Count("year"))
+ years = Year.objects.order_by("name")
return render(request, "index.html", {"years": years})
-def mention_list(request, year):
+def mention_list(request, year_slug):
+ year = get_object_or_404(Year, slug=year_slug)
timetables = Timetable.objects.order_by("name").filter(year=year)
+
return render(request, "mention_list.html", {"year": year, "timetables": timetables})
-def group_list(request, year, timetable_slug):
+def group_list(request, year_slug, timetable_slug):
+ get_object_or_404(Year, slug=year_slug)
timetable = get_object_or_404(Timetable, slug=timetable_slug)
- groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
+ groups = Group.objects.get_relevant_groups().order_by("name")
year, week = get_current_week()
start, _ = get_week(year, week)
- groups_weeks = Course.objects.get_weeks(begin__gte=start).values("groups__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week")
+ groups_weeks = Course.objects.get_weeks(begin__gte=start).values("group__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week")
for group in groups:
for group_week in groups_weeks:
@@ -53,7 +56,7 @@ def group_list(request, year, timetable_slug):
if hasattr(group, "weeks"):
group.weeks.sort()
- return render(request, "group_list.html", {"timetables": timetables, "groups": groups})
+ return render(request, "group_list.html", {"timetable": timetable, "groups": groups})
def timetable(request, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None:
--
cgit v1.2.1
From 49e56d97e5a126f66d1d52b5de45befe603893b2 Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Thu, 7 Sep 2017 23:31:54 +0200
Subject: Remplacement de la licence GPL 2 par la licence AGPL 3
---
views.py | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index ea3a5be..32a45fe 100644
--- a/views.py
+++ b/views.py
@@ -1,18 +1,17 @@
# Copyright (C) 2017 Alban Gruin
#
-# celcatsanitizer is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
+# celcatsanitizer is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# celcatsanitizer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# GNU Affero General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along
-# with celcatsanitizer; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU Affero General Public License
+# along with celcatsanitizer. If not, see .
from django.shortcuts import get_object_or_404, redirect, render
from django.core.mail import send_mail
--
cgit v1.2.1
From 0a287c2013bcfd1cb71926fbd0835170369521f7 Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Fri, 8 Sep 2017 00:18:21 +0200
Subject: Simplification du traitement des semaines
---
views.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index 32a45fe..31a89f5 100644
--- a/views.py
+++ b/views.py
@@ -36,15 +36,15 @@ def mention_list(request, year_slug):
def group_list(request, year_slug, timetable_slug):
get_object_or_404(Year, slug=year_slug)
timetable = get_object_or_404(Timetable, slug=timetable_slug)
- groups = Group.objects.get_relevant_groups().order_by("name")
+ groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
year, week = get_current_week()
start, _ = get_week(year, week)
- groups_weeks = Course.objects.get_weeks(begin__gte=start).values("group__timetable", "groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week")
+ groups_weeks = Course.objects.get_weeks(begin__gte=start, timetable=timetable).values("groups__mention", "groups__subgroup", "groups__td", "groups__tp", "year", "week")
for group in groups:
for group_week in groups_weeks:
- if group.corresponds_to(group_week["groups__timetable"], group_week["groups__mention"], group_week["groups__subgroup"], group_week["groups__td"], group_week["groups__tp"]):
+ if group.corresponds_to(timetable.id, group_week["groups__mention"], group_week["groups__subgroup"], group_week["groups__td"], group_week["groups__tp"]):
if not hasattr(group, "weeks"):
group.weeks = []
--
cgit v1.2.1
From 57ffdbf0658042069abcf0b1f9184ff69a3139e2 Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Fri, 8 Sep 2017 11:53:49 +0200
Subject: Ajout de l’année dans les urls
---
views.py | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index 31a89f5..f48509d 100644
--- a/views.py
+++ b/views.py
@@ -34,8 +34,8 @@ def mention_list(request, year_slug):
return render(request, "mention_list.html", {"year": year, "timetables": timetables})
def group_list(request, year_slug, timetable_slug):
- get_object_or_404(Year, slug=year_slug)
- timetable = get_object_or_404(Timetable, slug=timetable_slug)
+ year_obj = get_object_or_404(Year, slug=year_slug)
+ timetable = get_object_or_404(Timetable, year=year_obj, slug=timetable_slug)
groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
year, week = get_current_week()
@@ -57,12 +57,13 @@ def group_list(request, year_slug, timetable_slug):
return render(request, "group_list.html", {"timetable": timetable, "groups": groups})
-def timetable(request, timetable_slug, group_slug, year=None, week=None):
+def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=None):
if year is None or week is None:
year, week = get_current_week()
start, end = get_week(int(year), int(week))
+ get_object_or_404(Year, slug=year_slug)
timetable = get_object_or_404(Timetable, slug=timetable_slug)
group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
last_update = get_object_or_404(LastUpdate, timetable=timetable, week=week, year=year)
@@ -72,8 +73,9 @@ def timetable(request, timetable_slug, group_slug, year=None, week=None):
return render(request, "timetable.html", {"group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": int(week)})
-def subscribe(request, timetable_slug, group_slug, year, week):
- timetable = get_object_or_404(Timetable, slug=timetable_slug)
+def subscribe(request, year_slug, timetable_slug, group_slug, year, week):
+ year_obj = get_object_or_404(Year, slug=year_slug)
+ timetable = get_object_or_404(Timetable, year=year_obj, slug=timetable_slug)
group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
if request.method == "POST":
@@ -87,7 +89,7 @@ def subscribe(request, timetable_slug, group_slug, year, week):
context = Context({"group": group, "admins": settings.ADMINS, "token": subscription.token, "domain": settings.DEFAULT_DOMAIN})
send_mail("Confirmation de l’abonnemenent", template.render(context), settings.DEFAULT_FROM_EMAIL, [request.POST["email"]])
- return redirect("timetable", timetable_slug=timetable_slug, group_slug=group_slug, year=year, week=int(week))
+ return redirect("timetable", year_slug=year_slug, timetable_slug=timetable_slug, group_slug=group_slug, year=year, week=int(week))
else:
form = SubscribeForm()
--
cgit v1.2.1
From ee98e2d23a0d6bf449850f5dfef756bcde62909a Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Fri, 8 Sep 2017 12:08:24 +0200
Subject: Suppression des imports inutiles
---
views.py | 1 -
1 file changed, 1 deletion(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index f48509d..ffed2cc 100644
--- a/views.py
+++ b/views.py
@@ -17,7 +17,6 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.core.mail import send_mail
from django.conf import settings
from django.template import Context, loader
-from django.db.models import Count
from .forms import SubscribeForm
from .models import Timetable, LastUpdate, Group, Subscription, Course, Year
--
cgit v1.2.1
From af0fe7024ce13cdb30170f00df8a1883eef23bf8 Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Fri, 8 Sep 2017 12:58:04 +0200
Subject: Changement des index du modèle Timetable, meilleure utilisation des
requêtes
---
views.py | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index ffed2cc..2101a21 100644
--- a/views.py
+++ b/views.py
@@ -33,8 +33,7 @@ def mention_list(request, year_slug):
return render(request, "mention_list.html", {"year": year, "timetables": timetables})
def group_list(request, year_slug, timetable_slug):
- year_obj = get_object_or_404(Year, slug=year_slug)
- timetable = get_object_or_404(Timetable, year=year_obj, slug=timetable_slug)
+ timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug)
groups = Group.objects.get_relevant_groups(timetable=timetable).order_by("name")
year, week = get_current_week()
@@ -62,8 +61,7 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
start, end = get_week(int(year), int(week))
- get_object_or_404(Year, slug=year_slug)
- timetable = get_object_or_404(Timetable, slug=timetable_slug)
+ timetable = get_object_or_404(Timetable, year__slug=year_slug, slug=timetable_slug)
group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
last_update = get_object_or_404(LastUpdate, timetable=timetable, week=week, year=year)
courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end)
@@ -73,9 +71,7 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
return render(request, "timetable.html", {"group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": int(week)})
def subscribe(request, year_slug, timetable_slug, group_slug, year, week):
- year_obj = get_object_or_404(Year, slug=year_slug)
- timetable = get_object_or_404(Timetable, year=year_obj, slug=timetable_slug)
- group = get_object_or_404(Group, slug=group_slug, timetable=timetable)
+ group = get_object_or_404(Group, slug=group_slug, timetable__slug=timetable_slug, timetable__year__slug=year_slug)
if request.method == "POST":
form = SubscribeForm(request.POST)
--
cgit v1.2.1
From c7fce37ad4c8dee76f5d58eafefd0c73a03ea00c Mon Sep 17 00:00:00 2001
From: Alban Gruin
Date: Sat, 9 Sep 2017 14:56:17 +0200
Subject: Suppression de l’envoi des mails
---
views.py | 51 ++-------------------------------------------------
1 file changed, 2 insertions(+), 49 deletions(-)
(limited to 'views.py')
diff --git a/views.py b/views.py
index 2101a21..f445725 100644
--- a/views.py
+++ b/views.py
@@ -13,13 +13,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with celcatsanitizer. If not, see .
-from django.shortcuts import get_object_or_404, redirect, render
-from django.core.mail import send_mail
-from django.conf import settings
-from django.template import Context, loader
+from django.shortcuts import get_object_or_404, render
-from .forms import SubscribeForm
-from .models import Timetable, LastUpdate, Group, Subscription, Course, Year
+from .models import Timetable, LastUpdate, Group, Course, Year
from .utils import get_current_week, get_week, group_courses
def index(request):
@@ -69,46 +65,3 @@ def timetable(request, year_slug, timetable_slug, group_slug, year=None, week=No
grouped_courses = group_courses(courses)
return render(request, "timetable.html", {"group": group, "courses": grouped_courses, "last_update": last_update.date, "year": year, "week": int(week)})
-
-def subscribe(request, year_slug, timetable_slug, group_slug, year, week):
- group = get_object_or_404(Group, slug=group_slug, timetable__slug=timetable_slug, timetable__year__slug=year_slug)
-
- if request.method == "POST":
- form = SubscribeForm(request.POST)
- if form.is_valid():
- if not Subscription.objects.filter(email=request.POST["email"], group=group).exists():
- subscription = Subscription(email=request.POST["email"], group=group)
- subscription.save()
-
- template = loader.get_template("mail/mail_confirm.txt")
- context = Context({"group": group, "admins": settings.ADMINS, "token": subscription.token, "domain": settings.DEFAULT_DOMAIN})
- send_mail("Confirmation de l’abonnemenent", template.render(context), settings.DEFAULT_FROM_EMAIL, [request.POST["email"]])
-
- return redirect("timetable", year_slug=year_slug, timetable_slug=timetable_slug, group_slug=group_slug, year=year, week=int(week))
- else:
- form = SubscribeForm()
-
- return render(request, "subscribe.html", {"year": year, "week": week, "group": group, "form": form})
-
-def confirm_subscription(request, token):
- subscription = Subscription.objects.filter(token=token).first()
- year, week = get_current_week()
-
- if subscription is not None and not subscription.active:
- subscription.active = True
- subscription.save()
-
- return redirect("timetable", timetable_slug=subscription.group.timetable.slug, group_slug=subscription.group.slug, year=year, week=week)
-
-def cancel_subscription(request, token):
- subscription = Subscription.objects.filter(token=token).first()
-
- if subscription is not None:
- group = subscription.group
- subscription.delete()
-
- template = loader.get_template("mail/mail_unsubscribed.txt")
- context = Context({"group": group})
- send_mail("Confirmation de la désinscription", template.render(context), settings.DEFAULT_FROM_EMAIL, [subscription.email])
-
- return redirect("index")
--
cgit v1.2.1