phase3: add normalized domain schema, admin, services, and multistage docker build
This commit is contained in:
52
apps/scouting/models.py
Normal file
52
apps/scouting/models.py
Normal file
@ -0,0 +1,52 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
|
||||
class SavedSearch(models.Model):
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="saved_searches",
|
||||
)
|
||||
name = models.CharField(max_length=120)
|
||||
filters = models.JSONField(default=dict)
|
||||
is_public = models.BooleanField(default=False)
|
||||
last_run_at = models.DateTimeField(blank=True, null=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-updated_at"]
|
||||
constraints = [models.UniqueConstraint(fields=["user", "name"], name="uq_saved_search_user_name")]
|
||||
indexes = [
|
||||
models.Index(fields=["user", "updated_at"]),
|
||||
models.Index(fields=["is_public"]),
|
||||
]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.name} ({self.user})"
|
||||
|
||||
|
||||
class FavoritePlayer(models.Model):
|
||||
user = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="favorite_players",
|
||||
)
|
||||
player = models.ForeignKey(
|
||||
"players.Player",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="favorites",
|
||||
)
|
||||
note = models.CharField(max_length=240, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-created_at"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=["user", "player"], name="uq_favorite_player_per_user")
|
||||
]
|
||||
indexes = [models.Index(fields=["user", "created_at"]), models.Index(fields=["player"])]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.user} -> {self.player}"
|
||||
Reference in New Issue
Block a user