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