mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-05 06:13:55 +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>
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<p>
|
<p>
|
||||||
<a href="{% url "admin:character_character_change" object_id=character.pk %}">Edit</a>
|
<a href="{% url "admin:character_character_change" object_id=character.pk %}">Edit</a>
|
||||||
</p>
|
</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,6 +30,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Initiative divers
|
Initiative divers
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=ko"
|
hx-get="{% url "character:initiative_misc_change" pk=character.pk %}?value=ko"
|
||||||
|
@ -52,6 +55,7 @@
|
||||||
disabled
|
disabled
|
||||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</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)"
|
||||||
|
{% if character|managed_by:user %}
|
||||||
hx-get="{% url "character:get_initiative" pk=character.pk %}"
|
hx-get="{% url "character:get_initiative" pk=character.pk %}"
|
||||||
hx-trigger="update_initiative from:#fight-table">
|
hx-trigger="update_initiative from:#fight-table"
|
||||||
|
{% endif %}>
|
||||||
{{ character.modifier_initiative|modifier }}
|
{{ character.modifier_initiative|modifier }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -103,6 +109,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Armure
|
Armure
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
hx-get="{% url "character:armor_change" pk=character.pk %}?value=ko"
|
hx-get="{% url "character:armor_change" pk=character.pk %}?value=ko"
|
||||||
|
@ -127,6 +134,7 @@
|
||||||
disabled
|
disabled
|
||||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
<td id="armor">
|
<td id="armor">
|
||||||
{{ character.armor }}
|
{{ character.armor }}
|
||||||
|
@ -135,6 +143,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Bouclier
|
Bouclier
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
hx-get="{% url "character:shield_change" pk=character.pk %}?value=ko"
|
hx-get="{% url "character:shield_change" pk=character.pk %}?value=ko"
|
||||||
|
@ -159,6 +168,7 @@
|
||||||
disabled
|
disabled
|
||||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
<td id="shield">
|
<td id="shield">
|
||||||
{{ character.shield }}
|
{{ character.shield }}
|
||||||
|
@ -167,6 +177,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Divers défense
|
Divers défense
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=ko"
|
hx-get="{% url "character:defense_misc_change" pk=character.pk %}?value=ko"
|
||||||
|
@ -191,6 +202,7 @@
|
||||||
disabled
|
disabled
|
||||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</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"
|
||||||
|
{% if character|managed_by:user %}
|
||||||
hx-get="{% url "character:get_defense" pk=character.pk %}"
|
hx-get="{% url "character:get_defense" pk=character.pk %}"
|
||||||
hx-trigger="update_defense from:#fight-table">
|
hx-trigger="update_defense from:#fight-table"
|
||||||
|
{% endif %}>
|
||||||
{{ character.defense }}
|
{{ character.defense }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -218,6 +232,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Points de vie
|
Points de vie
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
hx-get="{% url "character:health_change" pk=character.pk %}?value=ko"
|
hx-get="{% url "character:health_change" pk=character.pk %}?value=ko"
|
||||||
|
@ -244,12 +259,14 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</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
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
hx-get="{% url "character:mana_change" pk=character.pk %}?value=ko"
|
hx-get="{% url "character:mana_change" pk=character.pk %}?value=ko"
|
||||||
|
@ -276,6 +293,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
<td data-bs-toggle="tooltip"
|
<td data-bs-toggle="tooltip"
|
||||||
data-bs-placement="left"
|
data-bs-placement="left"
|
||||||
|
@ -291,6 +309,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Points de récup.
|
Points de récup.
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -313,6 +332,7 @@
|
||||||
disabled
|
disabled
|
||||||
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-secondary"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</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,6 +340,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
Points de chance
|
Points de chance
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm float-end" role="group">
|
<div class="btn-group btn-group-sm float-end" role="group">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
@ -344,6 +365,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
class="btn btn-outline-success"><i class="fa-solid fa-battery-full"></i></button>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
<td data-bs-toggle="tooltip"
|
<td data-bs-toggle="tooltip"
|
||||||
data-bs-placement="left"
|
data-bs-placement="left"
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
{% 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
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<a hx-get="{% url "character:damage_reduction_change" pk=character.pk %}"
|
<a hx-get="{% url "character:damage_reduction_change" pk=character.pk %}"
|
||||||
hx-target="#damage-reduction"
|
hx-target="#damage-reduction"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
|
@ -8,6 +10,7 @@
|
||||||
>
|
>
|
||||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
</h5>
|
</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
{% load character_extras %}
|
||||||
<div class="card" id="equipment">
|
<div class="card" id="equipment">
|
||||||
<h5 class="card-header">
|
<h5 class="card-header">
|
||||||
Équipement
|
Équipement
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<a hx-get="{% url "character:equipment_change" pk=character.pk %}"
|
<a hx-get="{% url "character:equipment_change" pk=character.pk %}"
|
||||||
hx-target="#equipment"
|
hx-target="#equipment"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
|
@ -8,6 +10,7 @@
|
||||||
>
|
>
|
||||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
</h5>
|
</h5>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
{% load character_extras %}
|
||||||
<div class="mt-3" id="notes">
|
<div class="mt-3" id="notes">
|
||||||
<h2>
|
<h2>
|
||||||
Notes
|
Notes
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<a hx-get="{% url "character:notes_change" pk=character.pk %}"
|
<a hx-get="{% url "character:notes_change" pk=character.pk %}"
|
||||||
hx-target="#notes"
|
hx-target="#notes"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
|
@ -8,6 +10,7 @@
|
||||||
>
|
>
|
||||||
<i class="fa-solid fa-pen-to-square"></i> Edit
|
<i class="fa-solid fa-pen-to-square"></i> Edit
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
</h2>
|
</h2>
|
||||||
{{ character.get_formatted_notes|safe }}
|
{{ character.get_formatted_notes|safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<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 }})
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<div class="btn-group btn-group-sm">
|
<div class="btn-group btn-group-sm">
|
||||||
<button hx-get="{% url "character:remove_last_in_path" character_pk=character.pk path_pk=path.pk %}"
|
<button hx-get="{% url "character:remove_last_in_path" character_pk=character.pk path_pk=path.pk %}"
|
||||||
hx-target="#paths-and-capabilities"
|
hx-target="#paths-and-capabilities"
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
</button>
|
</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</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,5 +1,7 @@
|
||||||
|
{% load character_extras %}
|
||||||
{% load django_bootstrap5 %}
|
{% load django_bootstrap5 %}
|
||||||
<div id="paths-and-capabilities">
|
<div id="paths-and-capabilities">
|
||||||
|
{% if character|managed_by:user %}
|
||||||
<form>
|
<form>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -18,6 +20,7 @@
|
||||||
</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 %}
|
||||||
|
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-primary">
|
||||||
|
<i class="fa-solid fa-eye"></i> Observer
|
||||||
|
</a>
|
||||||
{% endif %}
|
{% 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