Anna Sirota
ba96ba9937
The following has changed: * Products have their own /tickets/book/../ URLs * Products only show up in product table if featured * Products should link to Stripe prices instead of payment links * Products have `taxes` field, which is a list of tax rules: * this field is used to display VAT lines in invoices * Tickets store Stripe checkout session data (to too many API calls) * Ticket page shows Stripe's product image, if available * Stripe webhook endpoint created, expecting the following events: * `checkout.session.completed` * `checkout.session.async_payment_succeeded` * `payment_intent.requires_action` * `charge.refunded` * Full refund will un-claim everyone who claimed the affected ticket * Invoice PDFs: * with Stripe's bank transfer instructions * refund date and amount * CSV report supports Stripe-paid tickets * CSV has new columns: VAT and refund
29 lines
898 B
Python
29 lines
898 B
Python
from typing import Set
|
|
|
|
from django.contrib.auth import get_user_model
|
|
from django.db.models.signals import m2m_changed
|
|
from django.dispatch import receiver
|
|
|
|
import tickets.models
|
|
import tickets.tasks as tasks
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
@receiver(m2m_changed, sender=tickets.models.Ticket.attendees.through)
|
|
def _on_ticket_claimed(
|
|
sender: object, instance: tickets.models.Ticket, pk_set: Set[int], action: str, **kwargs: object
|
|
) -> None:
|
|
if kwargs.get('raw', False):
|
|
return
|
|
|
|
if action != 'post_add':
|
|
return
|
|
|
|
# Send out additional emails to added attendees if ticket is paid or free
|
|
if instance.is_paid or instance.is_free:
|
|
for user_id in pk_set:
|
|
tasks.send_mail_confirm_tickets(ticket_id=instance.pk, user_id=user_id)
|
|
# Also send out general info
|
|
tasks.send_mail_general_info(ticket_id=instance.pk, user_id=user_id)
|