Introduce the foundational accounts app: - Custom email-as-username User (AbstractBaseUser + PermissionsMixin) set as AUTH_USER_MODEL, decoupled from membership so children can be members without a login. - Member model holding personal/roster data (names, contact email, phone + emergency phone via django-phonenumber-field, license number, DOB) with an optional link to a User. - Family household grouping and directional Guardianship (guardian -> child) with uniqueness and no-self-guardian constraints. - Custom UserAdmin plus Member/Family admin with inlines and autocomplete. - Settings: register apps, AUTH_USER_MODEL, phonenumber defaults (BE/E164). - Add CLAUDE.md and a tracked static/ directory. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
98 lines
5.1 KiB
Python
98 lines
5.1 KiB
Python
# Generated by Django 6.0.6 on 2026-07-01 22:04
|
|
|
|
import accounts.managers
|
|
import django.db.models.deletion
|
|
import django.utils.timezone
|
|
import phonenumber_field.modelfields
|
|
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='Family',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('name', models.CharField(help_text='e.g. "The Smiths"', max_length=150)),
|
|
('address', models.CharField(blank=True, max_length=255)),
|
|
],
|
|
options={
|
|
'verbose_name_plural': 'families',
|
|
'ordering': ['name'],
|
|
},
|
|
),
|
|
migrations.CreateModel(
|
|
name='Guardianship',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('relationship', models.CharField(choices=[('parent', 'Parent'), ('guardian', 'Guardian'), ('other', 'Other')], default='parent', max_length=20)),
|
|
],
|
|
),
|
|
migrations.CreateModel(
|
|
name='User',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('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')),
|
|
('email', models.EmailField(max_length=254, unique=True)),
|
|
('is_staff', models.BooleanField(default=False, help_text='Whether the user can log into the admin site.')),
|
|
('is_active', models.BooleanField(default=True)),
|
|
('date_joined', models.DateTimeField(default=django.utils.timezone.now)),
|
|
('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={
|
|
'abstract': False,
|
|
},
|
|
managers=[
|
|
('objects', accounts.managers.UserManager()),
|
|
],
|
|
),
|
|
migrations.CreateModel(
|
|
name='Member',
|
|
fields=[
|
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('first_name', models.CharField(max_length=150)),
|
|
('last_name', models.CharField(max_length=150)),
|
|
('email', models.EmailField(blank=True, max_length=254)),
|
|
('phone', phonenumber_field.modelfields.PhoneNumberField(blank=True, max_length=128, region=None)),
|
|
('emergency_phone', phonenumber_field.modelfields.PhoneNumberField(blank=True, max_length=128, region=None)),
|
|
('license_number', models.CharField(blank=True, max_length=50)),
|
|
('date_of_birth', models.DateField()),
|
|
('family', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='members', to='accounts.family')),
|
|
('guardians', models.ManyToManyField(related_name='dependents', through='accounts.Guardianship', through_fields=('child', 'guardian'), to='accounts.member')),
|
|
('user', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='member', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
options={
|
|
'ordering': ['last_name', 'first_name'],
|
|
},
|
|
),
|
|
migrations.AddField(
|
|
model_name='guardianship',
|
|
name='child',
|
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='child_links', to='accounts.member'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='guardianship',
|
|
name='guardian',
|
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='guardian_links', to='accounts.member'),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='guardianship',
|
|
constraint=models.UniqueConstraint(fields=('guardian', 'child'), name='unique_guardianship'),
|
|
),
|
|
migrations.AddConstraint(
|
|
model_name='guardianship',
|
|
constraint=models.CheckConstraint(condition=models.Q(('guardian', models.F('child')), _negated=True), name='guardian_not_self'),
|
|
),
|
|
]
|