forked from DGNum/gestioCOF
Merge branch 'master' into aureplop/cof-tests_petitcours
This commit is contained in:
commit
a2116bf290
4 changed files with 30 additions and 17 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -15,3 +15,6 @@ media/
|
||||||
# PyCharm
|
# PyCharm
|
||||||
.idea
|
.idea
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
|
# VSCode
|
||||||
|
.vscode/
|
|
@ -52,6 +52,11 @@ var django = {
|
||||||
} else {
|
} else {
|
||||||
deleteInput.attr("checked", true);
|
deleteInput.attr("checked", true);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Reset the default values
|
||||||
|
var selects = $(form).find("select");
|
||||||
|
$(selects[0]).val("");
|
||||||
|
$(selects[1]).val("1");
|
||||||
}
|
}
|
||||||
// callback
|
// callback
|
||||||
});
|
});
|
||||||
|
|
37
bda/views.py
37
bda/views.py
|
@ -10,6 +10,7 @@ from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
|
from django.core.exceptions import NON_FIELD_ERRORS
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Count, Prefetch
|
from django.db.models import Count, Prefetch
|
||||||
|
@ -188,22 +189,38 @@ def inscription(request, tirage_id):
|
||||||
ChoixSpectacle,
|
ChoixSpectacle,
|
||||||
fields=("spectacle", "double_choice", "priority"),
|
fields=("spectacle", "double_choice", "priority"),
|
||||||
formset=InscriptionInlineFormSet,
|
formset=InscriptionInlineFormSet,
|
||||||
|
error_messages={
|
||||||
|
NON_FIELD_ERRORS: {
|
||||||
|
"unique_together": "Vous avez déjà demandé ce voeu plus haut !"
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
success = False
|
|
||||||
stateerror = False
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
# use *this* queryset
|
# use *this* queryset
|
||||||
dbstate = _hash_queryset(participant.choixspectacle_set.all())
|
dbstate = _hash_queryset(participant.choixspectacle_set.all())
|
||||||
if "dbstate" in request.POST and dbstate != request.POST["dbstate"]:
|
if "dbstate" in request.POST and dbstate != request.POST["dbstate"]:
|
||||||
stateerror = True
|
|
||||||
formset = BdaFormSet(instance=participant)
|
formset = BdaFormSet(instance=participant)
|
||||||
|
messages.error(
|
||||||
|
request,
|
||||||
|
"Impossible d'enregistrer vos modifications "
|
||||||
|
": vous avez apporté d'autres modifications "
|
||||||
|
"entre temps.",
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
formset = BdaFormSet(request.POST, instance=participant)
|
formset = BdaFormSet(request.POST, instance=participant)
|
||||||
if formset.is_valid():
|
if formset.is_valid():
|
||||||
formset.save()
|
formset.save()
|
||||||
success = True
|
|
||||||
formset = BdaFormSet(instance=participant)
|
formset = BdaFormSet(instance=participant)
|
||||||
|
messages.success(
|
||||||
|
request, "Votre inscription a été mise à jour avec succès !"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
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:
|
else:
|
||||||
formset = BdaFormSet(instance=participant)
|
formset = BdaFormSet(instance=participant)
|
||||||
# use *this* queryset
|
# use *this* queryset
|
||||||
|
@ -214,18 +231,6 @@ def inscription(request, tirage_id):
|
||||||
total_price += choice.spectacle.price
|
total_price += choice.spectacle.price
|
||||||
if choice.double:
|
if choice.double:
|
||||||
total_price += choice.spectacle.price
|
total_price += choice.spectacle.price
|
||||||
# Messages
|
|
||||||
if success:
|
|
||||||
messages.success(
|
|
||||||
request, "Votre inscription a été mise à jour avec " "succès !"
|
|
||||||
)
|
|
||||||
if stateerror:
|
|
||||||
messages.error(
|
|
||||||
request,
|
|
||||||
"Impossible d'enregistrer vos modifications "
|
|
||||||
": vous avez apporté d'autres modifications "
|
|
||||||
"entre temps.",
|
|
||||||
)
|
|
||||||
return render(
|
return render(
|
||||||
request,
|
request,
|
||||||
"bda/inscription-tirage.html",
|
"bda/inscription-tirage.html",
|
||||||
|
|
|
@ -186,7 +186,7 @@ LOGIN_URL = "cof-login"
|
||||||
LOGIN_REDIRECT_URL = "home"
|
LOGIN_REDIRECT_URL = "home"
|
||||||
|
|
||||||
CAS_SERVER_URL = "https://cas.eleves.ens.fr/"
|
CAS_SERVER_URL = "https://cas.eleves.ens.fr/"
|
||||||
CAS_VERSION = "3"
|
CAS_VERSION = "2"
|
||||||
CAS_LOGIN_MSG = None
|
CAS_LOGIN_MSG = None
|
||||||
CAS_IGNORE_REFERER = True
|
CAS_IGNORE_REFERER = True
|
||||||
CAS_REDIRECT_URL = "/"
|
CAS_REDIRECT_URL = "/"
|
||||||
|
|
Loading…
Reference in a new issue