forked from DGNum/gestioCOF
PEP8: Enforced other rules, including 80 cols
This commit is contained in:
parent
c7a3656ded
commit
88bccc0e60
23 changed files with 571 additions and 324 deletions
65
bda/admin.py
65
bda/admin.py
|
@ -4,27 +4,36 @@ from django.core.mail import send_mail
|
|||
|
||||
from django.contrib import admin
|
||||
from django.db.models import Sum, Count
|
||||
from bda.models import Spectacle, Salle, Participant, ChoixSpectacle, Attribution, Tirage
|
||||
from bda.models import Spectacle, Salle, Participant, ChoixSpectacle,\
|
||||
Attribution, Tirage
|
||||
from django import forms
|
||||
|
||||
from datetime import timedelta
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
|
||||
class ChoixSpectacleInline(admin.TabularInline):
|
||||
model = ChoixSpectacle
|
||||
sortable_field_name = "priority"
|
||||
|
||||
|
||||
class AttributionInline(admin.TabularInline):
|
||||
model = Attribution
|
||||
|
||||
|
||||
class ParticipantAdmin(admin.ModelAdmin):
|
||||
inlines = [AttributionInline]
|
||||
|
||||
def get_queryset(self, request):
|
||||
return Participant.objects.annotate(nb_places=Count('attributions'),
|
||||
total=Sum('attributions__price'))
|
||||
|
||||
def nb_places(self, obj):
|
||||
return obj.nb_places
|
||||
nb_places.admin_order_field = "nb_places"
|
||||
nb_places.short_description = "Nombre de places"
|
||||
|
||||
def total(self, obj):
|
||||
tot = obj.total
|
||||
if tot:
|
||||
|
@ -51,8 +60,9 @@ class ParticipantAdmin(admin.ModelAdmin):
|
|||
Tu t'es inscrit-e pour le tirage au sort du BdA. Malheureusement, tu n'as
|
||||
obtenu aucune place.
|
||||
|
||||
Nous proposons cependant de nombreuses offres hors-tirage tout au long de
|
||||
l'année, et nous t'invitons à nous contacter si l'une d'entre elles t'intéresse !
|
||||
Nous proposons cependant de nombreuses offres hors-tirage tout au long de
|
||||
l'année, et nous t'invitons à nous contacter si l'une d'entre elles
|
||||
t'intéresse !
|
||||
--
|
||||
Le Bureau des Arts
|
||||
|
||||
|
@ -71,15 +81,16 @@ pour les spectacles suivants :
|
|||
L'intégralité de ces places de spectacles est à régler dès maintenant et AVANT
|
||||
le %s, au bureau du COF pendant les heures de permanences (du lundi au vendredi
|
||||
entre 12h et 14h, et entre 18h et 20h). Des facilités de paiement sont bien
|
||||
évidemment possibles : nous pouvons ne pas encaisser le chèque immédiatement, ou
|
||||
bien découper votre paiement en deux fois. Pour ceux qui ne pourraient pas venir
|
||||
payer au bureau, merci de nous contacter par mail.
|
||||
évidemment possibles : nous pouvons ne pas encaisser le chèque immédiatement,
|
||||
ou bien découper votre paiement en deux fois. Pour ceux qui ne pourraient pas
|
||||
venir payer au bureau, merci de nous contacter par mail.
|
||||
|
||||
*Mode de retrait des places*
|
||||
Au moment du paiement, certaines places vous seront remises directement, d'autres
|
||||
seront à récupérer au cours de l'année, d'autres encore seront nominatives et à retirer
|
||||
le soir même dans les theâtres correspondants. Pour chaque spectacle, vous recevrez un mail
|
||||
quelques jours avant la représentation vous indiquant le mode de retrait.
|
||||
Au moment du paiement, certaines places vous seront remises directement,
|
||||
d'autres seront à récupérer au cours de l'année, d'autres encore seront
|
||||
nominatives et à retirer le soir même dans les theâtres correspondants.
|
||||
Pour chaque spectacle, vous recevrez un mail quelques jours avant la
|
||||
représentation vous indiquant le mode de retrait.
|
||||
|
||||
Nous vous rappelons que l'obtention de places du BdA vous engage à
|
||||
respecter les règles de fonctionnement :
|
||||
|
@ -96,10 +107,11 @@ Le Bureau des Arts
|
|||
for attrib in attribs:
|
||||
attribs_text += u"- 1 place pour %s\n" % attrib
|
||||
deadline = member.tirage.fermeture + timedelta(days=7)
|
||||
mail = mail % (name, attribs_text, deadline.strftime('%d %b %Y'))
|
||||
send_mail ("Résultats du tirage au sort", mail,
|
||||
"bda@ens.fr", [member.user.email],
|
||||
fail_silently=True)
|
||||
mail = mail % (name, attribs_text,
|
||||
deadline.strftime('%d %b %Y'))
|
||||
send_mail("Résultats du tirage au sort", mail,
|
||||
"bda@ens.fr", [member.user.email],
|
||||
fail_silently=True)
|
||||
count = len(queryset.all())
|
||||
if count == 1:
|
||||
message_bit = u"1 membre a"
|
||||
|
@ -107,9 +119,11 @@ Le Bureau des Arts
|
|||
else:
|
||||
message_bit = u"%d membres ont" % count
|
||||
plural = "s"
|
||||
self.message_user(request, u"%s été informé%s avec succès." % (message_bit, plural))
|
||||
self.message_user(request, u"%s été informé%s avec succès." %
|
||||
(message_bit, plural))
|
||||
send_attribs.short_description = u"Envoyer les résultats par mail"
|
||||
|
||||
|
||||
class AttributionAdminForm(forms.ModelForm):
|
||||
def clean(self):
|
||||
cleaned_data = super(AttributionAdminForm, self).clean()
|
||||
|
@ -117,26 +131,36 @@ class AttributionAdminForm(forms.ModelForm):
|
|||
spectacle = cleaned_data.get("spectacle")
|
||||
if participant and spectacle:
|
||||
if participant.tirage != spectacle.tirage:
|
||||
raise forms.ValidationError(u"Erreur : le participant et le spectacle n'appartiennent pas au même tirage")
|
||||
raise forms.ValidationError(
|
||||
u"Erreur : le participant et le spectacle n'appartiennent"
|
||||
u"pas au même tirage")
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class AttributionAdmin(admin.ModelAdmin):
|
||||
def paid(self, obj):
|
||||
return obj.participant.paid
|
||||
paid.short_description = 'A payé'
|
||||
paid.boolean = True
|
||||
list_display = ("id", "spectacle", "participant", "given", "paid")
|
||||
search_fields = ('spectacle__title', 'participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
|
||||
search_fields = ('spectacle__title', 'participant__user__username',
|
||||
'participant__user__first_name',
|
||||
'participant__user__last_name')
|
||||
form = AttributionAdminForm
|
||||
|
||||
import autocomplete_light
|
||||
|
||||
class ChoixSpectacleAdmin(admin.ModelAdmin):
|
||||
form = autocomplete_light.modelform_factory(ChoixSpectacle, exclude=[])
|
||||
|
||||
def tirage(self, obj):
|
||||
return obj.participant.tirage
|
||||
list_display = ("participant", "tirage", "spectacle", "priority", "double_choice")
|
||||
list_display = ("participant", "tirage", "spectacle", "priority",
|
||||
"double_choice")
|
||||
list_filter = ("double_choice", "participant__tirage")
|
||||
search_fields = ('participant__user__username', 'participant__user__first_name', 'participant__user__last_name')
|
||||
search_fields = ('participant__user__username',
|
||||
'participant__user__first_name',
|
||||
'participant__user__last_name')
|
||||
|
||||
|
||||
class SpectacleAdmin(admin.ModelAdmin):
|
||||
model = Spectacle
|
||||
|
@ -144,6 +168,7 @@ class SpectacleAdmin(admin.ModelAdmin):
|
|||
list_filter = ("location", "tirage",)
|
||||
search_fields = ("title", "location__name")
|
||||
|
||||
|
||||
class TirageAdmin(admin.ModelAdmin):
|
||||
model = Tirage
|
||||
list_display = ("title", "ouverture", "fermeture", "active")
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.db.models import Max
|
|||
|
||||
import random
|
||||
|
||||
|
||||
class Algorithm(object):
|
||||
|
||||
shows = None
|
||||
|
@ -19,7 +20,8 @@ class Algorithm(object):
|
|||
show.requests
|
||||
- on crée des tables de demandes pour chaque personne, afin de
|
||||
pouvoir modifier les rankings"""
|
||||
self.max_group = 2 * choices.aggregate(Max('priority'))['priority__max']
|
||||
self.max_group = \
|
||||
2 * choices.aggregate(Max('priority'))['priority__max']
|
||||
self.shows = []
|
||||
showdict = {}
|
||||
for show in shows:
|
||||
|
@ -65,13 +67,14 @@ class Algorithm(object):
|
|||
def __call__(self, seed):
|
||||
random.seed(seed)
|
||||
results = []
|
||||
shows = sorted(self.shows, key=lambda x: x.nrequests / x.slots, reverse=True)
|
||||
shows = sorted(self.shows, key=lambda x: x.nrequests / x.slots,
|
||||
reverse=True)
|
||||
for show in shows:
|
||||
# On regroupe tous les gens ayant le même rang
|
||||
groups = dict([(i, []) for i in range(1, self.max_group + 1)])
|
||||
for member in show.requests:
|
||||
if self.ranks[member][show] == 0:
|
||||
raise RuntimeError, (member, show.title)
|
||||
raise RuntimeError(member, show.title)
|
||||
groups[self.ranks[member][show]].append(member)
|
||||
# On passe à l'attribution
|
||||
winners = []
|
||||
|
@ -84,7 +87,8 @@ class Algorithm(object):
|
|||
if len(winners) + 1 < show.slots:
|
||||
self.appendResult(winners, member, show)
|
||||
self.appendResult(winners, member, show)
|
||||
elif not self.choices[member][show].autoquit and len(winners) < show.slots:
|
||||
elif not self.choices[member][show].autoquit and\
|
||||
len(winners) < show.slots:
|
||||
self.appendResult(winners, member, show)
|
||||
self.appendResult(losers, member, show)
|
||||
else:
|
||||
|
|
|
@ -2,8 +2,11 @@ import autocomplete_light
|
|||
|
||||
from bda.models import Participant, Spectacle
|
||||
|
||||
autocomplete_light.register(Participant, search_fields=('user__username','user__first_name','user__last_name'),
|
||||
autocomplete_light.register(
|
||||
Participant, search_fields=('user__username', 'user__first_name',
|
||||
'user__last_name'),
|
||||
autocomplete_js_attributes={'placeholder': 'participant...'})
|
||||
|
||||
autocomplete_light.register(Spectacle, search_fields=('title',),
|
||||
autocomplete_light.register(
|
||||
Spectacle, search_fields=('title', ),
|
||||
autocomplete_js_attributes={'placeholder': 'spectacle...'})
|
||||
|
|
12
bda/forms.py
12
bda/forms.py
|
@ -4,6 +4,7 @@ from django import forms
|
|||
from django.forms.models import BaseInlineFormSet
|
||||
from bda.models import Spectacle
|
||||
|
||||
|
||||
class BaseBdaFormSet(BaseInlineFormSet):
|
||||
def clean(self):
|
||||
"""Checks that no two articles have the same title."""
|
||||
|
@ -20,22 +21,27 @@ class BaseBdaFormSet(BaseInlineFormSet):
|
|||
spectacle = form.cleaned_data['spectacle']
|
||||
delete = form.cleaned_data['DELETE']
|
||||
if not delete and spectacle in spectacles:
|
||||
raise forms.ValidationError("Vous ne pouvez pas vous " + \
|
||||
"inscrire deux fois pour le même spectacle.")
|
||||
raise forms.ValidationError(
|
||||
"Vous ne pouvez pas vous inscrire deux fois pour le "
|
||||
"même spectacle.")
|
||||
spectacles.append(spectacle)
|
||||
|
||||
|
||||
class TokenForm(forms.Form):
|
||||
token = forms.CharField(widget=forms.widgets.Textarea())
|
||||
|
||||
|
||||
class SpectacleModelChoiceField(forms.ModelChoiceField):
|
||||
def label_from_instance(self, obj):
|
||||
return u"%s le %s (%s) à %.02f€" % (obj.title, obj.date_no_seconds(),
|
||||
obj.location, obj.price)
|
||||
|
||||
|
||||
class ResellForm(forms.Form):
|
||||
count = forms.ChoiceField(choices=(("1", "1"), ("2", "2"),))
|
||||
spectacle = SpectacleModelChoiceField(queryset=Spectacle.objects.none())
|
||||
|
||||
def __init__(self, participant, *args, **kwargs):
|
||||
super(ResellForm, self).__init__(*args, **kwargs)
|
||||
self.fields['spectacle'].queryset = participant.attributions.all().distinct()
|
||||
self.fields['spectacle'].queryset = participant.attributions.all().\
|
||||
distinct()
|
||||
|
|
|
@ -6,6 +6,7 @@ from django.db import models
|
|||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class Tirage(models.Model):
|
||||
title = models.CharField("Titre", max_length=300)
|
||||
ouverture = models.DateTimeField("Date et heure d'ouverture du tirage")
|
||||
|
@ -19,6 +20,7 @@ class Tirage(models.Model):
|
|||
def __unicode__(self):
|
||||
return u"%s - %s" % (self.title, self.date_no_seconds())
|
||||
|
||||
|
||||
class Salle(models.Model):
|
||||
name = models.CharField("Nom", max_length=300)
|
||||
address = models.TextField("Adresse")
|
||||
|
@ -26,6 +28,7 @@ class Salle(models.Model):
|
|||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Spectacle(models.Model):
|
||||
title = models.CharField("Titre", max_length=300)
|
||||
date = models.DateTimeField("Date & heure")
|
||||
|
@ -52,7 +55,7 @@ class Spectacle(models.Model):
|
|||
|
||||
def __unicode__(self):
|
||||
return u"%s - %s, %s, %.02f€" % (self.title, self.date_no_seconds(),
|
||||
self.location, self.price)
|
||||
self.location, self.price)
|
||||
|
||||
PAYMENT_TYPES = (
|
||||
("cash", u"Cash"),
|
||||
|
@ -61,17 +64,19 @@ PAYMENT_TYPES = (
|
|||
("autre", u"Autre"),
|
||||
)
|
||||
|
||||
|
||||
class Participant(models.Model):
|
||||
user = models.ForeignKey(User)
|
||||
choices = models.ManyToManyField(Spectacle,
|
||||
through="ChoixSpectacle",
|
||||
related_name="chosen_by")
|
||||
through="ChoixSpectacle",
|
||||
related_name="chosen_by")
|
||||
attributions = models.ManyToManyField(Spectacle,
|
||||
through="Attribution",
|
||||
related_name="attributed_to")
|
||||
through="Attribution",
|
||||
related_name="attributed_to")
|
||||
paid = models.BooleanField(u"A payé", default=False)
|
||||
paymenttype = models.CharField(u"Moyen de paiement",
|
||||
max_length=6, choices=PAYMENT_TYPES, blank=True)
|
||||
max_length=6, choices=PAYMENT_TYPES,
|
||||
blank=True)
|
||||
tirage = models.ForeignKey(Tirage)
|
||||
|
||||
def __unicode__(self):
|
||||
|
@ -83,12 +88,14 @@ DOUBLE_CHOICES = (
|
|||
("double", "2 places sinon rien"),
|
||||
)
|
||||
|
||||
|
||||
class ChoixSpectacle(models.Model):
|
||||
participant = models.ForeignKey(Participant)
|
||||
spectacle = models.ForeignKey(Spectacle, related_name="participants")
|
||||
priority = models.PositiveIntegerField("Priorité")
|
||||
double_choice = models.CharField("Nombre de places",
|
||||
default="1", choices=DOUBLE_CHOICES, max_length=10)
|
||||
default="1", choices=DOUBLE_CHOICES,
|
||||
max_length=10)
|
||||
|
||||
def get_double(self):
|
||||
return self.double_choice != "1"
|
||||
|
@ -104,6 +111,7 @@ class ChoixSpectacle(models.Model):
|
|||
verbose_name = "voeu"
|
||||
verbose_name_plural = "voeux"
|
||||
|
||||
|
||||
class Attribution(models.Model):
|
||||
participant = models.ForeignKey(Participant)
|
||||
spectacle = models.ForeignKey(Spectacle, related_name="attribues")
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
from django.conf.urls import url, patterns
|
||||
from bda.views import SpectacleListView
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'inscription/(?P<tirage_id>\d+)$',
|
||||
'bda.views.inscription',
|
||||
name='bda-tirage-inscription'),
|
||||
|
|
85
bda/views.py
85
bda/views.py
|
@ -18,7 +18,8 @@ from datetime import timedelta
|
|||
import time
|
||||
|
||||
from gestioncof.decorators import cof_required, buro_required
|
||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution, Tirage
|
||||
from bda.models import Spectacle, Participant, ChoixSpectacle, Attribution,\
|
||||
Tirage
|
||||
from bda.algorithm import Algorithm
|
||||
|
||||
from bda.forms import BaseBdaFormSet, TokenForm, ResellForm
|
||||
|
@ -59,7 +60,7 @@ def etat_places(request, tirage_id):
|
|||
spectacles_dict[spectacle["spectacle"]].slots
|
||||
total += spectacle["total"]
|
||||
return render(request, "etat-places.html",
|
||||
{"spectacles": spectacles, "total": total, 'tirage': tirage})
|
||||
{"spectacles": spectacles, "total": total, 'tirage': tirage})
|
||||
|
||||
|
||||
def _hash_queryset(queryset):
|
||||
|
@ -73,9 +74,9 @@ def _hash_queryset(queryset):
|
|||
def places(request, tirage_id):
|
||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
participant, created = Participant.objects.get_or_create(
|
||||
user=request.user, tirage=tirage)
|
||||
user=request.user, tirage=tirage)
|
||||
places = participant.attribution_set.order_by(
|
||||
"spectacle__date", "spectacle").all()
|
||||
"spectacle__date", "spectacle").all()
|
||||
total = sum([place.spectacle.price for place in places])
|
||||
filtered_places = []
|
||||
places_dict = {}
|
||||
|
@ -107,9 +108,9 @@ def places(request, tirage_id):
|
|||
def places_ics(request, tirage_id):
|
||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
participant, created = Participant.objects.get_or_create(
|
||||
user=request.user, tirage=tirage)
|
||||
user=request.user, tirage=tirage)
|
||||
places = participant.attribution_set.order_by(
|
||||
"spectacle__date", "spectacle").all()
|
||||
"spectacle__date", "spectacle").all()
|
||||
filtered_places = []
|
||||
places_dict = {}
|
||||
spectacles = []
|
||||
|
@ -133,30 +134,32 @@ def inscription(request, tirage_id):
|
|||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
if timezone.now() < tirage.ouverture:
|
||||
error_desc = "Ouverture le %s" % (
|
||||
tirage.ouverture.strftime('%d %b %Y à %H:%M'))
|
||||
tirage.ouverture.strftime('%d %b %Y à %H:%M'))
|
||||
return render(request, 'resume_inscription.html',
|
||||
{ "error_title": "Le tirage n'est pas encore ouvert !",
|
||||
"error_description": error_desc})
|
||||
{"error_title": "Le tirage n'est pas encore ouvert !",
|
||||
"error_description": error_desc})
|
||||
if timezone.now() > tirage.fermeture:
|
||||
participant, created = Participant.objects.get_or_create(
|
||||
user=request.user, tirage=tirage)
|
||||
user=request.user, tirage=tirage)
|
||||
choices = participant.choixspectacle_set.order_by("priority").all()
|
||||
return render(request, "resume_inscription.html",
|
||||
{ "error_title": "C'est fini !",
|
||||
"error_description": u"Tirage au sort dans la journée !",
|
||||
"choices": choices})
|
||||
{"error_title": "C'est fini !",
|
||||
"error_description":
|
||||
u"Tirage au sort dans la journée !",
|
||||
"choices": choices})
|
||||
|
||||
def formfield_callback(f, **kwargs):
|
||||
if f.name == "spectacle":
|
||||
kwargs['queryset'] = tirage.spectacle_set
|
||||
return f.formfield(**kwargs)
|
||||
BdaFormSet = inlineformset_factory(
|
||||
Participant,
|
||||
ChoixSpectacle,
|
||||
fields=("spectacle", "double_choice", "priority"),
|
||||
formset=BaseBdaFormSet,
|
||||
formfield_callback=formfield_callback)
|
||||
Participant,
|
||||
ChoixSpectacle,
|
||||
fields=("spectacle", "double_choice", "priority"),
|
||||
formset=BaseBdaFormSet,
|
||||
formfield_callback=formfield_callback)
|
||||
participant, created = Participant.objects.get_or_create(
|
||||
user=request.user, tirage=tirage)
|
||||
user=request.user, tirage=tirage)
|
||||
success = False
|
||||
stateerror = False
|
||||
if request.method == "POST":
|
||||
|
@ -179,12 +182,12 @@ def inscription(request, tirage_id):
|
|||
if choice.double:
|
||||
total_price += choice.spectacle.price
|
||||
return render(request, "inscription-bda.html",
|
||||
{ "formset": formset,
|
||||
"success": success,
|
||||
"total_price": total_price,
|
||||
"dbstate": dbstate,
|
||||
'tirage': tirage,
|
||||
"stateerror": stateerror})
|
||||
{"formset": formset,
|
||||
"success": success,
|
||||
"total_price": total_price,
|
||||
"dbstate": dbstate,
|
||||
'tirage': tirage,
|
||||
"stateerror": stateerror})
|
||||
|
||||
|
||||
def do_tirage(request, tirage_id):
|
||||
|
@ -198,8 +201,8 @@ def do_tirage(request, tirage_id):
|
|||
data = {}
|
||||
shows = tirage_elt.spectacle_set.select_related().all()
|
||||
members = tirage_elt.participant_set.all()
|
||||
choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt).order_by(
|
||||
'participant', 'priority').select_related().all()
|
||||
choices = ChoixSpectacle.objects.filter(spectacle__tirage=tirage_elt).\
|
||||
order_by('participant', 'priority').select_related().all()
|
||||
algo = Algorithm(shows, members, choices)
|
||||
results = algo(form.cleaned_data["token"])
|
||||
total_slots = 0
|
||||
|
@ -248,8 +251,8 @@ def do_tirage(request, tirage_id):
|
|||
# cf. issue #32
|
||||
if False:
|
||||
Attribution.objects.filter(
|
||||
spectacle__tirage=tirage_elt
|
||||
).delete()
|
||||
spectacle__tirage=tirage_elt
|
||||
).delete()
|
||||
for (show, members, _) in results:
|
||||
for (member, _, _, _) in members:
|
||||
attrib = Attribution(spectacle=show, participant=member)
|
||||
|
@ -280,19 +283,20 @@ Je souhaite revendre %s pour %s le %s (%s) à %.02f€.
|
|||
Contactez moi par email si vous êtes intéressé·e·s !
|
||||
|
||||
%s (%s)""" % (places, spectacle.title, spectacle.date_no_seconds(),
|
||||
spectacle.location, spectacle.price, request.user.get_full_name(),
|
||||
request.user.email)
|
||||
spectacle.location, spectacle.price,
|
||||
request.user.get_full_name(), request.user.email)
|
||||
send_mail("%s" % spectacle, mail,
|
||||
request.user.email, ["bda-revente@lists.ens.fr"],
|
||||
fail_silently=False)
|
||||
return render(request, "bda-success.html", {"show": spectacle, "places": places})
|
||||
return render(request, "bda-success.html",
|
||||
{"show": spectacle, "places": places})
|
||||
|
||||
|
||||
@login_required
|
||||
def revente(request, tirage_id):
|
||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
participant, created = Participant.objects.get_or_create(
|
||||
user=request.user, tirage=tirage)
|
||||
user=request.user, tirage=tirage)
|
||||
if not participant.paid:
|
||||
return render(request, "bda-notpaid.html", {})
|
||||
if request.POST:
|
||||
|
@ -301,7 +305,8 @@ def revente(request, tirage_id):
|
|||
return do_resell(request, form)
|
||||
else:
|
||||
form = ResellForm(participant)
|
||||
return render(request, "bda-revente.html", {"form": form, 'tirage': tirage})
|
||||
return render(request, "bda-revente.html",
|
||||
{"form": form, 'tirage': tirage})
|
||||
|
||||
|
||||
@buro_required
|
||||
|
@ -326,9 +331,9 @@ def spectacle(request, tirage_id, spectacle_id):
|
|||
participants[participant.id] = participant_info
|
||||
|
||||
participants_info = sorted(participants.values(),
|
||||
key=lambda part: part['lastname'])
|
||||
key=lambda part: part['lastname'])
|
||||
return render(request, "bda-participants.html",
|
||||
{"spectacle": spectacle, "participants": participants_info})
|
||||
{"spectacle": spectacle, "participants": participants_info})
|
||||
|
||||
|
||||
class SpectacleListView(ListView):
|
||||
|
@ -351,8 +356,8 @@ class SpectacleListView(ListView):
|
|||
def unpaid(request, tirage_id):
|
||||
tirage = get_object_or_404(Tirage, id=tirage_id)
|
||||
unpaid = tirage.participant_set \
|
||||
.annotate(nb_attributions=Count('attribution')) \
|
||||
.filter(paid=False, nb_attributions__gt=0).all()
|
||||
.annotate(nb_attributions=Count('attribution')) \
|
||||
.filter(paid=False, nb_attributions__gt=0).all()
|
||||
return render(request, "bda-unpaid.html", {"unpaid": unpaid})
|
||||
|
||||
|
||||
|
@ -363,5 +368,5 @@ def liste_spectacles_ics(request, tirage_id):
|
|||
for spectacle in spectacles:
|
||||
spectacle.dtend = spectacle.date + timedelta(seconds=7200)
|
||||
return render(request, "liste_spectacles.ics",
|
||||
{"spectacles": spectacles, "tirage": tirage},
|
||||
content_type="text/calendar")
|
||||
{"spectacles": spectacles, "tirage": tirage},
|
||||
content_type="text/calendar")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue