mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-12-22 22:01:48 +01:00
Display path names and profile names in capabilities
This commit is contained in:
parent
df8ea865bb
commit
03eabc4bcb
1 changed files with 16 additions and 0 deletions
|
@ -46,6 +46,16 @@ class Path(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
|||
display_name = display_name.replace(text, "")
|
||||
return display_name.strip().capitalize()
|
||||
|
||||
@property
|
||||
def related_to(self) -> UniquelyNamedModel | None:
|
||||
category = Path.Category(self.category)
|
||||
if category == Path.Category.PROFILE:
|
||||
return self.profile
|
||||
elif category == Path.Category.RACE:
|
||||
return self.race
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class Capability(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
path = models.ForeignKey(
|
||||
|
@ -67,6 +77,12 @@ class Capability(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.M
|
|||
verbose_name = "Capacité"
|
||||
verbose_name_plural = "Capacités"
|
||||
|
||||
def __str__(self):
|
||||
description = f"{self.name} - {self.path.name}"
|
||||
if self.path.related_to:
|
||||
description += f" ({self.path.related_to.name})"
|
||||
return description
|
||||
|
||||
|
||||
class RacialCapabilityManager(models.Manager):
|
||||
def get_by_natural_key(self, name: str, race_id: int):
|
||||
|
|
Loading…
Reference in a new issue