mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-12-22 22:01:48 +01:00
Display capabilities
This commit is contained in:
parent
95a4e2bdd3
commit
c91dedde93
11 changed files with 90 additions and 4 deletions
|
@ -38,6 +38,14 @@ class Path(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
|||
verbose_name = "Voie"
|
||||
verbose_name_plural = "Voies"
|
||||
|
||||
@property
|
||||
def display_name(self) -> str:
|
||||
to_remove = ["voie de la", "voie de l'", "voie du", "voie des", "voie de"]
|
||||
display_name = self.name.lower()
|
||||
for text in to_remove:
|
||||
display_name = display_name.replace(text, "")
|
||||
return display_name.strip().capitalize()
|
||||
|
||||
|
||||
class Capability(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
path = models.ForeignKey(
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import collections
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.functions import Lower
|
||||
from django.urls import reverse
|
||||
from django_extensions.db.models import TimeStampedModel
|
||||
|
||||
from character.models import Capability, Path
|
||||
from character.models.dice import Dice
|
||||
from common.models import DocumentedModel, UniquelyNamedModel
|
||||
|
||||
|
@ -222,3 +225,18 @@ class Character(models.Model):
|
|||
@property
|
||||
def imc(self) -> float:
|
||||
return self.weight / (self.height_m**2)
|
||||
|
||||
def get_capabilities_by_path(self) -> dict[Path, list[Capability]]:
|
||||
capabilities_by_path = collections.defaultdict(list)
|
||||
for capability in self.capabilities.all():
|
||||
capabilities_by_path[capability.path].append(capability)
|
||||
|
||||
return dict(
|
||||
sorted(
|
||||
(
|
||||
(path, sorted(capabilities, key=lambda x: x.rank))
|
||||
for path, capabilities in capabilities_by_path.items()
|
||||
),
|
||||
key=lambda x: x[0].name,
|
||||
)
|
||||
)
|
||||
|
|
|
@ -114,10 +114,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h5>Capacité raciale</h5>
|
||||
<h6>{{ character.racial_capability.name }}</h6>
|
||||
<p>{{ character.racial_capability.description|capfirst }}</p>
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="card">
|
||||
<h5 class="card-header">{{ character.racial_capability.name }}</h5>
|
||||
<div class="card-body">
|
||||
<p class="card-text">{{ character.racial_capability.description|capfirst }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<table class="table table-hover table-sm">
|
||||
|
@ -146,4 +149,40 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<h5 class="card-header">Équipement</h5>
|
||||
<div class="card-body">
|
||||
<p class="card-text">{{ character.equipment|linebreaksbr|default:"Rien ici..." }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h5 class="mt-3">Voies & Capacités</h5>
|
||||
<div class="row gy-3">
|
||||
{% for path, capabilities in character.get_capabilities_by_path.items %}
|
||||
<div class="col-xl-3 col-md-6">
|
||||
<div class="card">
|
||||
<h5 class="card-header">{{ path.display_name }}</h5>
|
||||
{% if path.notes %}
|
||||
<div class="card-body">{{ path.notes }}</div>
|
||||
{% endif %}
|
||||
<ul class="list-group list-group-flush">
|
||||
{% for capability in capabilities %}
|
||||
<li class="list-group-item">
|
||||
<strong>
|
||||
{{ capability.rank }}.
|
||||
{{ capability.name }}
|
||||
{% if capability.spell %}<i class="fa-solid fa-hand-sparkles"></i>{% endif %}
|
||||
{% if capability.limited %}<i class="fa-solid fa-handcuffs"></i>{% endif %}
|
||||
</strong><br>
|
||||
{{ capability.description }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
6
src/common/static/vendor/fontawesome-6.2.0/css/brands.min.css
vendored
Normal file
6
src/common/static/vendor/fontawesome-6.2.0/css/brands.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
src/common/static/vendor/fontawesome-6.2.0/css/fontawesome.min.css
vendored
Normal file
6
src/common/static/vendor/fontawesome-6.2.0/css/fontawesome.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
src/common/static/vendor/fontawesome-6.2.0/css/solid.min.css
vendored
Normal file
6
src/common/static/vendor/fontawesome-6.2.0/css/solid.min.css
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
/*!
|
||||
* Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
|
||||
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
|
||||
* Copyright 2022 Fonticons, Inc.
|
||||
*/
|
||||
:host,:root{--fa-style-family-classic:"Font Awesome 6 Free";--fa-font-solid:normal 900 1em/1 "Font Awesome 6 Free"}@font-face{font-family:"Font Awesome 6 Free";font-style:normal;font-weight:900;font-display:block;src:url(../webfonts/fa-solid-900.woff2) format("woff2"),url(../webfonts/fa-solid-900.ttf) format("truetype")}.fa-solid,.fas{font-weight:900}
|
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-brands-400.ttf
vendored
Normal file
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-brands-400.ttf
vendored
Normal file
Binary file not shown.
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-brands-400.woff2
vendored
Normal file
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-brands-400.woff2
vendored
Normal file
Binary file not shown.
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-solid-900.ttf
vendored
Normal file
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-solid-900.ttf
vendored
Normal file
Binary file not shown.
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-solid-900.woff2
vendored
Normal file
BIN
src/common/static/vendor/fontawesome-6.2.0/webfonts/fa-solid-900.woff2
vendored
Normal file
Binary file not shown.
|
@ -10,6 +10,9 @@
|
|||
rel="stylesheet"
|
||||
integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi"
|
||||
crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="{% static "vendor/fontawesome-6.2.0/css/fontawesome.min.css" %}">
|
||||
<link rel="stylesheet" href="{% static "vendor/fontawesome-6.2.0/css/brands.min.css" %}">
|
||||
<link rel="stylesheet" href="{% static "vendor/fontawesome-6.2.0/css/solid.min.css" %}">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
|
Loading…
Reference in a new issue