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