feat: Core models implementation - Phase 1 complete

Settings Configuration:
- Split settings into base.py, local.py, production.py
- Configured all 60+ installed packages
- Set up PostgreSQL, Redis, Celery, Channels
- Configured caching, sessions, logging
- Added security settings for production

Core Models (apps/core/models.py):
- BaseModel: UUID primary key + timestamps + lifecycle hooks
- VersionedModel: Automatic version tracking with DirtyFieldsMixin
- Country, Subdivision, Locality: Location reference data
- DatePrecisionMixin: Track date precision (year/month/day)
- SoftDeleteMixin: Soft-delete functionality
- ActiveManager & AllObjectsManager: Query managers

User Models (apps/users/models.py):
- Custom User model with UUID, email-based auth
- OAuth support (Google, Discord)
- MFA support fields
- Ban/unban functionality
- UserRole: Role-based permissions (user/moderator/admin)
- UserProfile: Extended user info and preferences

App Structure:
- Created 7 Django apps with proper configs
- Set up migrations for core and users apps
- All migrations applied successfully to SQLite

Testing:
- Django check passes with only 1 warning (static dir)
- Database migrations successful
- Ready for entity models (Park, Ride, Company)

Next: Implement entity models for parks, rides, companies
This commit is contained in:
pacnpal
2025-11-08 11:35:50 -05:00
parent 5b8679237a
commit 543d7bc9dc
63 changed files with 1625 additions and 123 deletions

View File

@@ -0,0 +1,194 @@
# Generated by Django 4.2.8 on 2025-11-08 16:35
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 = []
operations = [
migrations.CreateModel(
name="Country",
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,
),
),
("name", models.CharField(max_length=255, unique=True)),
(
"code",
models.CharField(
help_text="ISO 3166-1 alpha-2 country code",
max_length=2,
unique=True,
),
),
(
"code3",
models.CharField(
blank=True,
help_text="ISO 3166-1 alpha-3 country code",
max_length=3,
),
),
],
options={
"verbose_name_plural": "countries",
"db_table": "countries",
"ordering": ["name"],
},
bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
),
migrations.CreateModel(
name="Subdivision",
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,
),
),
("name", models.CharField(max_length=255)),
(
"code",
models.CharField(
help_text="ISO 3166-2 subdivision code (without country prefix)",
max_length=10,
),
),
(
"subdivision_type",
models.CharField(
blank=True,
help_text="Type of subdivision (state, province, region, etc.)",
max_length=50,
),
),
(
"country",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="subdivisions",
to="core.country",
),
),
],
options={
"db_table": "subdivisions",
"ordering": ["country", "name"],
"unique_together": {("country", "code")},
},
bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
),
migrations.CreateModel(
name="Locality",
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,
),
),
("name", models.CharField(max_length=255)),
(
"latitude",
models.DecimalField(
blank=True, decimal_places=6, max_digits=9, null=True
),
),
(
"longitude",
models.DecimalField(
blank=True, decimal_places=6, max_digits=9, null=True
),
),
(
"subdivision",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="localities",
to="core.subdivision",
),
),
],
options={
"verbose_name_plural": "localities",
"db_table": "localities",
"ordering": ["subdivision", "name"],
"indexes": [
models.Index(
fields=["subdivision", "name"],
name="localities_subdivi_675d5a_idx",
)
],
},
bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
),
]

View File