first commit
This commit is contained in:
37
api/models.py
Normal file
37
api/models.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Hero(models.Model):
|
||||
PRIMARY_ATTR_STRENGTH = "Strength"
|
||||
PRIMARY_ATTR_AGILITY = "Agility"
|
||||
PRIMARY_ATTR_INTELLIGENCE = "Intelligence"
|
||||
|
||||
PRIMARY_CHOICES = (
|
||||
(PRIMARY_ATTR_STRENGTH, "Strength"),
|
||||
(PRIMARY_ATTR_AGILITY, "Agility"),
|
||||
(PRIMARY_ATTR_INTELLIGENCE, "Intelligence"),
|
||||
)
|
||||
|
||||
name = models.CharField(max_length=200)
|
||||
primary = models.CharField(max_length=20, choices=PRIMARY_CHOICES)
|
||||
|
||||
def __str__(self) -> str: # pragma: no cover - convenience only
|
||||
return f"{self.name} ({self.primary})"
|
||||
|
||||
|
||||
class Item(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
|
||||
def __str__(self) -> str: # pragma: no cover - convenience only
|
||||
return self.name
|
||||
|
||||
|
||||
class Aspect(models.Model):
|
||||
hero = models.ForeignKey(Hero, on_delete=models.CASCADE, related_name="aspects")
|
||||
name = models.CharField(max_length=200)
|
||||
|
||||
class Meta:
|
||||
unique_together = ["hero", "name"]
|
||||
|
||||
def __str__(self) -> str: # pragma: no cover - convenience only
|
||||
return f"{self.hero.name} - {self.name}"
|
||||
Reference in New Issue
Block a user