Add row-based multi-tenancy plumbing keyed on Club as the tenant root: - ClubTenantMiddleware maps the request's subdomain to a Club by slug, storing it on request.club and in a contextvar so service-layer code and management commands can read it via get_current_club(). Resolution honours CLUBMANAGER_BASE_DOMAIN (e.g. ajax-united.clubmanager.app), falling back to generic slug.example.com hosts, and ignores the bare base domain, www, and unknown slugs. - Club gains a unique slug (auto-derived from name on save) plus a ClubManager.current() accessor for the active tenant. - ClubScopedModel gets a TenantQuerySet (.for_club()/.current()) and auto-fills club from the active context on save. Contextvar helpers live in club.tenancy; Club is imported lazily there and in clubmanager.base to avoid an import cycle with club.models. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
# Generated by Django 6.0.6 on 2026-07-12 13:11
|
|
|
|
import django.db.models.deletion
|
|
import uuid
|
|
from django.db import migrations, models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('club', '0005_alter_clubmembership_member'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='club',
|
|
name='slug',
|
|
field=models.SlugField(blank=True, help_text='Drives subdomain / path resolution (e.g. ajax-united.clubmanager.app).', max_length=255, unique=True, verbose_name='slug'),
|
|
),
|
|
migrations.CreateModel(
|
|
name='Season',
|
|
fields=[
|
|
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
|
|
('start_date', models.DateField(verbose_name='start date')),
|
|
('end_date', models.DateField(verbose_name='end date')),
|
|
('club', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)ss', to='club.club')),
|
|
],
|
|
options={
|
|
'verbose_name': 'season',
|
|
'verbose_name_plural': 'seasons',
|
|
},
|
|
),
|
|
]
|