Merge branch 'Aufinal/fix_reinit_past' into 'master'

Aufinal/fix reinit past

Rajoute quelques vérifications de date lors d'une réinitialisation

See merge request !110
This commit is contained in:
Martin Pepin 2016-11-13 12:45:54 +01:00
commit b60365ddd6
2 changed files with 10 additions and 8 deletions

View file

@ -257,7 +257,8 @@ class SpectacleReventeAdmin(admin.ModelAdmin):
Réinitialise les reventes.
"""
count = queryset.count()
for revente in queryset.all():
for revente in queryset.filter(
attribution__spectacle__date__gte=timezone.now()):
revente.date = timezone.now() - timedelta(hours=1)
revente.soldTo = None
revente.notif_sent = False

View file

@ -329,13 +329,14 @@ def revente(request, tirage_id):
id=revente_id)
if rev.exists():
revente = rev.get()
revente.date = timezone.now() - timedelta(hours=1)
revente.soldTo = None
revente.notif_sent = False
revente.tirage_done = False
if revente.answered_mail:
revente.answered_mail.clear()
revente.save()
if revente.attribution.spectacle.date > timezone.now():
revente.date = timezone.now() - timedelta(hours=1)
revente.soldTo = None
revente.notif_sent = False
revente.tirage_done = False
if revente.answered_mail:
revente.answered_mail.clear()
revente.save()
else:
resellform = ResellForm(participant, prefix='resell')