From 95ba7798d7e109fd27a00c0b86ba5bc78177be72 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sun, 4 Nov 2018 23:07:57 +0100 Subject: [PATCH 1/9] Ignore VSCode files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 2f3d166c..825eed63 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ media/ # PyCharm .idea .cache + +# VSCode +.vscode/ \ No newline at end of file From 00a1e79af61f829df3b8c3a1af8d6016b446a8d4 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 00:54:44 +0100 Subject: [PATCH 2/9] Fix CAS support in python-cas 1.3+ cas.eleves.ens.fr has /serviceValidate, not /p3/serviceValidate, and is thus *probably* a V2 CAS server. python-cas was broken and using /serviceValidate for V3 while it should have been /p3/serviceValidate, see https://github.com/python-cas/python-cas/commit/c3ac4b6c769fcdf735cc48f9d51707041bc699b2 --- cof/settings/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cof/settings/common.py b/cof/settings/common.py index ebc7fb2a..4c853a16 100644 --- a/cof/settings/common.py +++ b/cof/settings/common.py @@ -186,7 +186,7 @@ LOGIN_URL = "cof-login" LOGIN_REDIRECT_URL = "home" CAS_SERVER_URL = "https://cas.eleves.ens.fr/" -CAS_VERSION = "3" +CAS_VERSION = "2" CAS_LOGIN_MSG = None CAS_IGNORE_REFERER = True CAS_REDIRECT_URL = "/" From 7124821f7c44882d038eb86a01e854957122b3d3 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 21:54:08 +0100 Subject: [PATCH 3/9] =?UTF-8?q?Permet=20la=20suppression=20d'un=20voeu=20a?= =?UTF-8?q?jout=C3=A9=20mais=20non=20enregistr=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Voir #203. Cette solution est horrible, tout comme le code dans lequel elle se trouve. Déso pas déso. --- bda/templates/bda/inscription-tirage.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bda/templates/bda/inscription-tirage.html b/bda/templates/bda/inscription-tirage.html index 3fd81378..9a39df6f 100644 --- a/bda/templates/bda/inscription-tirage.html +++ b/bda/templates/bda/inscription-tirage.html @@ -52,6 +52,11 @@ var django = { } else { deleteInput.attr("checked", true); } + } else { + // Reset the default values + var selects = $(form).find("select"); + $(selects[0]).val(""); + $(selects[1]).val("1"); } // callback }); From e09fa2b84742a6a3b113eac667ef93c0e703dfaa Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 22:16:43 +0100 Subject: [PATCH 4/9] Affiche un message d'erreur lors de l'enregistrement des voeux BDA Voir #203 --- bda/views.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bda/views.py b/bda/views.py index 050d6851..b67737bc 100644 --- a/bda/views.py +++ b/bda/views.py @@ -192,6 +192,7 @@ def inscription(request, tirage_id): success = False stateerror = False + form_invalid = False if request.method == "POST": # use *this* queryset dbstate = _hash_queryset(participant.choixspectacle_set.all()) @@ -204,6 +205,8 @@ def inscription(request, tirage_id): formset.save() success = True formset = BdaFormSet(instance=participant) + else: + form_invalid = True else: formset = BdaFormSet(instance=participant) # use *this* queryset @@ -217,15 +220,21 @@ def inscription(request, tirage_id): # Messages if success: messages.success( - request, "Votre inscription a été mise à jour avec " "succès !" + request, "Votre inscription a été mise à jour avec succès !" ) - if stateerror: + elif stateerror: messages.error( request, "Impossible d'enregistrer vos modifications " ": vous avez apporté d'autres modifications " "entre temps.", ) + elif form_invalid: + messages.error( + request, + "Une erreur s'est produite lors de l'enregistrement de vos vœux. " + "Avez-vous demandé plusieurs fois le même spectacle ?", + ) return render( request, "bda/inscription-tirage.html", From 511981e762acc8fba60f232b3f043685698ffd9d Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 22:22:49 +0100 Subject: [PATCH 5/9] Simplifie la Logique --- bda/views.py | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/bda/views.py b/bda/views.py index b67737bc..49d509eb 100644 --- a/bda/views.py +++ b/bda/views.py @@ -190,23 +190,31 @@ def inscription(request, tirage_id): formset=InscriptionInlineFormSet, ) - success = False - stateerror = False - form_invalid = False if request.method == "POST": # use *this* queryset dbstate = _hash_queryset(participant.choixspectacle_set.all()) if "dbstate" in request.POST and dbstate != request.POST["dbstate"]: - stateerror = True formset = BdaFormSet(instance=participant) + messages.error( + request, + "Impossible d'enregistrer vos modifications " + ": vous avez apporté d'autres modifications " + "entre temps.", + ) else: formset = BdaFormSet(request.POST, instance=participant) if formset.is_valid(): formset.save() - success = True formset = BdaFormSet(instance=participant) + messages.success( + request, "Votre inscription a été mise à jour avec succès !" + ) else: - form_invalid = True + messages.error( + request, + "Une erreur s'est produite lors de l'enregistrement de vos vœux. " + "Avez-vous demandé plusieurs fois le même spectacle ?", + ) else: formset = BdaFormSet(instance=participant) # use *this* queryset @@ -217,24 +225,6 @@ def inscription(request, tirage_id): total_price += choice.spectacle.price if choice.double: total_price += choice.spectacle.price - # Messages - if success: - messages.success( - request, "Votre inscription a été mise à jour avec succès !" - ) - elif stateerror: - messages.error( - request, - "Impossible d'enregistrer vos modifications " - ": vous avez apporté d'autres modifications " - "entre temps.", - ) - elif form_invalid: - messages.error( - request, - "Une erreur s'est produite lors de l'enregistrement de vos vœux. " - "Avez-vous demandé plusieurs fois le même spectacle ?", - ) return render( request, "bda/inscription-tirage.html", From b80927efa3c154dbcddeb7a2002081e8abdca595 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 22:44:09 +0100 Subject: [PATCH 6/9] Message d'erreur qui ne parle pas de object Voeu --- bda/views.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bda/views.py b/bda/views.py index 49d509eb..7f14ee37 100644 --- a/bda/views.py +++ b/bda/views.py @@ -11,6 +11,7 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required from django.core import serializers from django.core.urlresolvers import reverse +from django.core.exceptions import NON_FIELD_ERRORS from django.db import transaction from django.db.models import Count, Prefetch from django.forms.models import inlineformset_factory @@ -188,6 +189,12 @@ def inscription(request, tirage_id): ChoixSpectacle, fields=("spectacle", "double_choice", "priority"), formset=InscriptionInlineFormSet, + can_order=True, + error_messages={ + NON_FIELD_ERRORS: { + 'unique_together': "Vous avez déjà demandé ce voeu plus haut !", + }, + } ) if request.method == "POST": From d7f4d32c9229dc924cafb209de2de8a5fd695759 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 22:46:02 +0100 Subject: [PATCH 7/9] Oh mon dieu! --- bda/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bda/views.py b/bda/views.py index 7f14ee37..81669492 100644 --- a/bda/views.py +++ b/bda/views.py @@ -189,7 +189,6 @@ def inscription(request, tirage_id): ChoixSpectacle, fields=("spectacle", "double_choice", "priority"), formset=InscriptionInlineFormSet, - can_order=True, error_messages={ NON_FIELD_ERRORS: { 'unique_together': "Vous avez déjà demandé ce voeu plus haut !", From 042ce80b7863987ae3101112d4115a64ffe2c3cc Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 22:52:20 +0100 Subject: [PATCH 8/9] Run black --- bda/views.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bda/views.py b/bda/views.py index 81669492..93f37583 100644 --- a/bda/views.py +++ b/bda/views.py @@ -191,9 +191,9 @@ def inscription(request, tirage_id): formset=InscriptionInlineFormSet, error_messages={ NON_FIELD_ERRORS: { - 'unique_together': "Vous avez déjà demandé ce voeu plus haut !", - }, - } + "unique_together": "Vous avez déjà demandé ce voeu plus haut !" + } + }, ) if request.method == "POST": From 7f2f25cb710d1cbc5c0b417651a4ca02df172c62 Mon Sep 17 00:00:00 2001 From: Basile Clement Date: Mon, 12 Nov 2018 23:04:37 +0100 Subject: [PATCH 9/9] Isort --- bda/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bda/views.py b/bda/views.py index 93f37583..9c4c54f7 100644 --- a/bda/views.py +++ b/bda/views.py @@ -10,8 +10,8 @@ from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import login_required from django.core import serializers -from django.core.urlresolvers import reverse from django.core.exceptions import NON_FIELD_ERRORS +from django.core.urlresolvers import reverse from django.db import transaction from django.db.models import Count, Prefetch from django.forms.models import inlineformset_factory