mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 06:51:12 -05:00
feat: Implement Phase 1.5 entity models (Park, Ride, Company, RideModel, Photo)
- Created Company model with location tracking, date precision, and CloudFlare Images - Created RideModel model for manufacturer's ride models with specifications - Created Park model with location, dates, operator, and cached statistics - Created Ride model with comprehensive stats, manufacturer, and park relationship - Created Photo model with CloudFlare Images integration and generic relations - Added lifecycle hooks for auto-slug generation and count updates - Created migrations and applied to database - Registered all models in Django admin with detailed fieldsets - Fixed admin autocomplete_fields to use raw_id_fields where needed - All models inherit from VersionedModel for automatic version tracking - Models include date precision tracking for opening/closing dates - Added comprehensive indexes for query performance Phase 1.5 complete - Entity models ready for API development
This commit is contained in:
253
django/apps/media/migrations/0001_initial.py
Normal file
253
django/apps/media/migrations/0001_initial.py
Normal file
@@ -0,0 +1,253 @@
|
||||
# Generated by Django 4.2.8 on 2025-11-08 16:41
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
import django_lifecycle.mixins
|
||||
import model_utils.fields
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
("contenttypes", "0002_remove_content_type_name"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Photo",
|
||||
fields=[
|
||||
(
|
||||
"created",
|
||||
model_utils.fields.AutoCreatedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="created",
|
||||
),
|
||||
),
|
||||
(
|
||||
"modified",
|
||||
model_utils.fields.AutoLastModifiedField(
|
||||
default=django.utils.timezone.now,
|
||||
editable=False,
|
||||
verbose_name="modified",
|
||||
),
|
||||
),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
),
|
||||
),
|
||||
(
|
||||
"cloudflare_image_id",
|
||||
models.CharField(
|
||||
db_index=True,
|
||||
help_text="Unique CloudFlare image identifier",
|
||||
max_length=255,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"cloudflare_url",
|
||||
models.URLField(help_text="CloudFlare CDN URL for the image"),
|
||||
),
|
||||
(
|
||||
"cloudflare_thumbnail_url",
|
||||
models.URLField(
|
||||
blank=True,
|
||||
help_text="CloudFlare thumbnail URL (if different from main URL)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"title",
|
||||
models.CharField(
|
||||
blank=True, help_text="Photo title or caption", max_length=255
|
||||
),
|
||||
),
|
||||
(
|
||||
"description",
|
||||
models.TextField(
|
||||
blank=True, help_text="Photo description or details"
|
||||
),
|
||||
),
|
||||
(
|
||||
"credit",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
help_text="Photo credit/photographer name",
|
||||
max_length=255,
|
||||
),
|
||||
),
|
||||
(
|
||||
"photo_type",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("main", "Main Photo"),
|
||||
("gallery", "Gallery Photo"),
|
||||
("banner", "Banner Image"),
|
||||
("logo", "Logo"),
|
||||
("thumbnail", "Thumbnail"),
|
||||
("other", "Other"),
|
||||
],
|
||||
db_index=True,
|
||||
default="gallery",
|
||||
help_text="Type of photo",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"object_id",
|
||||
models.UUIDField(
|
||||
db_index=True,
|
||||
help_text="ID of the entity this photo belongs to",
|
||||
),
|
||||
),
|
||||
(
|
||||
"moderation_status",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("pending", "Pending Review"),
|
||||
("approved", "Approved"),
|
||||
("rejected", "Rejected"),
|
||||
("flagged", "Flagged"),
|
||||
],
|
||||
db_index=True,
|
||||
default="pending",
|
||||
help_text="Moderation status",
|
||||
max_length=50,
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_approved",
|
||||
models.BooleanField(
|
||||
db_index=True,
|
||||
default=False,
|
||||
help_text="Quick filter for approved photos",
|
||||
),
|
||||
),
|
||||
(
|
||||
"moderated_at",
|
||||
models.DateTimeField(
|
||||
blank=True, help_text="When the photo was moderated", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"moderation_notes",
|
||||
models.TextField(blank=True, help_text="Notes from moderator"),
|
||||
),
|
||||
(
|
||||
"width",
|
||||
models.IntegerField(
|
||||
blank=True, help_text="Image width in pixels", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"height",
|
||||
models.IntegerField(
|
||||
blank=True, help_text="Image height in pixels", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"file_size",
|
||||
models.IntegerField(
|
||||
blank=True, help_text="File size in bytes", null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"display_order",
|
||||
models.IntegerField(
|
||||
db_index=True,
|
||||
default=0,
|
||||
help_text="Order for displaying in galleries (lower numbers first)",
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_featured",
|
||||
models.BooleanField(
|
||||
db_index=True,
|
||||
default=False,
|
||||
help_text="Is this a featured photo?",
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_public",
|
||||
models.BooleanField(
|
||||
db_index=True,
|
||||
default=True,
|
||||
help_text="Is this photo publicly visible?",
|
||||
),
|
||||
),
|
||||
(
|
||||
"content_type",
|
||||
models.ForeignKey(
|
||||
help_text="Type of entity this photo belongs to",
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
to="contenttypes.contenttype",
|
||||
),
|
||||
),
|
||||
(
|
||||
"moderated_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="Moderator who approved/rejected this photo",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="moderated_photos",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
(
|
||||
"uploaded_by",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
help_text="User who uploaded this photo",
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="uploaded_photos",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Photo",
|
||||
"verbose_name_plural": "Photos",
|
||||
"ordering": ["display_order", "-created"],
|
||||
"indexes": [
|
||||
models.Index(
|
||||
fields=["content_type", "object_id"],
|
||||
name="media_photo_content_0187f5_idx",
|
||||
),
|
||||
models.Index(
|
||||
fields=["cloudflare_image_id"],
|
||||
name="media_photo_cloudfl_63ac12_idx",
|
||||
),
|
||||
models.Index(
|
||||
fields=["moderation_status"],
|
||||
name="media_photo_moderat_2033b1_idx",
|
||||
),
|
||||
models.Index(
|
||||
fields=["is_approved"], name="media_photo_is_appr_13ab34_idx"
|
||||
),
|
||||
models.Index(
|
||||
fields=["uploaded_by"], name="media_photo_uploade_220d3a_idx"
|
||||
),
|
||||
models.Index(
|
||||
fields=["photo_type"], name="media_photo_photo_t_b387e7_idx"
|
||||
),
|
||||
models.Index(
|
||||
fields=["display_order"], name="media_photo_display_04e358_idx"
|
||||
),
|
||||
],
|
||||
},
|
||||
bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user