phase3: add normalized domain schema, admin, services, and multistage docker build
This commit is contained in:
10
apps/teams/admin.py
Normal file
10
apps/teams/admin.py
Normal file
@ -0,0 +1,10 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Team
|
||||
|
||||
|
||||
@admin.register(Team)
|
||||
class TeamAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "short_name", "country", "is_national_team")
|
||||
list_filter = ("is_national_team", "country")
|
||||
search_fields = ("name", "short_name", "slug")
|
||||
35
apps/teams/migrations/0001_initial.py
Normal file
35
apps/teams/migrations/0001_initial.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Generated by Django 5.2.12 on 2026-03-10 09:33
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('players', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Team',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('short_name', models.CharField(blank=True, max_length=80)),
|
||||
('slug', models.SlugField(max_length=220, unique=True)),
|
||||
('founded_year', models.PositiveSmallIntegerField(blank=True, null=True)),
|
||||
('is_national_team', models.BooleanField(default=False)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('country', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='teams', to='players.nationality')),
|
||||
],
|
||||
options={
|
||||
'ordering': ['name'],
|
||||
'indexes': [models.Index(fields=['name'], name='teams_team_name_43e047_idx'), models.Index(fields=['slug'], name='teams_team_slug_1ce39f_idx'), models.Index(fields=['country'], name='teams_team_country_f5cb06_idx'), models.Index(fields=['is_national_team'], name='teams_team_is_nati_04af60_idx')],
|
||||
'constraints': [models.UniqueConstraint(fields=('name', 'country'), name='uq_team_name_country')],
|
||||
},
|
||||
),
|
||||
]
|
||||
33
apps/teams/models.py
Normal file
33
apps/teams/models.py
Normal file
@ -0,0 +1,33 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Team(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
short_name = models.CharField(max_length=80, blank=True)
|
||||
slug = models.SlugField(max_length=220, unique=True)
|
||||
country = models.ForeignKey(
|
||||
"players.Nationality",
|
||||
on_delete=models.SET_NULL,
|
||||
blank=True,
|
||||
null=True,
|
||||
related_name="teams",
|
||||
)
|
||||
founded_year = models.PositiveSmallIntegerField(blank=True, null=True)
|
||||
is_national_team = models.BooleanField(default=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["name", "country"], name="uq_team_name_country")
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=["name"]),
|
||||
models.Index(fields=["slug"]),
|
||||
models.Index(fields=["country"]),
|
||||
models.Index(fields=["is_national_team"]),
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
Reference in New Issue
Block a user