forked from DGNum/gestioCOF
Merge branch 'Aufinal/clean_code' into Kerl/clean_code_amend
This commit is contained in:
commit
847345bb63
5 changed files with 45 additions and 31 deletions
|
@ -68,9 +68,8 @@ class AnnulForm(forms.Form):
|
||||||
self.fields['attributions'].queryset = participant.attribution_set\
|
self.fields['attributions'].queryset = participant.attribution_set\
|
||||||
.filter(spectacle__date__gte=timezone.now(),
|
.filter(spectacle__date__gte=timezone.now(),
|
||||||
revente__isnull=False,
|
revente__isnull=False,
|
||||||
revente__date__gt=timezone.now()-timedelta(hours=1))\
|
revente__date__gt=timezone.now()-timedelta(hours=1),
|
||||||
.filter(Q(revente__soldTo__isnull=True) |
|
revente__soldTo__isnull=True)
|
||||||
Q(revente__soldTo=participant))
|
|
||||||
|
|
||||||
|
|
||||||
class InscriptionReventeForm(forms.Form):
|
class InscriptionReventeForm(forms.Form):
|
||||||
|
|
|
@ -2,6 +2,19 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import models, migrations
|
from django.db import models, migrations
|
||||||
|
from django.utils import timezone
|
||||||
|
from datetime import timedelta
|
||||||
|
|
||||||
|
|
||||||
|
def forwards_func(apps, schema_editor):
|
||||||
|
SpectacleRevente = apps.get_model("bda", "SpectacleRevente")
|
||||||
|
|
||||||
|
for revente in SpectacleRevente.objects.all():
|
||||||
|
is_expired = timezone.now() > revente.date_tirage()
|
||||||
|
is_direct = (revente.attribution.spectacle.date >= revente.date and
|
||||||
|
timezone.now() > revente.date + timedelta(minutes=15))
|
||||||
|
revente.shotgun = is_expired or is_direct
|
||||||
|
revente.save()
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
@ -16,4 +29,5 @@ class Migration(migrations.Migration):
|
||||||
name='shotgun',
|
name='shotgun',
|
||||||
field=models.BooleanField(default=False, verbose_name='Disponible imm\xe9diatement'),
|
field=models.BooleanField(default=False, verbose_name='Disponible imm\xe9diatement'),
|
||||||
),
|
),
|
||||||
|
migrations.RunPython(forwards_func, migrations.RunPython.noop),
|
||||||
]
|
]
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if deja_revente %}
|
{% if deja_revente %}
|
||||||
<p class="success">Des reventes existent déjà pour certains de ces spectacles ; vérifie les places disponibles sans tirage !</p>
|
<p class="success">Des reventes existent déjà pour certains de ces spectacles ; vérifie les places disponibles sans tirage !</p>
|
||||||
|
{% elif inscrit_revente %}
|
||||||
|
<p class="success">Tu as été inscrit à une revente en cours pour ce spectacle !</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form action="" class="form-horizontal" method="post">
|
<form action="" class="form-horizontal" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|
19
bda/views.py
19
bda/views.py
|
@ -287,6 +287,7 @@ def revente(request, tirage_id):
|
||||||
if not created:
|
if not created:
|
||||||
revente.seller = participant
|
revente.seller = participant
|
||||||
revente.date = timezone.now()
|
revente.date = timezone.now()
|
||||||
|
revente.soldTo = None
|
||||||
revente.notif_sent = False
|
revente.notif_sent = False
|
||||||
revente.tirage_done = False
|
revente.tirage_done = False
|
||||||
revente.shotgun = False
|
revente.shotgun = False
|
||||||
|
@ -346,6 +347,7 @@ def revente(request, tirage_id):
|
||||||
revente.soldTo = None
|
revente.soldTo = None
|
||||||
revente.notif_sent = False
|
revente.notif_sent = False
|
||||||
revente.tirage_done = False
|
revente.tirage_done = False
|
||||||
|
revente.shotgun = False
|
||||||
if revente.answered_mail:
|
if revente.answered_mail:
|
||||||
revente.answered_mail.clear()
|
revente.answered_mail.clear()
|
||||||
revente.save()
|
revente.save()
|
||||||
|
@ -366,8 +368,7 @@ def revente(request, tirage_id):
|
||||||
sold = participant.attribution_set.filter(
|
sold = participant.attribution_set.filter(
|
||||||
spectacle__date__gte=timezone.now(),
|
spectacle__date__gte=timezone.now(),
|
||||||
revente__isnull=False,
|
revente__isnull=False,
|
||||||
revente__soldTo__isnull=False).exclude(
|
revente__soldTo__isnull=False)
|
||||||
revente__soldTo=participant)
|
|
||||||
|
|
||||||
return render(request, "bda-revente.html",
|
return render(request, "bda-revente.html",
|
||||||
{'tirage': tirage, 'overdue': overdue, "sold": sold,
|
{'tirage': tirage, 'overdue': overdue, "sold": sold,
|
||||||
|
@ -396,6 +397,7 @@ def list_revente(request, tirage_id):
|
||||||
user=request.user, tirage=tirage)
|
user=request.user, tirage=tirage)
|
||||||
deja_revente = False
|
deja_revente = False
|
||||||
success = False
|
success = False
|
||||||
|
inscrit_revente = False
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = InscriptionReventeForm(tirage, request.POST)
|
form = InscriptionReventeForm(tirage, request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
@ -422,6 +424,7 @@ def list_revente(request, tirage_id):
|
||||||
if min_resell is not None:
|
if min_resell is not None:
|
||||||
min_resell.answered_mail.add(participant)
|
min_resell.answered_mail.add(participant)
|
||||||
min_resell.save()
|
min_resell.save()
|
||||||
|
inscrit_revente = True
|
||||||
success = True
|
success = True
|
||||||
else:
|
else:
|
||||||
form = InscriptionReventeForm(
|
form = InscriptionReventeForm(
|
||||||
|
@ -430,7 +433,8 @@ def list_revente(request, tirage_id):
|
||||||
|
|
||||||
return render(request, "liste-reventes.html",
|
return render(request, "liste-reventes.html",
|
||||||
{"form": form,
|
{"form": form,
|
||||||
"deja_revente": deja_revente, "success": success})
|
"deja_revente": deja_revente, "success": success,
|
||||||
|
"inscrit_revente": inscrit_revente})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -485,14 +489,11 @@ def revente_shotgun(request, tirage_id):
|
||||||
date__gte=timezone.now())
|
date__gte=timezone.now())
|
||||||
shotgun = []
|
shotgun = []
|
||||||
for spectacle in spectacles:
|
for spectacle in spectacles:
|
||||||
revente_objects = SpectacleRevente.objects.filter(
|
reventes = SpectacleRevente.objects.filter(
|
||||||
attribution__spectacle=spectacle,
|
attribution__spectacle=spectacle,
|
||||||
|
shotgun=True,
|
||||||
soldTo__isnull=True)
|
soldTo__isnull=True)
|
||||||
revente_count = 0
|
if reventes.exists():
|
||||||
for revente in revente_objects:
|
|
||||||
if revente.shotgun:
|
|
||||||
revente_count += 1
|
|
||||||
if revente_count:
|
|
||||||
shotgun.append(spectacle)
|
shotgun.append(spectacle)
|
||||||
|
|
||||||
return render(request, "bda-shotgun.html",
|
return render(request, "bda-shotgun.html",
|
||||||
|
|
|
@ -550,7 +550,6 @@ def export_members(request):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
|
||||||
def csv_export_mega(filename, qs):
|
def csv_export_mega(filename, qs):
|
||||||
response = HttpResponse(content_type='text/csv')
|
response = HttpResponse(content_type='text/csv')
|
||||||
response['Content-Disposition'] = 'attachment; filename=' + filename
|
response['Content-Disposition'] = 'attachment; filename=' + filename
|
||||||
|
@ -572,12 +571,12 @@ def csv_export_mega(filename, qs):
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def export_mega_remarksonly(request):
|
def export_mega_remarksonly(request):
|
||||||
filename = 'remarques_mega_2015.csv'
|
filename = 'remarques_mega_2016.csv'
|
||||||
response = HttpResponse(content_type='text/csv')
|
response = HttpResponse(content_type='text/csv')
|
||||||
response['Content-Disposition'] = 'attachment; filename=' + filename
|
response['Content-Disposition'] = 'attachment; filename=' + filename
|
||||||
writer = unicodecsv.writer(response)
|
writer = unicodecsv.writer(response)
|
||||||
|
|
||||||
event = Event.objects.get(title="Mega 15")
|
event = Event.objects.get(title="Mega 2016")
|
||||||
commentfield = event.commentfields.get(name="Commentaires")
|
commentfield = event.commentfields.get(name="Commentaires")
|
||||||
for val in commentfield.values.all():
|
for val in commentfield.values.all():
|
||||||
reg = val.registration
|
reg = val.registration
|
||||||
|
@ -600,42 +599,40 @@ def export_mega_bytype(request, type):
|
||||||
if type not in types:
|
if type not in types:
|
||||||
raise Http404
|
raise Http404
|
||||||
|
|
||||||
event = Event.objects.get(title="Mega 15")
|
event = Event.objects.get(title="Mega 2016")
|
||||||
type_option = event.options.get(name="Type")
|
type_option = event.options.get(name="Type")
|
||||||
participant_type = type_option.choices.get(value=types[type]).id
|
participant_type = type_option.choices.get(value=types[type]).id
|
||||||
qs = EventRegistration.objects.filter(event=event).filter(
|
qs = EventRegistration.objects.filter(event=event).filter(
|
||||||
options__id__exact=participant_type)
|
options__id__exact=participant_type)
|
||||||
return csv_export_mega(type + '_mega_2015.csv', qs)
|
return csv_export_mega(type + '_mega_2016.csv', qs)
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def export_mega_orgas(request):
|
def export_mega_orgas(request):
|
||||||
event = Event.objects.get(title="Mega 15")
|
event = Event.objects.get(title="Mega 2016")
|
||||||
type_option = event.options.get(name="Type")
|
type_option = event.options.get(name="Conscrit ou orga ?")
|
||||||
participant_type_a = type_option.choices.get(value="Conscrit étudiant").id
|
participant_type = type_option.choices.get(value="Vieux").id
|
||||||
participant_type_b = type_option.choices.get(value="Conscrit élève").id
|
|
||||||
qs = EventRegistration.objects.filter(event=event).exclude(
|
qs = EventRegistration.objects.filter(event=event).exclude(
|
||||||
options__id__in=(participant_type_a, participant_type_b))
|
options__id=participant_type)
|
||||||
return csv_export_mega('orgas_mega_15.csv', qs)
|
return csv_export_mega('orgas_mega_2016.csv', qs)
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def export_mega_participants(request):
|
def export_mega_participants(request):
|
||||||
event = Event.objects.get(title="Mega 15")
|
event = Event.objects.get(title="Mega 2016")
|
||||||
type_option = event.options.get(name="Type")
|
type_option = event.options.get(name="Conscrit ou orga ?")
|
||||||
participant_type_a = type_option.choices.get(value="Conscrit étudiant").id
|
participant_type = type_option.choices.get(value="Conscrit").id
|
||||||
participant_type_b = type_option.choices.get(value="Conscrit élève").id
|
|
||||||
qs = EventRegistration.objects.filter(event=event).filter(
|
qs = EventRegistration.objects.filter(event=event).filter(
|
||||||
options__id__in=(participant_type_a, participant_type_b))
|
options__id=participant_type)
|
||||||
return csv_export_mega('participants_mega_15.csv', qs)
|
return csv_export_mega('participants_mega_2016.csv', qs)
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
def export_mega(request):
|
def export_mega(request):
|
||||||
event = Event.objects.filter(title="Mega 15")
|
event = Event.objects.filter(title="Mega 2016")
|
||||||
qs = EventRegistration.objects.filter(event=event) \
|
qs = EventRegistration.objects.filter(event=event) \
|
||||||
.order_by("user__username")
|
.order_by("user__username")
|
||||||
return csv_export_mega('all_mega_2015.csv', qs)
|
return csv_export_mega('all_mega_2016.csv', qs)
|
||||||
|
|
||||||
|
|
||||||
@buro_required
|
@buro_required
|
||||||
|
|
Loading…
Reference in a new issue