Add a default `last_topic` to the PrivateUserNode
This commit is contained in:
parent
c4b652c064
commit
6fff84127c
|
|
@ -11,6 +11,7 @@ from graphql_relay import to_global_id
|
|||
from api.types import FailureNode
|
||||
|
||||
from books.models import Module
|
||||
from books.models.topic import Topic
|
||||
from books.schema.nodes import ModuleLevelNode
|
||||
from books.schema.queries import ModuleNode
|
||||
from users.models import SchoolClass, SchoolClassMember, Team, User
|
||||
|
|
@ -104,7 +105,7 @@ class PrivateUserNode(DjangoObjectType):
|
|||
"onboarding_visited",
|
||||
"team",
|
||||
"read_only",
|
||||
"last_module_level"
|
||||
"last_module_level",
|
||||
]
|
||||
interfaces = (relay.Node,)
|
||||
|
||||
|
|
@ -142,6 +143,12 @@ class PrivateUserNode(DjangoObjectType):
|
|||
def resolve_is_teacher(root: User, info):
|
||||
return root.is_teacher()
|
||||
|
||||
@staticmethod
|
||||
def resolve_last_topic(root: User, info):
|
||||
if root.last_topic is not None:
|
||||
return root.last_topic
|
||||
return Topic.objects.first()
|
||||
|
||||
@staticmethod
|
||||
def resolve_school_classes(root: User, info):
|
||||
if root.selected_class is None: # then we don't have any class to return
|
||||
|
|
@ -164,7 +171,6 @@ class PrivateUserNode(DjangoObjectType):
|
|||
return self.team
|
||||
|
||||
|
||||
|
||||
class ClassMemberNode(ObjectType):
|
||||
"""
|
||||
We need to build this ourselves, because we want the active property on the node, because providing it on the
|
||||
|
|
|
|||
Loading…
Reference in New Issue