Fix observe character in group 500

Closes #25
This commit is contained in:
Gabriel Augendre 2022-11-16 15:21:29 +01:00
parent 0b1b2ceb00
commit f8f546679c
2 changed files with 30 additions and 1 deletions

View file

@ -93,7 +93,7 @@ class CharacterQuerySet(models.QuerySet):
Q(player=user) Q(player=user)
| Q(parties__in=Party.objects.related_to(user)) | Q(parties__in=Party.objects.related_to(user))
| Q(invites__in=Party.objects.related_to(user)) | Q(invites__in=Party.objects.related_to(user))
) ).distinct()
DEFAULT_NOTES = """ DEFAULT_NOTES = """

View file

@ -64,3 +64,32 @@ def test_gm_observe_invited_character_in_group(
).click() ).click()
title = selenium.find_element(By.TAG_NAME, "h1").text.strip() title = selenium.find_element(By.TAG_NAME, "h1").text.strip()
assert title == character.name assert title == character.name
@pytest.mark.django_db
def test_gm_observe_invited_character_in_two_groups(
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)
other_party = baker.make(Party, game_master=gm)
character = baker.make(Character, player=player)
party.invited_characters.add(character)
other_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