diff --git a/bda/forms.py b/bda/forms.py index fe20e565..352914e4 100644 --- a/bda/forms.py +++ b/bda/forms.py @@ -68,9 +68,8 @@ class AnnulForm(forms.Form): self.fields['attributions'].queryset = participant.attribution_set\ .filter(spectacle__date__gte=timezone.now(), revente__isnull=False, - revente__date__gt=timezone.now()-timedelta(hours=1))\ - .filter(Q(revente__soldTo__isnull=True) | - Q(revente__soldTo=participant)) + revente__date__gt=timezone.now()-timedelta(hours=1), + revente__soldTo__isnull=True) class InscriptionReventeForm(forms.Form): diff --git a/bda/migrations/0010_spectaclerevente_shotgun.py b/bda/migrations/0010_spectaclerevente_shotgun.py index a4bf2abc..35b4da8a 100644 --- a/bda/migrations/0010_spectaclerevente_shotgun.py +++ b/bda/migrations/0010_spectaclerevente_shotgun.py @@ -2,6 +2,19 @@ from __future__ import unicode_literals 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): @@ -16,4 +29,5 @@ class Migration(migrations.Migration): name='shotgun', field=models.BooleanField(default=False, verbose_name='Disponible imm\xe9diatement'), ), + migrations.RunPython(forwards_func, migrations.RunPython.noop), ] diff --git a/bda/templates/liste-reventes.html b/bda/templates/liste-reventes.html index d08d4010..c0bf8ff0 100644 --- a/bda/templates/liste-reventes.html +++ b/bda/templates/liste-reventes.html @@ -8,7 +8,10 @@ {% endif %} {% if deja_revente %}
Des reventes existent déjà pour certains de ces spectacles ; vérifie les places disponibles sans tirage !
+ {% elif inscrit_revente %} +Tu as été inscrit à une revente en cours pour ce spectacle !
{% endif %} +