diff --git a/src/character/forms.py b/src/character/forms.py index 8d25a0e..e341ee8 100644 --- a/src/character/forms.py +++ b/src/character/forms.py @@ -24,8 +24,10 @@ class AddPathForm(forms.Form): def __init__(self, character: Character, *args, **kwargs): super().__init__(*args, **kwargs) paths = {cap.path_id for cap in character.capabilities.all()} - paths = Path.objects.exclude(pk__in=paths).order_by( - "profile__name", "race__name" + paths = ( + Path.objects.exclude(pk__in=paths) + .order_by("profile__name", "race__name") + .select_related("profile", "race") ) character_paths = paths.filter( Q(profile=character.profile) | Q(race=character.race) diff --git a/src/character/migrations/0031_alter_harmfulstate_options.py b/src/character/migrations/0031_alter_harmfulstate_options.py new file mode 100644 index 0000000..a251c9b --- /dev/null +++ b/src/character/migrations/0031_alter_harmfulstate_options.py @@ -0,0 +1,21 @@ +# Generated by Django 4.1.2 on 2022-11-02 21:01 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("character", "0030_alter_character_states"), + ] + + operations = [ + migrations.AlterModelOptions( + name="harmfulstate", + options={ + "ordering": ["name"], + "verbose_name": "État préjudiciable", + "verbose_name_plural": "États préjudiciables", + }, + ), + ] diff --git a/src/character/migrations/max_migration.txt b/src/character/migrations/max_migration.txt index 8f8b1da..626f3dd 100644 --- a/src/character/migrations/max_migration.txt +++ b/src/character/migrations/max_migration.txt @@ -1 +1 @@ -0030_alter_character_states +0031_alter_harmfulstate_options diff --git a/src/character/models/character.py b/src/character/models/character.py index 1dd20c4..7bf11c9 100644 --- a/src/character/models/character.py +++ b/src/character/models/character.py @@ -1,4 +1,5 @@ import collections +from collections.abc import Iterable import markdown from django.db import models @@ -56,6 +57,7 @@ class HarmfulState(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models class Meta: verbose_name = "État préjudiciable" verbose_name_plural = "États préjudiciables" + ordering = ["name"] def modifier(value: int) -> int: @@ -318,3 +320,8 @@ class Character(models.Model): def get_formatted_notes(self) -> str: md = markdown.Markdown(extensions=["extra", "nl2br"]) return md.convert(self.notes) + + def get_missing_states(self) -> Iterable[HarmfulState]: + return HarmfulState.objects.exclude( + pk__in=self.states.all().values_list("pk", flat=True) + ) diff --git a/src/character/static/character/style.css b/src/character/static/character/style.css new file mode 100644 index 0000000..88d9572 --- /dev/null +++ b/src/character/static/character/style.css @@ -0,0 +1,3 @@ +.state-enabled { + filter: invert(50%) sepia(100%) saturate(3000%) hue-rotate(325deg); +} diff --git a/src/character/templates/character/states.html b/src/character/templates/character/states.html index 0fdcf58..6137566 100644 --- a/src/character/templates/character/states.html +++ b/src/character/templates/character/states.html @@ -1,15 +1,20 @@
États : - {% for state in character.states.all %} - - {% empty %} - Aucun - {% endfor %} + {% with character.states.all as character_states %} + {% for state in all_states %} + + {% endfor %} + {% endwith %}
diff --git a/src/character/templates/character/view.html b/src/character/templates/character/view.html index 246c7ee..e6c6dc8 100644 --- a/src/character/templates/character/view.html +++ b/src/character/templates/character/view.html @@ -1,9 +1,14 @@ {% extends "common/base.html" %} +{% load static %} {% load django_bootstrap5 %} {% load character_extras %} {% block title %}{{ character.name }}{% endblock %} +{% block head_end %} + +{% endblock %} + {% block content %}
diff --git a/src/character/urls.py b/src/character/urls.py
index a333358..05a80c6 100644
--- a/src/character/urls.py
+++ b/src/character/urls.py
@@ -72,4 +72,5 @@ urlpatterns = [
path(
"