validate ticket before create mail
This commit is contained in:
parent
d56366ca21
commit
a6eff19fa2
|
|
@ -266,6 +266,7 @@ class ReservationValidator(serializers.Serializer):
|
|||
|
||||
if new_paiement_stripe.is_valid():
|
||||
reservation.paiement = new_paiement_stripe.paiement_stripe_db
|
||||
reservation.status = Reservation.UNPAID
|
||||
reservation.save()
|
||||
print(new_paiement_stripe.checkout_session.stripe_id)
|
||||
# return new_paiement_stripe.redirect_to_stripe()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
<li>5:10pm</li>
|
||||
<li>Dec 15, 2018</li>
|
||||
<li>Coach</li>
|
||||
<li>1257797706706</li>
|
||||
<li>PROUTPROUT</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
|
@ -49,5 +49,6 @@
|
|||
<li>5:10pm</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
from datetime import datetime
|
||||
|
||||
from django.http import Http404
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
from django.utils import timezone
|
||||
from django_weasyprint import WeasyTemplateView
|
||||
|
|
@ -149,13 +144,13 @@ class TicketPdf(WeasyTemplateView):
|
|||
|
||||
def get_context_data(self, pk_uuid, **kwargs):
|
||||
logger.info(f"{timezone.now()} création de pdf demandé. uuid : {pk_uuid}")
|
||||
|
||||
self.config = Configuration.get_solo()
|
||||
ticket: Ticket = get_object_or_404(Ticket, uuid=pk_uuid)
|
||||
kwargs['ticket'] = ticket
|
||||
kwargs['config'] = self.config
|
||||
|
||||
self.nom_prenom = f"{ticket.first_name.upper()}_{ticket.last_name.capitalize()}"
|
||||
|
||||
return kwargs
|
||||
|
||||
def get_pdf_filename(self, **kwargs):
|
||||
|
|
|
|||
|
|
@ -325,15 +325,16 @@ class Reservation(models.Model):
|
|||
on_delete=models.PROTECT,
|
||||
related_name="reservation")
|
||||
|
||||
CANCELED, UNPAID, PAID, VALID, = 'C', 'N', 'P', 'V'
|
||||
CANCELED, CREATED, UNPAID, PAID, VALID, = 'C', 'R', 'N', 'P', 'V'
|
||||
TYPE_CHOICES = [
|
||||
(CANCELED, _('Annulée')),
|
||||
(CREATED, _('Crée')),
|
||||
(UNPAID, _('Non payée')),
|
||||
(PAID, _('Payée')),
|
||||
(VALID, _('Validée')),
|
||||
]
|
||||
|
||||
status = models.CharField(max_length=3, choices=TYPE_CHOICES, default=UNPAID,
|
||||
status = models.CharField(max_length=3, choices=TYPE_CHOICES, default=CREATED,
|
||||
verbose_name=_("Status de la réservation"))
|
||||
|
||||
mail_send = models.BooleanField(default=False)
|
||||
|
|
|
|||
|
|
@ -14,14 +14,10 @@ logger = logging.getLogger(__name__)
|
|||
logger.info(f'import basebillet.signals')
|
||||
|
||||
|
||||
@receiver(post_save, sender=Reservation)
|
||||
def trigger_reservation(sender, instance: Reservation, created, **kwargs):
|
||||
if instance.status == Reservation.PAID:
|
||||
if instance.tickets:
|
||||
for ticket in instance.tickets.filter(status=Ticket.NOT_ACTIV):
|
||||
logger.info(f'trigger_reservation, activation des tickets {ticket} NOT_SCANNED')
|
||||
ticket.status = Ticket.NOT_SCANNED
|
||||
ticket.save()
|
||||
# @receiver(post_save, sender=Reservation)
|
||||
# def trigger_reservation(sender, instance: Reservation, created, **kwargs):
|
||||
# if instance.status == Reservation.PAID:
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -132,8 +128,15 @@ def valide_stripe_paiement(old_instance, new_instance):
|
|||
|
||||
######################## TRIGGER RESERVATION ########################
|
||||
|
||||
|
||||
def send_billet_to_mail(old_instance, new_instance):
|
||||
# On active les tickets
|
||||
if new_instance.tickets:
|
||||
for ticket in new_instance.tickets.filter(status=Ticket.NOT_ACTIV):
|
||||
logger.info(f'trigger_reservation, activation des tickets {ticket} NOT_SCANNED')
|
||||
ticket.status = Ticket.NOT_SCANNED
|
||||
ticket.save()
|
||||
|
||||
# On vérifier qu'on a pas déja envoyé le mail
|
||||
if not new_instance.mail_send :
|
||||
logger.info(f" TRIGGER RESERVATION send_billet_to_mail {old_instance.status} to {new_instance.status}")
|
||||
new_instance : Reservation
|
||||
|
|
@ -173,7 +176,7 @@ def error_regression(old_instance, new_instance):
|
|||
TRANSITIONS = {
|
||||
'RESERVATION': {
|
||||
Reservation.UNPAID: {
|
||||
Reservation.PAID: send_billet_to_mail
|
||||
Reservation.PAID: send_billet_to_mail,
|
||||
},
|
||||
Reservation.PAID: {
|
||||
Reservation.VALID: send_billet_to_mail,
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ li {
|
|||
}
|
||||
#informations li:last-of-type {
|
||||
font-family: Libre Barcode, cursive;
|
||||
color: black;
|
||||
font-size: 25pt;
|
||||
margin-left: auto;
|
||||
padding-right: 1cm;
|
||||
|
|
|
|||
Loading…
Reference in New Issue