Skip to content

Commit

Permalink
interface inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
lukavdplas committed Sep 19, 2024
1 parent f5228a1 commit 83da94d
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 86 deletions.
2 changes: 2 additions & 0 deletions backend/core/types/EntityDescriptionType.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from user.models import User
from user.types.UserType import UserType
from core.types.entity import EntityDescription as EntityDescriptionInterface


class EntityDescriptionType(NamedType, AbstractDjangoObjectType):
Expand All @@ -27,6 +28,7 @@ class Meta:
"page",
"contributors",
] + NamedType.fields()
interfaces = (EntityDescriptionInterface,)

@staticmethod
def resolve_contributors(
Expand Down
1 change: 1 addition & 0 deletions backend/core/types/NamedType.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class NamedType(AbstractDjangoObjectType):
"""

name = graphene.NonNull(graphene.String)
description = graphene.NonNull(graphene.String)

class Meta:
model = Named
Expand Down
2 changes: 1 addition & 1 deletion backend/core/types/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Entity(graphene.Enum):
SPACE = "space"


class EntityInterface(graphene.Interface):
class EntityDescription(graphene.Interface):
id = graphene.NonNull(graphene.ID)
name = graphene.String()
description = graphene.String()
4 changes: 2 additions & 2 deletions backend/event/types/EpisodeAgentType.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

from core.types.DescriptionFieldType import DescriptionFieldType
from event.models import EpisodeAgent
from core.types.entity import Entity, EntityInterface
from core.types.entity import Entity, EntityDescription
from event.types.EpisodeEntityLink import EpisodeEntityLink
from core.types.DescriptionFieldType import SourceMentionEnum

class EpisodeAgentType(DescriptionFieldType, DjangoObjectType):
entity = NonNull(EntityInterface)
entity = NonNull(EntityDescription)
entity_type = NonNull(Entity)

class Meta:
Expand Down
4 changes: 2 additions & 2 deletions backend/event/types/EpisodeEntityLink.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from graphene import ID, NonNull, String, Interface
from core.types.DescriptionFieldType import SourceMentionEnum
from event.types.EpisodeType import EpisodeType
from core.types.entity import Entity, EntityInterface
from core.types.entity import Entity, EntityDescription


class EpisodeEntityLink(Interface):
id = NonNull(ID)
episode = NonNull(EpisodeType)
entity_type = NonNull(Entity)
entity = NonNull(EntityInterface)
entity = NonNull(EntityDescription)
source_mention = NonNull(SourceMentionEnum)
note = String()
4 changes: 2 additions & 2 deletions backend/event/types/EpisodeGiftType.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from graphene import NonNull
from graphene_django import DjangoObjectType

from core.types.entity import Entity, EntityInterface
from core.types.entity import Entity, EntityDescription
from core.types.DescriptionFieldType import DescriptionFieldType, SourceMentionEnum
from event.models import EpisodeGift
from event.types.EpisodeEntityLink import EpisodeEntityLink


class EpisodeGiftType(DescriptionFieldType, DjangoObjectType):
entity = NonNull(EntityInterface)
entity = NonNull(EntityDescription)
entity_type = NonNull(Entity)

class Meta:
Expand Down
4 changes: 2 additions & 2 deletions backend/event/types/EpisodeLetterType.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from graphene_django import DjangoObjectType

from core.types.DescriptionFieldType import DescriptionFieldType, SourceMentionEnum
from core.types.entity import Entity, EntityInterface
from core.types.entity import Entity, EntityDescription
from event.models import EpisodeLetter
from event.types.EpisodeEntityLink import EpisodeEntityLink

class EpisodeLetterType(DescriptionFieldType, DjangoObjectType):
entity = NonNull(EntityInterface)
entity = NonNull(EntityDescription)
entity_type = NonNull(Entity)

class Meta:
Expand Down
4 changes: 2 additions & 2 deletions backend/event/types/EpisodeSpaceType.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from graphene_django import DjangoObjectType

from core.types.DescriptionFieldType import DescriptionFieldType, SourceMentionEnum
from core.types.entity import Entity, EntityInterface
from core.types.entity import Entity, EntityDescription
from event.models import EpisodeSpace
from event.types.EpisodeEntityLink import EpisodeEntityLink

class EpisodeSpaceType(DescriptionFieldType, DjangoObjectType):
entity = NonNull(EntityInterface)
entity = NonNull(EntityDescription)
entity_type = NonNull(Entity)

class Meta:
Expand Down
1 change: 1 addition & 0 deletions backend/event/types/EpisodeType.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Meta:
"letters",
"spaces",
] + EntityDescriptionType.fields()
interfaces = EntityDescriptionType._meta.interfaces

@classmethod
def get_queryset(
Expand Down
3 changes: 1 addition & 2 deletions backend/letter/types/GiftDescriptionType.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from letter.models import GiftCategory, GiftDescription, GiftDescriptionCategory
from letter.types.GiftDescriptionCategoryType import GiftDescriptionCategoryType
from letter.types.GiftCategoryType import GiftCategoryType
from core.types.entity import EntityInterface
from event.types.EpisodeGiftType import EpisodeGiftType
from event.models import EpisodeGift

Expand All @@ -24,7 +23,7 @@ class Meta:
"categories",
"episodes",
] + EntityDescriptionType.fields()
interfaces = (EntityInterface,)
interfaces = EntityDescriptionType._meta.interfaces

@classmethod
def get_queryset(
Expand Down
3 changes: 1 addition & 2 deletions backend/letter/types/LetterDescriptionType.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from letter.models import LetterCategory, LetterDescription, LetterDescriptionCategory
from letter.types.LetterCategoryType import LetterCategoryType
from letter.types.LetterDescriptionCategoryType import LetterDescriptionCategoryType
from core.types.entity import EntityInterface
from event.models import EpisodeLetter
from event.types.EpisodeLetterType import EpisodeLetterType

Expand All @@ -24,7 +23,7 @@ class Meta:
"categories",
"episodes",
] + EntityDescriptionType.fields()
interfaces = (EntityInterface,)
interfaces = EntityDescriptionType._meta.interfaces

@classmethod
def get_queryset(
Expand Down
3 changes: 1 addition & 2 deletions backend/person/types/AgentDescriptionType.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from person.types.PersonReferenceType import PersonReferenceType
from event.types.EpisodeAgentType import EpisodeAgentType
from event.models import EpisodeAgent
from core.types.entity import EntityInterface


class AgentDescriptionType(EntityDescriptionType, DjangoObjectType):
Expand All @@ -31,7 +30,7 @@ class Meta:
"location",
"episodes",
] + EntityDescriptionType.fields()
interfaces = (EntityInterface,)
interfaces = EntityDescriptionType._meta.interfaces

@classmethod
def get_queryset(
Expand Down
3 changes: 1 addition & 2 deletions backend/space/types/SpaceDescriptionType.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from space.types.StructureType import StructureType
from space.types.SettlementFieldType import SettlementFieldType
from space.types.StructureFieldType import StructureFieldType
from core.types.entity import EntityInterface
from event.types.EpisodeSpaceType import EpisodeSpaceType
from event.models import EpisodeSpace

Expand All @@ -41,7 +40,7 @@ class Meta:
"structures",
"episodes",
] + EntityDescriptionType.fields()
interfaces = (EntityInterface,)
interfaces = EntityDescriptionType._meta.interfaces

@classmethod
def get_queryset(
Expand Down
Loading

0 comments on commit 83da94d

Please sign in to comment.