Files
eventify_backend/events/models.py
Ubuntu aaaab190da feat: add is_featured/is_top_event fields and API endpoints
- Event model: added is_featured, is_top_event BooleanFields
- Migration 0007 applied to DB
- EventForm: checkboxes for both new fields
- EventAdmin: list_display, list_editable, list_filter for both flags
- FeaturedEventsAPI: POST /api/events/featured-events/ -> is_featured=True events
- TopEventsAPI: POST /api/events/top-events/ -> is_top_event=True events
2026-03-24 14:09:43 +00:00

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)
name = models.CharField(max_length=200)
description = models.TextField()
start_date = models.DateField(blank=True, null=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')
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}"