mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 14:38:03 +01:00
Allow navigating to others characters in party
This commit is contained in:
parent
855a853415
commit
67fcfa633d
3 changed files with 18 additions and 6 deletions
|
@ -7,14 +7,19 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ character.name }}</h1>
|
<h1>{{ character.name }}</h1>
|
||||||
|
<p>
|
||||||
|
Joueur : {{ character.player.get_full_name|default:character.player.username }}
|
||||||
|
</p>
|
||||||
|
{% if party %}
|
||||||
|
<p>
|
||||||
|
Groupe : {{ party }}. Joueurs : {% for other in party.characters.all %}<a href="{% url "character:view" pk=other.pk %}?party={{ party.pk }}">{{ other }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
{% if character|managed_by:user %}
|
{% 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 %}
|
{% endif %}
|
||||||
<p>
|
|
||||||
Joueur : {{ character.player.get_full_name|default:character.player.username }}
|
|
||||||
</p>
|
|
||||||
<p>
|
<p>
|
||||||
{{ character.race.name }} {{ character.profile.name }} niv. {{ character.level }}<br>
|
{{ character.race.name }} {{ character.profile.name }} niv. {{ character.level }}<br>
|
||||||
{{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg (IMC: {{ character.imc|floatformat }})
|
{{ character.get_gender_display }}, {{ character.age }} ans, {{ character.height_m }}m, {{ character.weight }}kg (IMC: {{ character.imc|floatformat }})
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</p>
|
</p>
|
||||||
<div class="btn-group btn-group-sm">
|
<div class="btn-group btn-group-sm">
|
||||||
{% if character.player == user %}
|
{% if character.player == user %}
|
||||||
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-success">
|
<a href="{% url "character:view" pk=character.pk %}{% if party %}?party={{ party.pk }}{% endif %}" class="btn btn-success">
|
||||||
<i class="fa-solid fa-user"></i> Jouer
|
<i class="fa-solid fa-user"></i> Jouer
|
||||||
</a>
|
</a>
|
||||||
{% if party %}
|
{% if party %}
|
||||||
|
@ -42,11 +42,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elif character|managed_by:user %}
|
{% elif character|managed_by:user %}
|
||||||
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-primary">
|
<a href="{% url "character:view" pk=character.pk %}{% if party %}?party={{ party.pk }}{% endif %}" class="btn btn-primary">
|
||||||
<i class="fa-solid fa-cog"></i> Gérer
|
<i class="fa-solid fa-cog"></i> Gérer
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{% url "character:view" pk=character.pk %}" class="btn btn-primary">
|
<a href="{% url "character:view" pk=character.pk %}{% if party %}?party={{ party.pk }}{% endif %}" class="btn btn-primary">
|
||||||
<i class="fa-solid fa-eye"></i> Observer
|
<i class="fa-solid fa-eye"></i> Observer
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -6,6 +6,7 @@ from django_htmx.http import trigger_client_event
|
||||||
from character.forms import AddPathForm, EquipmentForm
|
from character.forms import AddPathForm, EquipmentForm
|
||||||
from character.models import Capability, Character, HarmfulState, Path
|
from character.models import Capability, Character, HarmfulState, Path
|
||||||
from character.templatetags.character_extras import modifier
|
from character.templatetags.character_extras import modifier
|
||||||
|
from party.models import Party
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -38,6 +39,12 @@ def character_view(request, pk: int):
|
||||||
"add_path_form": add_path_form,
|
"add_path_form": add_path_form,
|
||||||
"all_states": HarmfulState.objects.all(),
|
"all_states": HarmfulState.objects.all(),
|
||||||
}
|
}
|
||||||
|
party_pk = request.GET.get("party")
|
||||||
|
if party_pk:
|
||||||
|
context["party"] = get_object_or_404(
|
||||||
|
Party.objects.related_to(request.user).prefetch_related("characters"),
|
||||||
|
pk=party_pk,
|
||||||
|
)
|
||||||
return render(request, "character/character_details.html", context)
|
return render(request, "character/character_details.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue