mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 14:38:03 +01:00
feat: allow players to update party effects (#206)
--------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
92ac0caa33
commit
7f38d60365
4 changed files with 30 additions and 66 deletions
|
@ -3,7 +3,6 @@
|
|||
<div class="card {% if rounds == 0 %}text-bg-secondary{% endif %} effect" data-id="{{ effect.pk }}">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
{% if party.game_master == request.user %}
|
||||
<button
|
||||
hx-get="{% url "party:delete_effect" pk=party.pk effect_pk=effect.pk %}"
|
||||
hx-target="#effects"
|
||||
|
@ -13,7 +12,6 @@
|
|||
>
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
{{ effect.name }}
|
||||
</h5>
|
||||
<h6 class="card-subtitle mb-2 {% if rounds != 0 %}text-muted{% endif %}">
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
id="add-effect"
|
||||
class="btn btn-primary"><i class="fa-solid fa-plus"></i> Ajouter un effet
|
||||
</button>
|
||||
{% if party.game_master == request.user %}
|
||||
<div class="btn-group">
|
||||
<button
|
||||
hx-get="{% url "party:increase_rounds" pk=party.pk %}"
|
||||
|
@ -28,7 +27,6 @@
|
|||
class="btn btn-outline-secondary"><i class="fa-solid fa-minus"></i> tours
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="effects-cards" class="row mt-1 row-cols-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4">
|
||||
{% for effect in party.effects.all %}
|
||||
|
|
|
@ -4,7 +4,6 @@ import pytest
|
|||
from django.urls import reverse
|
||||
from model_bakery import baker
|
||||
from pytest_django.live_server_helper import LiveServer
|
||||
from selenium.common import NoSuchElementException
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.firefox.webdriver import WebDriver
|
||||
from selenium.webdriver.support.select import Select
|
||||
|
@ -285,37 +284,6 @@ def test_gm_can_delete_any_existing_effect(
|
|||
BattleEffect.objects.get(pk=effects[1].pk)
|
||||
|
||||
|
||||
@pytest.mark.django_db()
|
||||
def test_player_cant_change_existing_running_effect(
|
||||
selenium: WebDriver,
|
||||
live_server: LiveServer,
|
||||
):
|
||||
"""Members of the group can only view existing running effects, no update."""
|
||||
user, password = "player", "password"
|
||||
player = User.objects.create_user(user, password=password)
|
||||
character = baker.make(Character, player=player)
|
||||
party = baker.make(Party)
|
||||
party.characters.set([character])
|
||||
effects = baker.make(BattleEffect, _quantity=2, party=party)
|
||||
|
||||
go_to_party(selenium, live_server, party, user, password)
|
||||
effect = effects[0]
|
||||
effect_element = selenium.find_element(
|
||||
By.CSS_SELECTOR,
|
||||
f'.effect[data-id="{effect.pk}"]',
|
||||
)
|
||||
assert effect.name in effect_element.text
|
||||
assert effect.target in effect_element.text
|
||||
assert effect.description in effect_element.text
|
||||
|
||||
with pytest.raises(NoSuchElementException):
|
||||
selenium.find_element(By.CSS_SELECTOR, ".effect .delete")
|
||||
with pytest.raises(NoSuchElementException):
|
||||
selenium.find_element(By.ID, "increase-rounds")
|
||||
with pytest.raises(NoSuchElementException):
|
||||
selenium.find_element(By.ID, "decrease-rounds")
|
||||
|
||||
|
||||
def fill_effect(
|
||||
selenium: WebDriver,
|
||||
name: str,
|
||||
|
|
|
@ -96,7 +96,7 @@ def party_add_effect(request, pk):
|
|||
@require_GET
|
||||
@login_required
|
||||
def party_increase_rounds(request, pk):
|
||||
party = get_object_or_404(Party.objects.managed_by(request.user), pk=pk)
|
||||
party = get_object_or_404(Party.objects.played_or_mastered_by(request.user), pk=pk)
|
||||
party.effects.increase_rounds()
|
||||
return render(request, "party/snippets/effects.html", {"party": party})
|
||||
|
||||
|
@ -104,7 +104,7 @@ def party_increase_rounds(request, pk):
|
|||
@require_GET
|
||||
@login_required
|
||||
def party_decrease_rounds(request, pk):
|
||||
party = get_object_or_404(Party.objects.managed_by(request.user), pk=pk)
|
||||
party = get_object_or_404(Party.objects.played_or_mastered_by(request.user), pk=pk)
|
||||
party.effects.decrease_rounds()
|
||||
return render(request, "party/snippets/effects.html", {"party": party})
|
||||
|
||||
|
@ -112,7 +112,7 @@ def party_decrease_rounds(request, pk):
|
|||
@require_GET
|
||||
@login_required
|
||||
def party_delete_effect(request, pk, effect_pk):
|
||||
party = get_object_or_404(Party.objects.managed_by(request.user), pk=pk)
|
||||
party = get_object_or_404(Party.objects.played_or_mastered_by(request.user), pk=pk)
|
||||
BattleEffect.objects.filter(pk=effect_pk).delete()
|
||||
return render(request, "party/snippets/effects.html", {"party": party})
|
||||
|
||||
|
|
Loading…
Reference in a new issue