Compare commits
4 Commits
aecbb62376
...
80f6c160f4
| Author | SHA1 | Date | |
|---|---|---|---|
| 80f6c160f4 | |||
| 065a5f66f1 | |||
| aa283a1235 | |||
| e6390fe664 |
@ -26,8 +26,10 @@ class SpecialtyAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(Player)
|
||||
class PlayerAdmin(admin.ModelAdmin):
|
||||
list_display = ("full_name", "nationality", "birth_date")
|
||||
list_display = ("full_name", "position", "nationality", "birth_date")
|
||||
search_fields = ("full_name", "first_name", "last_name", "nationality")
|
||||
list_filter = ("position",)
|
||||
filter_horizontal = ("roles", "specialties")
|
||||
|
||||
|
||||
@admin.register(Competition)
|
||||
@ -38,9 +40,8 @@ class CompetitionAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(Team)
|
||||
class TeamAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "competition", "country")
|
||||
list_display = ("name", "country")
|
||||
search_fields = ("name", "country")
|
||||
list_filter = ("competition",)
|
||||
|
||||
|
||||
@admin.register(Season)
|
||||
@ -51,10 +52,9 @@ class SeasonAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(PlayerSeason)
|
||||
class PlayerSeasonAdmin(admin.ModelAdmin):
|
||||
list_display = ("player", "season", "team", "competition", "position")
|
||||
list_filter = ("season", "competition", "position")
|
||||
list_display = ("player", "season", "team", "competition")
|
||||
list_filter = ("season", "competition")
|
||||
search_fields = ("player__full_name", "team__name", "competition__name")
|
||||
filter_horizontal = ("roles", "specialties")
|
||||
|
||||
|
||||
@admin.register(PlayerSeasonStats)
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
# Generated by Django 5.2.2 on 2026-04-06 17:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('scouting', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterUniqueTogether(
|
||||
name='team',
|
||||
unique_together=set(),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='playerseason',
|
||||
name='position',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='playerseason',
|
||||
name='roles',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='playerseason',
|
||||
name='specialties',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='position',
|
||||
field=models.CharField(choices=[('PG', 'PG'), ('SG', 'SG'), ('SF', 'SF'), ('PF', 'PF'), ('C', 'C')], default='PG', max_length=2),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='roles',
|
||||
field=models.ManyToManyField(blank=True, related_name='players', to='scouting.role'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='player',
|
||||
name='specialties',
|
||||
field=models.ManyToManyField(blank=True, related_name='players', to='scouting.specialty'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='playerseason',
|
||||
constraint=models.UniqueConstraint(fields=('player', 'season'), name='uniq_player_season'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='team',
|
||||
constraint=models.UniqueConstraint(fields=('name', 'country'), name='uniq_team_name_country'),
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='team',
|
||||
name='competition',
|
||||
),
|
||||
]
|
||||
18
app/scouting/migrations/0003_alter_player_position.py
Normal file
18
app/scouting/migrations/0003_alter_player_position.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.2 on 2026-04-06 17:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('scouting', '0002_alter_team_unique_together_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='player',
|
||||
name='position',
|
||||
field=models.CharField(choices=[('PG', 'PG'), ('SG', 'SG'), ('SF', 'SF'), ('PF', 'PF'), ('C', 'C')], max_length=2),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.2.2 on 2026-04-06 17:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('scouting', '0003_alter_player_position'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='playerseason',
|
||||
name='uniq_player_season',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='playerseason',
|
||||
constraint=models.UniqueConstraint(fields=('player', 'season', 'team', 'competition'), name='uniq_player_season_context', nulls_distinct=False),
|
||||
),
|
||||
]
|
||||
@ -26,6 +26,13 @@ class Specialty(models.Model):
|
||||
|
||||
|
||||
class Player(models.Model):
|
||||
class Position(models.TextChoices):
|
||||
PG = "PG", "PG"
|
||||
SG = "SG", "SG"
|
||||
SF = "SF", "SF"
|
||||
PF = "PF", "PF"
|
||||
C = "C", "C"
|
||||
|
||||
full_name = models.CharField(max_length=255)
|
||||
first_name = models.CharField(max_length=100, blank=True)
|
||||
last_name = models.CharField(max_length=100, blank=True)
|
||||
@ -34,6 +41,9 @@ class Player(models.Model):
|
||||
height_cm = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
|
||||
weight_kg = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
|
||||
wingspan_cm = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
|
||||
position = models.CharField(max_length=2, choices=Position.choices)
|
||||
roles = models.ManyToManyField(Role, blank=True, related_name="players")
|
||||
specialties = models.ManyToManyField(Specialty, blank=True, related_name="players")
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
@ -60,20 +70,15 @@ class Competition(models.Model):
|
||||
|
||||
class Team(models.Model):
|
||||
name = models.CharField(max_length=150)
|
||||
competition = models.ForeignKey(
|
||||
Competition,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name="teams",
|
||||
)
|
||||
country = models.CharField(max_length=100, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
unique_together = ("name", "competition")
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["name", "country"], name="uniq_team_name_country"),
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.name
|
||||
@ -94,13 +99,6 @@ class Season(models.Model):
|
||||
|
||||
|
||||
class PlayerSeason(models.Model):
|
||||
class Position(models.TextChoices):
|
||||
PG = "PG", "PG"
|
||||
SG = "SG", "SG"
|
||||
SF = "SF", "SF"
|
||||
PF = "PF", "PF"
|
||||
C = "C", "C"
|
||||
|
||||
player = models.ForeignKey(Player, on_delete=models.CASCADE, related_name="player_seasons")
|
||||
season = models.ForeignKey(Season, on_delete=models.CASCADE, related_name="player_seasons")
|
||||
team = models.ForeignKey(
|
||||
@ -117,17 +115,23 @@ class PlayerSeason(models.Model):
|
||||
blank=True,
|
||||
related_name="player_seasons",
|
||||
)
|
||||
position = models.CharField(max_length=2, choices=Position.choices)
|
||||
roles = models.ManyToManyField(Role, blank=True, related_name="player_seasons")
|
||||
specialties = models.ManyToManyField(Specialty, blank=True, related_name="player_seasons")
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["player__full_name", "-season__start_year"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["player", "season", "team", "competition"],
|
||||
name="uniq_player_season_context",
|
||||
nulls_distinct=False,
|
||||
),
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.player.full_name} - {self.season.name}"
|
||||
team_name = self.team.name if self.team else "No team"
|
||||
competition_name = self.competition.name if self.competition else "No competition"
|
||||
return f"{self.player.full_name} - {self.season.name} - {team_name} - {competition_name}"
|
||||
|
||||
|
||||
class PlayerSeasonStats(models.Model):
|
||||
|
||||
Reference in New Issue
Block a user