Files
kennethreitz 338a1e230b Add all models, README, and initial migrations
Core: User (AbstractUser + email required), Camera, Lens, Image, ExifData.
Gallery: Collection and CollectionImage.
Groups: Group, GroupMembership, GroupImage.
All models use UUID primary keys with created_at/updated_at timestamps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 19:07:37 -04:00

405 lines
15 KiB
Python

# Generated by Django 6.0.4 on 2026-04-07 23:07
import django.contrib.auth.models
import django.contrib.auth.validators
import django.db.models.deletion
import django.utils.timezone
import uuid
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("auth", "0012_alter_user_first_name_max_length"),
]
operations = [
migrations.CreateModel(
name="User",
fields=[
("password", models.CharField(max_length=128, verbose_name="password")),
(
"last_login",
models.DateTimeField(
blank=True, null=True, verbose_name="last login"
),
),
(
"is_superuser",
models.BooleanField(
default=False,
help_text="Designates that this user has all permissions without explicitly assigning them.",
verbose_name="superuser status",
),
),
(
"username",
models.CharField(
error_messages={
"unique": "A user with that username already exists."
},
help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
max_length=150,
unique=True,
validators=[
django.contrib.auth.validators.UnicodeUsernameValidator()
],
verbose_name="username",
),
),
(
"first_name",
models.CharField(
blank=True, max_length=150, verbose_name="first name"
),
),
(
"last_name",
models.CharField(
blank=True, max_length=150, verbose_name="last name"
),
),
(
"is_staff",
models.BooleanField(
default=False,
help_text="Designates whether the user can log into this admin site.",
verbose_name="staff status",
),
),
(
"is_active",
models.BooleanField(
default=True,
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
verbose_name="active",
),
),
(
"date_joined",
models.DateTimeField(
default=django.utils.timezone.now, verbose_name="date joined"
),
),
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("bio", models.TextField(blank=True)),
("avatar", models.ImageField(blank=True, upload_to="avatars/")),
("website", models.URLField(blank=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"email",
models.EmailField(
max_length=254, unique=True, verbose_name="email address"
),
),
(
"groups",
models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.group",
verbose_name="groups",
),
),
(
"user_permissions",
models.ManyToManyField(
blank=True,
help_text="Specific permissions for this user.",
related_name="user_set",
related_query_name="user",
to="auth.permission",
verbose_name="user permissions",
),
),
],
options={
"ordering": ["-created_at"],
},
managers=[
("objects", django.contrib.auth.models.UserManager()),
],
),
migrations.CreateModel(
name="Camera",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("manufacturer", models.CharField(db_index=True, max_length=255)),
("model", models.CharField(max_length=255)),
("slug", models.SlugField(max_length=255, unique=True)),
("display_name", models.CharField(max_length=512)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"ordering": ["manufacturer", "model"],
"unique_together": {("manufacturer", "model")},
},
),
migrations.CreateModel(
name="Image",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("title", models.CharField(blank=True, max_length=255)),
("description", models.TextField(blank=True)),
("slug", models.SlugField(max_length=255)),
("original", models.ImageField(upload_to="originals/%Y/%m/")),
(
"thumbnail_small",
models.ImageField(blank=True, upload_to="thumbs/small/"),
),
(
"thumbnail_medium",
models.ImageField(blank=True, upload_to="thumbs/medium/"),
),
(
"thumbnail_large",
models.ImageField(blank=True, upload_to="thumbs/large/"),
),
(
"visibility",
models.CharField(
choices=[
("public", "Public"),
("private", "Private"),
("unlisted", "Unlisted"),
],
default="public",
max_length=10,
),
),
("view_count", models.PositiveIntegerField(default=0)),
("is_processing", models.BooleanField(default=True)),
("upload_date", models.DateTimeField(auto_now_add=True, db_index=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="images",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"ordering": ["-upload_date"],
},
),
migrations.CreateModel(
name="Lens",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
("manufacturer", models.CharField(db_index=True, max_length=255)),
("model", models.CharField(max_length=255)),
("slug", models.SlugField(max_length=255, unique=True)),
("display_name", models.CharField(max_length=512)),
(
"focal_length_min",
models.PositiveIntegerField(
blank=True, help_text="Minimum focal length in mm", null=True
),
),
(
"focal_length_max",
models.PositiveIntegerField(
blank=True,
help_text="Maximum focal length in mm (same as min for primes)",
null=True,
),
),
(
"max_aperture",
models.DecimalField(
blank=True, decimal_places=1, max_digits=4, null=True
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name_plural": "lenses",
"ordering": ["manufacturer", "model"],
"unique_together": {("manufacturer", "model")},
},
),
migrations.CreateModel(
name="ExifData",
fields=[
(
"id",
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
),
),
(
"raw_data",
models.JSONField(
default=dict,
help_text="Complete raw EXIF blob — never discard this",
),
),
(
"focal_length",
models.DecimalField(
blank=True,
decimal_places=1,
help_text="Focal length in mm",
max_digits=7,
null=True,
),
),
(
"aperture",
models.DecimalField(
blank=True,
decimal_places=1,
help_text="f-number",
max_digits=4,
null=True,
),
),
(
"shutter_speed",
models.CharField(
blank=True, help_text='e.g. 1/250, 2.5"', max_length=20
),
),
("iso", models.PositiveIntegerField(blank=True, null=True)),
(
"date_taken",
models.DateTimeField(blank=True, db_index=True, null=True),
),
(
"gps_latitude",
models.DecimalField(
blank=True, decimal_places=6, max_digits=9, null=True
),
),
(
"gps_longitude",
models.DecimalField(
blank=True, decimal_places=6, max_digits=9, null=True
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"camera",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="images",
to="core.camera",
),
),
(
"image",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE,
related_name="exif",
to="core.image",
),
),
(
"lens",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="images",
to="core.lens",
),
),
],
options={
"verbose_name": "EXIF data",
"verbose_name_plural": "EXIF data",
},
),
migrations.AddIndex(
model_name="image",
index=models.Index(
fields=["user", "upload_date"], name="core_image_user_id_38dfed_idx"
),
),
migrations.AddIndex(
model_name="image",
index=models.Index(
fields=["visibility", "upload_date"],
name="core_image_visibil_6df2a8_idx",
),
),
migrations.AddIndex(
model_name="exifdata",
index=models.Index(
fields=["camera", "date_taken"], name="core_exifda_camera__a7be99_idx"
),
),
migrations.AddIndex(
model_name="exifdata",
index=models.Index(
fields=["lens", "date_taken"], name="core_exifda_lens_id_255c04_idx"
),
),
migrations.AddIndex(
model_name="exifdata",
index=models.Index(
fields=["focal_length"], name="core_exifda_focal_l_2260e9_idx"
),
),
migrations.AddIndex(
model_name="exifdata",
index=models.Index(
fields=["aperture"], name="core_exifda_apertur_e229d9_idx"
),
),
migrations.AddIndex(
model_name="exifdata",
index=models.Index(fields=["iso"], name="core_exifda_iso_e5a48e_idx"),
),
]