diff --git a/src/character/models/character.py b/src/character/models/character.py index 78c790c..b45133e 100644 --- a/src/character/models/character.py +++ b/src/character/models/character.py @@ -3,6 +3,7 @@ from collections.abc import Iterable import markdown from django.db import models +from django.db.models import Q from django.db.models.functions import Lower from django.urls import reverse from django_extensions.db.models import TimeStampedModel @@ -75,7 +76,11 @@ class CharacterManager(models.Manager): class CharacterQuerySet(models.QuerySet): def managed_by(self, user): - return self.filter(player=user) + from party.models import Party + + return self.filter( + Q(player=user) | Q(parties__in=Party.objects.managed_by(user)) + ) def owned_by(self, user): return self.filter(player=user) diff --git a/src/party/models.py b/src/party/models.py index 7e5d5e9..ff072e2 100644 --- a/src/party/models.py +++ b/src/party/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.db.models import Q from django_extensions.db.models import TimeStampedModel from character.models import Character @@ -12,6 +13,12 @@ class PartyQuerySet(models.QuerySet): def played_by(self, user): return self.filter(characters__in=Character.objects.filter(player=user)) + def related_to(self, user): + return self.filter( + Q(game_master=user) + | Q(characters__in=Character.objects.filter(player=user)) + ).distinct() + class PartyManager(UniquelyNamedModelManager): pass diff --git a/src/party/templates/party/party_details.html b/src/party/templates/party/party_details.html new file mode 100644 index 0000000..4dedd0e --- /dev/null +++ b/src/party/templates/party/party_details.html @@ -0,0 +1,21 @@ +{% extends "common/base.html" %} +{% load django_bootstrap5 %} +{% load character_extras %} + +{% block title %}{{ party.name }} · Groupe{% endblock %} + +{% block content %} +
Personnages :
+