Booking lifecycle notifications and status updates
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
("bookings", "0001_initial"),
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Notification",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("phone_number", models.CharField(blank=True, max_length=20)),
|
||||
(
|
||||
"channel",
|
||||
models.CharField(
|
||||
choices=[("sms", "SMS"), ("whatsapp", "WhatsApp")],
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"event",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("booking_created", "Booking Created"),
|
||||
("booking_confirmed", "Booking Confirmed"),
|
||||
("booking_cancelled", "Booking Cancelled"),
|
||||
],
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("pending", "Pending"),
|
||||
("sent", "Sent"),
|
||||
("failed", "Failed"),
|
||||
("skipped", "Skipped"),
|
||||
],
|
||||
default="pending",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
("provider", models.CharField(blank=True, max_length=50)),
|
||||
("message", models.TextField(blank=True)),
|
||||
("provider_payload", models.JSONField(blank=True, default=dict)),
|
||||
("error_message", models.TextField(blank=True)),
|
||||
("sent_at", models.DateTimeField(blank=True, null=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
(
|
||||
"booking",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.deletion.CASCADE,
|
||||
related_name="notifications",
|
||||
to="bookings.booking",
|
||||
),
|
||||
),
|
||||
(
|
||||
"recipient",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.deletion.SET_NULL,
|
||||
related_name="notifications",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name="notification",
|
||||
constraint=models.UniqueConstraint(
|
||||
fields=("booking", "recipient", "event", "channel"),
|
||||
name="uniq_notification_booking_event",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user