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
73 lines
2.7 KiB
Python
73 lines
2.7 KiB
Python
from random import choices
|
|
from django.db import models
|
|
from master_data.models import EventType
|
|
from partner.models import Partner
|
|
|
|
|
|
class Event(models.Model):
|
|
created_date = models.DateField(auto_now_add=True, db_index=True)
|
|
name = models.CharField(max_length=200)
|
|
description = models.TextField()
|
|
start_date = models.DateField(blank=True, null=True, db_index=True)
|
|
end_date = models.DateField(blank=True, null=True)
|
|
start_time = models.TimeField(blank=True, null=True)
|
|
end_time = models.TimeField(blank=True, null=True)
|
|
all_year_event = models.BooleanField(default=False)
|
|
|
|
latitude = models.DecimalField(max_digits=9, decimal_places=6)
|
|
longitude = models.DecimalField(max_digits=9, decimal_places=6)
|
|
pincode = models.CharField(max_length=10)
|
|
district = models.CharField(max_length=100)
|
|
state = models.CharField(max_length=100)
|
|
place = models.CharField(max_length=200)
|
|
|
|
is_bookable = models.BooleanField(default=False)
|
|
include_gst = models.BooleanField(default=False)
|
|
gst_percentage_1 = models.IntegerField(default=0)
|
|
gst_percentage_2 = models.IntegerField(default=0)
|
|
|
|
is_eventify_event = models.BooleanField(default=True)
|
|
outside_event_url = models.URLField(default='NA')
|
|
|
|
is_partner_event = models.BooleanField(default=False)
|
|
partner = models.ForeignKey(Partner, on_delete=models.CASCADE, blank=True, null=True)
|
|
|
|
event_type = models.ForeignKey(EventType, on_delete=models.CASCADE)
|
|
event_status = models.CharField(max_length=250, choices=[
|
|
('created', 'Created'),
|
|
('cancelled', 'Cancelled'),
|
|
('pending', 'Pending'),
|
|
('completed', 'Completed'),
|
|
('postponed', 'Postponed'),
|
|
('published', 'Published'),
|
|
('live', 'Live'),
|
|
('flagged', 'Flagged'),
|
|
], default='pending', db_index=True)
|
|
cancelled_reason = models.TextField(default='NA')
|
|
|
|
title = models.CharField(max_length=250, blank=True)
|
|
important_information = models.TextField(blank=True)
|
|
venue_name = models.CharField(max_length=250, blank=True)
|
|
|
|
source = models.CharField(max_length=250, blank=True, choices=[
|
|
('official', 'Official'),
|
|
('community', 'Community'),
|
|
])
|
|
|
|
is_featured = models.BooleanField(default=False, help_text='Show this event in the featured section')
|
|
is_top_event = models.BooleanField(default=False, help_text='Show this event in the Top Events section')
|
|
|
|
def __str__(self):
|
|
return f"{self.name} ({self.start_date})"
|
|
|
|
|
|
class EventImages(models.Model):
|
|
event = models.ForeignKey(Event, on_delete=models.CASCADE)
|
|
is_primary = models.BooleanField(default=False)
|
|
event_image = models.ImageField(upload_to='event_images')
|
|
|
|
def __str__(self):
|
|
return f"{self.event_image}"
|
|
|
|
|