Skip to content
Snippets Groups Projects
Commit ddbcd9f5 authored by permcu's avatar permcu Committed by Julian
Browse files

Move get_for_coursebook into schema

parent 7b23a6af
No related branches found
No related tags found
1 merge request!360Resolve "Add absence management to course book student dialog"
...@@ -568,46 +568,6 @@ class Documentation(CalendarEvent): ...@@ -568,46 +568,6 @@ class Documentation(CalendarEvent):
return (docs, dummies) return (docs, dummies)
@classmethod
def get_for_coursebook(
cls,
own: bool,
date_start: datetime,
date_end: datetime,
request: HttpRequest,
obj_type: Optional[str] = None,
obj_id: Optional[str] = None,
incomplete: Optional[bool] = False,
) -> list:
"""Get all the documentations for an object and a time frame.
obj_type may be one of TEACHER, GROUP, ROOM, COURSE
"""
# Find all LessonEvents for all Lessons of this Course in this date range
event_params = {
"own": own,
}
if obj_type is not None and obj_id is not None:
event_params.update(
{
"type": obj_type,
"id": obj_id,
}
)
events = LessonEvent.get_single_events(
date_start,
date_end,
request,
event_params,
with_reference_object=True,
)
# Lookup or create documentations and return them all.
docs, dummies = cls.get_documentations_for_events(events, incomplete)
return docs + dummies
class ParticipationStatus(CalendarEvent): class ParticipationStatus(CalendarEvent):
"""A participation or absence record about a single person. """A participation or absence record about a single person.
......
...@@ -63,9 +63,6 @@ class Query(graphene.ObjectType): ...@@ -63,9 +63,6 @@ class Query(graphene.ObjectType):
incomplete=False, incomplete=False,
**kwargs, **kwargs,
): ):
datetime_start = datetime.combine(date_start, datetime.min.time())
datetime_end = datetime.combine(date_end, datetime.max.time())
if ( if (
( (
obj_type == "COURSE" obj_type == "COURSE"
...@@ -88,10 +85,30 @@ class Query(graphene.ObjectType): ...@@ -88,10 +85,30 @@ class Query(graphene.ObjectType):
): ):
raise PermissionDenied() raise PermissionDenied()
return Documentation.get_for_coursebook( # Find all LessonEvents for all Lessons of this Course in this date range
own, datetime_start, datetime_end, info.context, obj_type, obj_id, incomplete event_params = {
"own": own,
}
if obj_type is not None and obj_id is not None:
event_params.update(
{
"type": obj_type,
"id": obj_id,
}
)
events = LessonEvent.get_single_events(
datetime.combine(date_start, datetime.min.time()),
datetime.combine(date_end, datetime.max.time()),
info.context,
event_params,
with_reference_object=True,
) )
# Lookup or create documentations and return them all.
docs, dummies = Documentation.get_documentations_for_events(events, incomplete)
return docs + dummies
@staticmethod @staticmethod
def resolve_groups_by_person(root, info, person=None): def resolve_groups_by_person(root, info, person=None):
if person: if person:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment