Small code QoL improvements

This commit is contained in:
Ludovic Stephan 2017-10-23 18:59:30 +02:00
parent e74dbb11f1
commit 919bcd197d
2 changed files with 12 additions and 8 deletions

View file

@ -252,6 +252,16 @@ class SpectacleRevente(models.Model):
class Meta: class Meta:
verbose_name = "Revente" verbose_name = "Revente"
def reset(self):
"""Réinitialise la revente pour permettre une remise sur le marché"""
self.seller = self.attribution.participant
self.date = timezone.now()
self.answered_mail.clear()
self.soldTo = None
self.notif_sent = False
self.tirage_done = False
self.shotgun = False
def send_notif(self): def send_notif(self):
""" """
Envoie une notification pour indiquer la mise en vente d'une place sur Envoie une notification pour indiquer la mise en vente d'une place sur

View file

@ -375,13 +375,7 @@ def revente_manage(request, tirage_id):
attribution=attribution, attribution=attribution,
defaults={'seller': participant}) defaults={'seller': participant})
if not created: if not created:
revente.seller = participant revente.reset()
revente.date = timezone.now()
revente.wanted = Participant.objects.none()
revente.soldTo = None
revente.notif_sent = False
revente.tirage_done = False
revente.shotgun = False
context = { context = {
'vendeur': participant.user, 'vendeur': participant.user,
'show': attribution.spectacle, 'show': attribution.spectacle,
@ -495,7 +489,7 @@ def revente_confirm(request, revente_id):
revente = get_object_or_404(SpectacleRevente, id=revente_id) revente = get_object_or_404(SpectacleRevente, id=revente_id)
participant, _ = Participant.objects.get_or_create( participant, _ = Participant.objects.get_or_create(
user=request.user, tirage=revente.attribution.spectacle.tirage) user=request.user, tirage=revente.attribution.spectacle.tirage)
if (timezone.now() < revente.date + timedelta(hours=1)) or revente.shotgun: if not revente.notif_sent or revente.shotgun:
return render(request, "bda/revente/wrongtime.html", return render(request, "bda/revente/wrongtime.html",
{"revente": revente}) {"revente": revente})