mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 14:38:03 +01:00
Fix GM can't observe invited character
This commit is contained in:
parent
66afe8265b
commit
0b1b2ceb00
3 changed files with 32 additions and 3 deletions
|
@ -90,7 +90,9 @@ class CharacterQuerySet(models.QuerySet):
|
|||
from party.models import Party
|
||||
|
||||
return self.filter(
|
||||
Q(player=user) | Q(parties__in=Party.objects.related_to(user))
|
||||
Q(player=user)
|
||||
| Q(parties__in=Party.objects.related_to(user))
|
||||
| Q(invites__in=Party.objects.related_to(user))
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -60,11 +60,11 @@
|
|||
</a>
|
||||
{% endif %}
|
||||
{% elif character|managed_by:user %}
|
||||
<a href="{% url "character:view" pk=character.pk %}{% if party %}?party={{ party.pk }}{% endif %}" class="btn btn-primary">
|
||||
<a href="{% url "character:view" pk=character.pk %}{% if party %}?party={{ party.pk }}{% endif %}" class="btn btn-primary manage">
|
||||
<i class="fa-solid fa-cog"></i> Gérer
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{% url "character:view" pk=character.pk %}{% if party %}?party={{ party.pk }}{% endif %}" class="btn btn-primary">
|
||||
<a href="{% url "character:view" pk=character.pk %}{% if party %}?party={{ party.pk }}{% endif %}" class="btn btn-primary observe">
|
||||
<i class="fa-solid fa-eye"></i> Observer
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -37,3 +37,30 @@ def test_add_character_to_existing_group(selenium: WebDriver, live_server: LiveS
|
|||
assert selenium.current_url == live_server.url + reverse("party:list")
|
||||
party.refresh_from_db()
|
||||
assert set(party.invited_characters.all()) == {character}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_gm_observe_invited_character_in_group(
|
||||
selenium: WebDriver, live_server: LiveServer
|
||||
):
|
||||
call_command("loaddata", "initial_data")
|
||||
|
||||
username, password = "gm", "password"
|
||||
gm = User.objects.create_user(username, password=password)
|
||||
player = User.objects.create_user("player")
|
||||
party = baker.make(Party, game_master=gm)
|
||||
character = baker.make(Character, player=player)
|
||||
party.invited_characters.add(character)
|
||||
|
||||
selenium.get(live_server.url)
|
||||
login(selenium, username, password)
|
||||
|
||||
selenium.get(live_server.url + reverse("party:list"))
|
||||
selenium.find_element(
|
||||
By.CSS_SELECTOR, f".party[data-id='{party.pk}'] .access"
|
||||
).click()
|
||||
selenium.find_element(
|
||||
By.CSS_SELECTOR, f".character[data-id='{character.pk}'] .observe"
|
||||
).click()
|
||||
title = selenium.find_element(By.TAG_NAME, "h1").text.strip()
|
||||
assert title == character.name
|
||||
|
|
Loading…
Reference in a new issue