2025-12-09 03:59:57 +05:30
|
|
|
from django.db import models
|
2026-01-28 16:52:06 +05:30
|
|
|
import uuid
|
|
|
|
|
from events.models import Event
|
|
|
|
|
from accounts.models import User
|
2025-12-09 03:59:57 +05:30
|
|
|
|
|
|
|
|
# Create your models here.
|
2026-03-15 00:29:17 +05:30
|
|
|
class TicketMeta(models.Model):
|
2026-01-28 16:52:06 +05:30
|
|
|
event = models.ForeignKey(Event, on_delete=models.CASCADE)
|
|
|
|
|
ticket_name = models.CharField(max_length=250)
|
|
|
|
|
maximum_quantity = models.IntegerField()
|
|
|
|
|
available_quantity = models.IntegerField(default=0)
|
|
|
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
|
created_date = models.DateField(auto_now_add=True)
|
|
|
|
|
updated_date = models.DateField(auto_now=True)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.ticket_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TicketType(models.Model):
|
2026-03-15 00:29:17 +05:30
|
|
|
ticket_meta = models.ForeignKey(TicketMeta, on_delete=models.CASCADE)
|
2026-01-28 16:52:06 +05:30
|
|
|
ticket_type = models.CharField(max_length=250)
|
|
|
|
|
ticket_type_description = models.TextField()
|
2026-03-15 00:29:17 +05:30
|
|
|
ticket_type_quantity = models.IntegerField()
|
|
|
|
|
|
2026-01-28 16:52:06 +05:30
|
|
|
price = models.DecimalField(max_digits=10, decimal_places=2)
|
2026-03-15 00:29:17 +05:30
|
|
|
|
2026-01-28 16:52:06 +05:30
|
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
|
created_date = models.DateField(auto_now_add=True)
|
|
|
|
|
updated_date = models.DateField(auto_now=True)
|
|
|
|
|
|
|
|
|
|
is_offer = models.BooleanField(default=False)
|
|
|
|
|
offer_percentage = models.IntegerField(default=0)
|
|
|
|
|
offer_price = models.DecimalField(max_digits=10, decimal_places=2, default=0)
|
|
|
|
|
offer_start_date = models.DateField(blank=True, null=True)
|
|
|
|
|
offer_end_date = models.DateField(blank=True, null=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.ticket_type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Cart(models.Model):
|
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
2026-03-15 00:29:17 +05:30
|
|
|
ticket_meta = models.ForeignKey(TicketMeta, on_delete=models.CASCADE)
|
2026-01-28 16:52:06 +05:30
|
|
|
ticket_type = models.ForeignKey(TicketType, on_delete=models.CASCADE)
|
|
|
|
|
quantity = models.IntegerField()
|
|
|
|
|
price = models.DecimalField(max_digits=10, decimal_places=2)
|
2026-03-15 00:29:17 +05:30
|
|
|
is_active = models.BooleanField(default=True)
|
2026-01-28 16:52:06 +05:30
|
|
|
created_date = models.DateField(auto_now_add=True)
|
|
|
|
|
updated_date = models.DateField(auto_now=True)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.user.username + " - " + self.ticket.event.name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Booking(models.Model):
|
|
|
|
|
booking_id = models.CharField(max_length=250)
|
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
2026-03-15 00:29:17 +05:30
|
|
|
ticket_meta = models.ForeignKey(TicketMeta, on_delete=models.CASCADE)
|
2026-01-28 16:52:06 +05:30
|
|
|
ticket_type = models.ForeignKey(TicketType, on_delete=models.CASCADE)
|
|
|
|
|
quantity = models.IntegerField()
|
|
|
|
|
price = models.DecimalField(max_digits=10, decimal_places=2)
|
feat: Phase 1+2 - JWT auth, dashboard metrics API, DB indexes
Phase 1 - JWT Auth Foundation:
- Replace token auth with djangorestframework-simplejwt
- POST /api/v1/admin/auth/login/ - returns access + refresh JWT
- POST /api/v1/auth/refresh/ - JWT refresh
- GET /api/v1/auth/me/ - current admin profile
- GET /api/v1/health/ - DB health check
- Add ledger app to INSTALLED_APPS
Phase 2 - Dashboard Metrics API:
- GET /api/v1/dashboard/metrics/ - revenue, partners, events, tickets
- GET /api/v1/dashboard/revenue/ - 7-day revenue vs payouts chart data
- GET /api/v1/dashboard/activity/ - last 10 platform events feed
- GET /api/v1/dashboard/actions/ - KYC queue, flagged events, pending payouts
DB Indexes (dashboard query optimisation):
- RazorpayTransaction: status, captured_at
- Partner: status, kyc_compliance_status
- Event: event_status, start_date, created_date
- Booking: created_date
- PaymentTransaction: payment_type, payment_transaction_status, payment_transaction_date
Infra:
- Add Dockerfile for eventify-backend container
- Add simplejwt to requirements.txt
- All 4 dashboard views use IsAuthenticated permission class
2026-03-24 17:46:41 +00:00
|
|
|
created_date = models.DateField(auto_now_add=True, db_index=True)
|
2026-01-28 16:52:06 +05:30
|
|
|
updated_date = models.DateField(auto_now=True)
|
|
|
|
|
|
|
|
|
|
transaction_id = models.CharField(max_length=250, blank=True, null=True)
|
|
|
|
|
|
|
|
|
|
def __save__(self):
|
|
|
|
|
if not self.booking_id:
|
|
|
|
|
self.booking_id = str(self.ticket.event.name[:3].upper()) + str(uuid.uuid4().hex[:10]).upper()
|
|
|
|
|
super().save(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
2026-03-15 00:29:17 +05:30
|
|
|
return self.booking_id
|
|
|
|
|
|
|
|
|
|
class Ticket(models.Model):
|
|
|
|
|
booking = models.ForeignKey(Booking, on_delete=models.CASCADE)
|
|
|
|
|
ticket_id = models.CharField(max_length=250)
|
|
|
|
|
is_checked_in = models.BooleanField(default=False)
|
|
|
|
|
checked_in_date_time = models.DateTimeField(blank=True, null=True)
|
|
|
|
|
|
|
|
|
|
def __save__(self):
|
|
|
|
|
if not self.ticket_id:
|
|
|
|
|
self.ticket_id = str(self.booking.ticket_meta.event.name[:3].upper()) + str(uuid.uuid4().hex[:10]).upper()
|
|
|
|
|
super().save(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return self.ticket_id
|
|
|
|
|
|
|
|
|
|
def check_in(self, ticket_id):
|
|
|
|
|
if self.ticket_id == ticket_id:
|
|
|
|
|
self.is_checked_in = True
|
|
|
|
|
self.checked_in_date_time = datetime.now()
|
|
|
|
|
self.save()
|
|
|
|
|
return True
|
|
|
|
|
return False
|