mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-04 22:03:56 +01:00
Add view capability
This commit is contained in:
parent
9033c8453c
commit
833584a2b7
10 changed files with 307 additions and 257 deletions
|
@ -337,3 +337,6 @@ class Character(models.Model):
|
|||
return HarmfulState.objects.exclude(
|
||||
pk__in=self.states.all().values_list("pk", flat=True)
|
||||
)
|
||||
|
||||
def managed_by(self, user):
|
||||
return self in Character.objects.managed_by(user)
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
|
||||
{% block content %}
|
||||
<h1>{{ character.name }}</h1>
|
||||
<p>
|
||||
<a href="{% url "admin:character_character_change" object_id=character.pk %}">Edit</a>
|
||||
</p>
|
||||
{% if character|managed_by:user %}
|
||||
<p>
|
||||
<a href="{% url "admin:character_character_change" object_id=character.pk %}">Edit</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
<p>
|
||||
Joueur : {{ character.player.get_full_name|default:character.player.username }}
|
||||
</p>
|
||||
|
@ -28,30 +30,32 @@
|
|||
<tr>
|
||||
<th scope="row">
|
||||
Initiative divers
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#initiative-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#initiative-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=1"
|
||||
hx-target="#initiative-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#initiative-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#initiative-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=1"
|
||||
hx-target="#initiative-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td id="initiative-misc">
|
||||
{{ character.initiative_misc }}
|
||||
|
@ -62,8 +66,10 @@
|
|||
<td data-bs-toggle="tooltip"
|
||||
data-bs-placement="left"
|
||||
data-bs-title="{{ character.modifier_dexterity }} (mod. DEX) + {{ character.initiative_misc }} (divers)"
|
||||
hx-get="{% url "character:get_initiative" pk=character.pk %}"
|
||||
hx-trigger="update_initiative from:#fight-table">
|
||||
{% if character|managed_by:user %}
|
||||
hx-get="{% url "character:get_initiative" pk=character.pk %}"
|
||||
hx-trigger="update_initiative from:#fight-table"
|
||||
{% endif %}>
|
||||
{{ character.modifier_initiative|modifier }}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -103,30 +109,32 @@
|
|||
<tr>
|
||||
<th scope="row">
|
||||
Armure
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=1"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=1"
|
||||
hx-target="#armor"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td id="armor">
|
||||
{{ character.armor }}
|
||||
|
@ -135,30 +143,32 @@
|
|||
<tr>
|
||||
<th scope="row">
|
||||
Bouclier
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:shield_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#shield"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:shield_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#shield"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:shield_change" pk=character.pk %}?value=1"
|
||||
hx-target="#shield"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:shield_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#shield"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:shield_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#shield"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:shield_change" pk=character.pk %}?value=1"
|
||||
hx-target="#shield"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td id="shield">
|
||||
{{ character.shield }}
|
||||
|
@ -167,30 +177,32 @@
|
|||
<tr>
|
||||
<th scope="row">
|
||||
Divers défense
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#defense-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#defense-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=1"
|
||||
hx-target="#defense-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#defense-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#defense-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=1"
|
||||
hx-target="#defense-misc"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td id="defense-misc">
|
||||
{{ character.defense_misc }}
|
||||
|
@ -201,8 +213,10 @@
|
|||
<td data-bs-toggle="tooltip"
|
||||
data-bs-placement="left"
|
||||
data-bs-title="10 + armure + bouclier + mod. DEX + divers"
|
||||
hx-get="{% url "character:get_defense" pk=character.pk %}"
|
||||
hx-trigger="update_defense from:#fight-table">
|
||||
{% if character|managed_by:user %}
|
||||
hx-get="{% url "character:get_defense" pk=character.pk %}"
|
||||
hx-trigger="update_defense from:#fight-table"
|
||||
{% endif %}>
|
||||
{{ character.defense }}
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -218,64 +232,68 @@
|
|||
<tr>
|
||||
<th scope="row">
|
||||
Points de vie
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=1"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=max"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=1"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=max"
|
||||
hx-target="#health-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td><span id="health-remaining">{{ character.health_remaining }}</span> / {{ character.health_max }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
Points de mana
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=1"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=max"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=ko"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-danger"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=1"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=max"
|
||||
hx-target="#mana-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td data-bs-toggle="tooltip"
|
||||
data-bs-placement="left"
|
||||
|
@ -291,28 +309,30 @@
|
|||
<tr>
|
||||
<th scope="row">
|
||||
Points de récup.
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:recovery_points_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#recovery-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:recovery_points_change" pk=character.pk %}?value=1"
|
||||
hx-target="#recovery-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:recovery_points_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#recovery-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:recovery_points_change" pk=character.pk %}?value=1"
|
||||
hx-target="#recovery-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td>
|
||||
<span id="recovery-points-remaining">{{ character.recovery_points_remaining }}</span> / {{ character.recovery_points_max }}</td>
|
||||
|
@ -320,30 +340,32 @@
|
|||
<tr>
|
||||
<th scope="row">
|
||||
Points de chance
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=1"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=max"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm float-end" role="group">
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-empty"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=-1"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-danger"><i class="fa-solid fa-minus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=1"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-success"><i class="fa-solid fa-plus"></i></button>
|
||||
<button
|
||||
hx-get="{% url "character:luck_points_change" pk=character.pk %}?value=max"
|
||||
hx-target="#luck-points-remaining"
|
||||
hx-swap="innerHTML"
|
||||
type="button"
|
||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</th>
|
||||
<td data-bs-toggle="tooltip"
|
||||
data-bs-placement="left"
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
{% load character_extras %}
|
||||
<div class="card" id="damage-reduction">
|
||||
<h5 class="card-header">
|
||||
Réduction de dégâts
|
||||
<a hx-get="{% url "character:damage_reduction_change" pk=character.pk %}"
|
||||
hx-target="#damage-reduction"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||
</a>
|
||||
{% if character|managed_by:user %}
|
||||
<a hx-get="{% url "character:damage_reduction_change" pk=character.pk %}"
|
||||
hx-target="#damage-reduction"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||
</a>
|
||||
{% endif %}
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
<p class="card-text">
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
{% load character_extras %}
|
||||
<div class="card" id="equipment">
|
||||
<h5 class="card-header">
|
||||
Équipement
|
||||
<a hx-get="{% url "character:equipment_change" pk=character.pk %}"
|
||||
hx-target="#equipment"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||
</a>
|
||||
{% if character|managed_by:user %}
|
||||
<a hx-get="{% url "character:equipment_change" pk=character.pk %}"
|
||||
hx-target="#equipment"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||
</a>
|
||||
{% endif %}
|
||||
</h5>
|
||||
<div class="card-body">
|
||||
<p class="card-text">
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
{% load character_extras %}
|
||||
<div class="mt-3" id="notes">
|
||||
<h2>
|
||||
Notes
|
||||
<a hx-get="{% url "character:notes_change" pk=character.pk %}"
|
||||
hx-target="#notes"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||
</a>
|
||||
{% if character|managed_by:user %}
|
||||
<a hx-get="{% url "character:notes_change" pk=character.pk %}"
|
||||
hx-target="#notes"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary btn-sm"
|
||||
>
|
||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||
</a>
|
||||
{% endif %}
|
||||
</h2>
|
||||
{{ character.get_formatted_notes|safe }}
|
||||
</div>
|
||||
|
|
|
@ -2,22 +2,24 @@
|
|||
<div class="col-12 col-md-6 col-xl-4">
|
||||
<h5>
|
||||
{{ path.display_name }} ({{ path|max_rank:character }})
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button hx-get="{% url "character:remove_last_in_path" character_pk=character.pk path_pk=path.pk %}"
|
||||
hx-target="#paths-and-capabilities"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-secondary">
|
||||
<i class="fa-solid fa-minus"></i>
|
||||
</button>
|
||||
{% if path|has_next_capability:character %}
|
||||
<button hx-get="{% url "character:add_next_in_path" character_pk=character.pk path_pk=path.pk %}"
|
||||
{% if character|managed_by:user %}
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button hx-get="{% url "character:remove_last_in_path" character_pk=character.pk path_pk=path.pk %}"
|
||||
hx-target="#paths-and-capabilities"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
class="btn btn-secondary">
|
||||
<i class="fa-solid fa-minus"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if path|has_next_capability:character %}
|
||||
<button hx-get="{% url "character:add_next_in_path" character_pk=character.pk path_pk=path.pk %}"
|
||||
hx-target="#paths-and-capabilities"
|
||||
hx-swap="outerHTML"
|
||||
class="btn btn-primary">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</h5>
|
||||
{% if path.notes %}
|
||||
<div class="alert alert-primary">{{ path.notes }}</div>
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
{% load character_extras %}
|
||||
{% load django_bootstrap5 %}
|
||||
<div id="paths-and-capabilities">
|
||||
<form>
|
||||
{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{% bootstrap_form_errors add_path_form %}
|
||||
<div class="input-group">
|
||||
{{ add_path_form.character_path }}
|
||||
{{ add_path_form.other_path }}
|
||||
<button class="btn btn-primary"
|
||||
hx-target="#paths-and-capabilities"
|
||||
hx-swap="outerHTML"
|
||||
hx-post="{% url "character:add_path" pk=character.pk %}">
|
||||
Sélectionner
|
||||
</button>
|
||||
{% if character|managed_by:user %}
|
||||
<form>
|
||||
{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{% bootstrap_form_errors add_path_form %}
|
||||
<div class="input-group">
|
||||
{{ add_path_form.character_path }}
|
||||
{{ add_path_form.other_path }}
|
||||
<button class="btn btn-primary"
|
||||
hx-target="#paths-and-capabilities"
|
||||
hx-swap="outerHTML"
|
||||
hx-post="{% url "character:add_path" pk=character.pk %}">
|
||||
Sélectionner
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
{% endif %}
|
||||
<div class="row mt-2 gy-3">
|
||||
{% for path, capabilities in character.get_capabilities_by_path.items %}
|
||||
{% include "character/snippets/character_details/path.html" %}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{% load character_extras %}
|
||||
<div class="col">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
@ -21,18 +22,22 @@
|
|||
{% endfor %}
|
||||
{% endwith %}
|
||||
</p>
|
||||
{% if character.player == user %}
|
||||
<div class="btn-group btn-group-sm">
|
||||
<div class="btn-group btn-group-sm">
|
||||
{% if character|managed_by:user %}
|
||||
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-success">
|
||||
<i class="fa-solid fa-user"></i> Jouer
|
||||
<i class="fa-solid fa-user"></i> {% if character.player == user %}Jouer{% else %}Gérer{% endif %}
|
||||
</a>
|
||||
{% if party %}
|
||||
<a href="{% url "party:leave" pk=party.pk character_pk=character.pk %}" class="btn btn-warning">
|
||||
<i class="fa-solid fa-person-walking-arrow-right"></i> Quitter le groupe
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-primary">
|
||||
<i class="fa-solid fa-eye"></i> Observer
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django import template
|
||||
|
||||
from character.models import Character, Path, Weapon
|
||||
from common.models import User
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -37,3 +38,8 @@ def has_next_capability(path: Path, character: Character) -> bool:
|
|||
@register.filter
|
||||
def max_rank(path: Path, character: Character) -> int:
|
||||
return path.max_rank(character)
|
||||
|
||||
|
||||
@register.filter
|
||||
def managed_by(character: Character, user: User) -> bool:
|
||||
return character.managed_by(user)
|
||||
|
|
|
@ -27,7 +27,7 @@ def character_create(request):
|
|||
@login_required
|
||||
def character_view(request, pk: int):
|
||||
character = get_object_or_404(
|
||||
Character.objects.managed_by(request.user)
|
||||
Character.objects.all()
|
||||
.select_related("player", "racial_capability", "profile", "race")
|
||||
.prefetch_related("capabilities__path", "weapons"),
|
||||
pk=pk,
|
||||
|
|
Loading…
Reference in a new issue