Translate fields

This commit is contained in:
Gabriel Augendre 2022-10-30 11:09:46 +01:00
parent 8196422f9e
commit 1be70dfe6f
5 changed files with 125 additions and 66 deletions

View file

@ -10,7 +10,7 @@ class CapabilityAdmin(admin.ModelAdmin):
search_fields = ["name", "description"] search_fields = ["name", "description"]
fieldsets = [ fieldsets = [
(None, {"fields": ["name"]}), (None, {"fields": ["name"]}),
("Path", {"fields": [("path", "rank")]}), ("Voie", {"fields": [("path", "rank")]}),
("Type", {"fields": [("limited", "spell")]}), ("Type", {"fields": [("limited", "spell")]}),
("Description", {"fields": ["description"]}), ("Description", {"fields": ["description"]}),
("Documentation", {"fields": ["url"]}), ("Documentation", {"fields": ["url"]}),
@ -24,7 +24,7 @@ class PathAdmin(admin.ModelAdmin):
search_fields = ["name"] search_fields = ["name"]
fieldsets = [ fieldsets = [
(None, {"fields": ["name"]}), (None, {"fields": ["name"]}),
("Related to", {"fields": ["category", ("profile", "race")]}), ("Lié à", {"fields": ["category", ("profile", "race")]}),
("Notes", {"fields": ["notes"]}), ("Notes", {"fields": ["notes"]}),
("Documentation", {"fields": ["url"]}), ("Documentation", {"fields": ["url"]}),
] ]
@ -85,12 +85,12 @@ class CharacterAdmin(admin.ModelAdmin):
fieldsets = [ fieldsets = [
( (
"Identity", "Identité",
{"fields": ["name", "player", "profile", "level", "race"]}, {"fields": ["name", "player", "profile", "level", "race"]},
), ),
("Appearance", {"fields": ["gender", "age", "height", "weight"]}), ("Apparence", {"fields": ["gender", "age", "height", "weight"]}),
( (
"Abilities", "Caractéristiques",
{ {
"fields": [ "fields": [
("value_strength", "modifier_strength"), ("value_strength", "modifier_strength"),
@ -103,15 +103,15 @@ class CharacterAdmin(admin.ModelAdmin):
}, },
), ),
( (
"Fight", "Combat",
{"fields": ["initiative", "attack_melee", "attack_range", "attack_magic"]}, {"fields": ["initiative", "attack_melee", "attack_range", "attack_magic"]},
), ),
("Health", {"fields": ["health_max", "health_remaining"]}), ("Vitalité", {"fields": ["health_max", "health_remaining"]}),
("Defense", {"fields": ["armor", "shield", "defense_misc", "defense"]}), ("Défense", {"fields": ["armor", "shield", "defense_misc", "defense"]}),
("Weapons & equipment", {"fields": ["weapons", "equipment"]}), ("Armes & équipement", {"fields": ["weapons", "equipment"]}),
("Racial", {"fields": ["racial_capability"]}), ("Race", {"fields": ["racial_capability"]}),
("Capabilities", {"fields": ["capabilities"]}), ("Capacités", {"fields": ["capabilities"]}),
("Luck", {"fields": ["luck_points_max", "luck_points_remaining"]}), ("Chance", {"fields": ["luck_points_max", "luck_points_remaining"]}),
("Mana", {"fields": ["mana_max", "mana_consumed", "mana_remaining"]}), ("Mana", {"fields": ["mana_max", "mana_consumed", "mana_remaining"]}),
("Notes", {"fields": ["notes"]}), ("Notes", {"fields": ["notes"]}),
] ]

View file

@ -12,6 +12,7 @@ class Path(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
related_name="paths", related_name="paths",
blank=True, blank=True,
null=True, null=True,
verbose_name="profil",
) )
race = models.ForeignKey( race = models.ForeignKey(
"character.Race", "character.Race",
@ -19,30 +20,44 @@ class Path(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
related_name="paths", related_name="paths",
blank=True, blank=True,
null=True, null=True,
verbose_name="race",
) )
class Category(models.TextChoices): class Category(models.TextChoices):
PROFILE = "profile", "Profile" PROFILE = "profile", "Profil"
RACE = "race", "Race" RACE = "race", "Race"
PRESTIGE = "prestige", "Prestige" PRESTIGE = "prestige", "Prestige"
CREATURE = "creature", "Creature" CREATURE = "creature", "Créature"
category = models.CharField(max_length=20, choices=Category.choices) category = models.CharField(
notes = models.TextField(blank=True) max_length=20, choices=Category.choices, verbose_name="catégorie"
)
notes = models.TextField(blank=True, verbose_name="notes")
class Meta:
verbose_name = "Voie"
verbose_name_plural = "Voies"
class Capability(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model): class Capability(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
path = models.ForeignKey("character.Path", on_delete=models.CASCADE) path = models.ForeignKey(
rank = models.PositiveSmallIntegerField( "character.Path", on_delete=models.CASCADE, verbose_name="voie"
validators=[MinValueValidator(1), MaxValueValidator(5)]
) )
limited = models.BooleanField(blank=True, null=False, default=False) rank = models.PositiveSmallIntegerField(
spell = models.BooleanField(blank=True, null=False, default=False) validators=[MinValueValidator(1), MaxValueValidator(5)], verbose_name="rang"
description = models.TextField() )
limited = models.BooleanField(
blank=True, null=False, default=False, verbose_name="limitée"
)
spell = models.BooleanField(
blank=True, null=False, default=False, verbose_name="sort"
)
description = models.TextField(verbose_name="description")
class Meta: class Meta:
constraints = [models.UniqueConstraint("path", "rank", name="unique_path_rank")] constraints = [models.UniqueConstraint("path", "rank", name="unique_path_rank")]
verbose_name_plural = "Capabilities" verbose_name = "Capacité"
verbose_name_plural = "Capacités"
class RacialCapabilityManager(models.Manager): class RacialCapabilityManager(models.Manager):
@ -51,14 +66,17 @@ class RacialCapabilityManager(models.Manager):
class RacialCapability(DocumentedModel, TimeStampedModel, models.Model): class RacialCapability(DocumentedModel, TimeStampedModel, models.Model):
name = models.CharField(max_length=100, blank=False, null=False) name = models.CharField(max_length=100, blank=False, null=False, verbose_name="nom")
race = models.ForeignKey("character.Race", on_delete=models.CASCADE) race = models.ForeignKey(
description = models.TextField() "character.Race", on_delete=models.CASCADE, verbose_name="race"
)
description = models.TextField(verbose_name="description")
objects = RacialCapabilityManager() objects = RacialCapabilityManager()
class Meta: class Meta:
verbose_name_plural = "Racial capabilities" verbose_name = "Capacité raciale"
verbose_name_plural = "Capacités raciales"
constraints = [models.UniqueConstraint("name", "race", name="unique_name_race")] constraints = [models.UniqueConstraint("name", "race", name="unique_name_race")]
def __str__(self): def __str__(self):

View file

@ -9,20 +9,31 @@ from common.models import DocumentedModel, UniquelyNamedModel
class Profile(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model): class Profile(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
class MagicalStrength(models.TextChoices): class MagicalStrength(models.TextChoices):
NONE = "NON", "None" NONE = "NON", "Aucun"
INTELLIGENCE = "INT", "Intelligence" INTELLIGENCE = "INT", "Intelligence"
WISDOM = "SAG", "Wisdom" WISDOM = "SAG", "Sagesse"
CHARISMA = "CHA", "Charisma" CHARISMA = "CHA", "Charisme"
magical_strength = models.CharField( magical_strength = models.CharField(
max_length=3, choices=MagicalStrength.choices, default=MagicalStrength.NONE max_length=3,
choices=MagicalStrength.choices,
default=MagicalStrength.NONE,
verbose_name="force magique",
) )
life_dice = models.PositiveSmallIntegerField(choices=Dice.choices) life_dice = models.PositiveSmallIntegerField(
notes = models.TextField(blank=True) choices=Dice.choices, verbose_name="dé de vie"
)
notes = models.TextField(blank=True, verbose_name="notes")
class Meta:
verbose_name = "Profil"
verbose_name_plural = "Profils"
class Race(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model): class Race(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
pass class Meta:
verbose_name = "Race"
verbose_name_plural = "Races"
def modifier(value: int) -> int: def modifier(value: int) -> int:
@ -39,69 +50,93 @@ class CharacterManager(models.Manager):
class Character(models.Model): class Character(models.Model):
class Gender(models.TextChoices): class Gender(models.TextChoices):
MALE = "M", "Male" MALE = "M", "Mâle"
FEMALE = "F", "Female" FEMALE = "F", "Femelle"
OTHER = "O", "Other" OTHER = "O", "Autre"
name = models.CharField(max_length=100) name = models.CharField(max_length=100, verbose_name="nom")
player = models.ForeignKey( player = models.ForeignKey(
"common.User", on_delete=models.CASCADE, related_name="characters" "common.User",
on_delete=models.CASCADE,
related_name="characters",
verbose_name="joueur",
) )
race = models.ForeignKey( race = models.ForeignKey(
"character.Race", "character.Race",
on_delete=models.PROTECT, on_delete=models.PROTECT,
related_name="characters", related_name="characters",
verbose_name="race",
) )
profile = models.ForeignKey( profile = models.ForeignKey(
"character.Profile", "character.Profile",
on_delete=models.PROTECT, on_delete=models.PROTECT,
related_name="characters", related_name="characters",
verbose_name="profil",
) )
level = models.PositiveSmallIntegerField() level = models.PositiveSmallIntegerField(verbose_name="niveau")
gender = models.CharField( gender = models.CharField(
max_length=1, choices=Gender.choices, default=Gender.OTHER max_length=1, choices=Gender.choices, default=Gender.OTHER, verbose_name="genre"
) )
age = models.PositiveSmallIntegerField() age = models.PositiveSmallIntegerField(verbose_name="âge")
height = models.PositiveSmallIntegerField() height = models.PositiveSmallIntegerField(verbose_name="taille")
weight = models.PositiveSmallIntegerField() weight = models.PositiveSmallIntegerField(verbose_name="poids")
value_strength = models.PositiveSmallIntegerField() value_strength = models.PositiveSmallIntegerField(verbose_name="valeur force")
value_dexterity = models.PositiveSmallIntegerField() value_dexterity = models.PositiveSmallIntegerField(verbose_name="valeur dextérité")
value_constitution = models.PositiveSmallIntegerField() value_constitution = models.PositiveSmallIntegerField(
value_intelligence = models.PositiveSmallIntegerField() verbose_name="valeur constitution"
value_wisdom = models.PositiveSmallIntegerField() )
value_charisma = models.PositiveSmallIntegerField() value_intelligence = models.PositiveSmallIntegerField(
verbose_name="valeur intelligence"
)
value_wisdom = models.PositiveSmallIntegerField(verbose_name="valeur sagesse")
value_charisma = models.PositiveSmallIntegerField(verbose_name="valeur charisme")
health_max = models.PositiveSmallIntegerField() health_max = models.PositiveSmallIntegerField(verbose_name="points de vie max")
health_remaining = models.PositiveSmallIntegerField() health_remaining = models.PositiveSmallIntegerField(
verbose_name="points de vie restants"
)
racial_capability = models.ForeignKey( racial_capability = models.ForeignKey(
"character.RacialCapability", "character.RacialCapability",
on_delete=models.PROTECT, on_delete=models.PROTECT,
related_name="characters", related_name="characters",
verbose_name="capacité raciale",
) )
weapons = models.ManyToManyField("character.Weapon", blank=True) weapons = models.ManyToManyField(
"character.Weapon", blank=True, verbose_name="armes"
)
armor = models.PositiveSmallIntegerField() armor = models.PositiveSmallIntegerField(verbose_name="armure")
shield = models.PositiveSmallIntegerField() shield = models.PositiveSmallIntegerField(verbose_name="bouclier")
defense_misc = models.SmallIntegerField() defense_misc = models.SmallIntegerField(verbose_name="divers défense")
capabilities = models.ManyToManyField("character.Capability", blank=True) capabilities = models.ManyToManyField(
"character.Capability", blank=True, verbose_name="capacités"
)
equipment = models.TextField(blank=True) equipment = models.TextField(blank=True, verbose_name="équipement")
luck_points_max = models.PositiveSmallIntegerField() luck_points_max = models.PositiveSmallIntegerField(
luck_points_remaining = models.PositiveSmallIntegerField() verbose_name="points de chance max"
)
luck_points_remaining = models.PositiveSmallIntegerField(
verbose_name="points de chance restants"
)
mana_consumed = models.PositiveSmallIntegerField(default=0) mana_consumed = models.PositiveSmallIntegerField(
default=0, verbose_name="mana utilisé"
)
notes = models.TextField(blank=True) notes = models.TextField(blank=True, verbose_name="notes")
objects = CharacterManager() objects = CharacterManager()
class Meta: class Meta:
verbose_name = "Personnage"
verbose_name_plural = "Personnages"
constraints = [ constraints = [
models.UniqueConstraint( models.UniqueConstraint(
Lower("name"), "player", name="unique_character_player" Lower("name"), "player", name="unique_character_player"

View file

@ -5,5 +5,9 @@ from common.models import UniquelyNamedModel
class Weapon(UniquelyNamedModel, TimeStampedModel, models.Model): class Weapon(UniquelyNamedModel, TimeStampedModel, models.Model):
damage = models.CharField(max_length=50, blank=True) damage = models.CharField(max_length=50, blank=True, verbose_name="dégâts")
special = models.TextField(blank=True) special = models.TextField(blank=True, verbose_name="spécial")
class Meta:
verbose_name = "Arme"
verbose_name_plural = "Armes"

View file

@ -14,7 +14,9 @@ class UniquelyNamedModelManager(models.Manager):
class UniquelyNamedModel(models.Model): class UniquelyNamedModel(models.Model):
name = models.CharField(max_length=100, blank=False, null=False, unique=True) name = models.CharField(
max_length=100, blank=False, null=False, unique=True, verbose_name="nom"
)
objects = UniquelyNamedModelManager() objects = UniquelyNamedModelManager()
class Meta: class Meta:
@ -28,7 +30,7 @@ class UniquelyNamedModel(models.Model):
class DocumentedModel(models.Model): class DocumentedModel(models.Model):
url = models.URLField(blank=True, null=False) url = models.URLField(blank=True, null=False, verbose_name="url")
class Meta: class Meta:
abstract = True abstract = True