Skip to content
Snippets Groups Projects
Verified Commit 27d9b58d authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add filter for incomplete documentations

parent ec50cb19
No related branches found
No related tags found
2 merge requests!352Draft: Resolve "Add dialog with each lesson's students",!350Resolve "Add simple course book list"
...@@ -12,32 +12,48 @@ ...@@ -12,32 +12,48 @@
hide-default-footer hide-default-footer
> >
<template #additionalActions="{ attrs, on }"> <template #additionalActions="{ attrs, on }">
<v-autocomplete <div class="d-flex flex-grow-1 justify-end">
:items="selectable" <v-autocomplete
item-text="name" :items="selectable"
clearable item-text="name"
return-object clearable
filled return-object
dense filled
hide-details dense
:placeholder="$t('alsijil.coursebook.filter.filter_for_obj')" hide-details
:loading="selectLoading" :placeholder="$t('alsijil.coursebook.filter.filter_for_obj')"
:value="currentObj" :loading="selectLoading"
@input="changeSelection" :value="currentObj"
@click:clear="changeSelection" @input="changeSelection"
/> @click:clear="changeSelection"
<v-switch class="max-width"
:loading="selectLoading" />
:label="$t('alsijil.coursebook.filter.own')" <div class="ml-6">
:input-value="filterType === 'my'" <v-switch
@change=" :loading="selectLoading"
changeSelection({ :label="$t('alsijil.coursebook.filter.own')"
filterType: $event ? 'my' : 'all', :input-value="filterType === 'my'"
type: objType, @change="
id: objId, changeSelection({
}) filterType: $event ? 'my' : 'all',
" type: objType,
/> id: objId,
})
"
dense
inset
hide-details
/>
<v-switch
:loading="selectLoading"
:label="$t('alsijil.coursebook.filter.missing')"
v-model="incomplete"
dense
inset
hide-details
/>
</div>
</div>
</template> </template>
<template #default="{ items }"> <template #default="{ items }">
<v-list-item <v-list-item
...@@ -140,6 +156,7 @@ export default { ...@@ -140,6 +156,7 @@ export default {
courses: [], courses: [],
dateStart: null, dateStart: null,
dateEnd: null, dateEnd: null,
incomplete: false,
}; };
}, },
apollo: { apollo: {
...@@ -161,6 +178,7 @@ export default { ...@@ -161,6 +178,7 @@ export default {
dateEnd: dateEnd:
this.dateEnd ?? this.dateEnd ??
DateTime.fromISO(this.date).plus({ weeks: 1 }).toISODate(), DateTime.fromISO(this.date).plus({ weeks: 1 }).toISODate(),
incomplete: !!this.incomplete,
}; };
}, },
selectable() { selectable() {
...@@ -282,3 +300,9 @@ export default { ...@@ -282,3 +300,9 @@ export default {
}, },
}; };
</script> </script>
<style>
.max-width {
max-width: 25rem;
}
</style>
...@@ -22,6 +22,7 @@ query documentationsForCoursebook( ...@@ -22,6 +22,7 @@ query documentationsForCoursebook(
$objType: String $objType: String
$dateStart: Date! $dateStart: Date!
$dateEnd: Date! $dateEnd: Date!
$incomplete: Boolean
) { ) {
items: documentationsForCoursebook( items: documentationsForCoursebook(
own: $own own: $own
...@@ -29,6 +30,7 @@ query documentationsForCoursebook( ...@@ -29,6 +30,7 @@ query documentationsForCoursebook(
objType: $objType objType: $objType
dateStart: $dateStart dateStart: $dateStart
dateEnd: $dateEnd dateEnd: $dateEnd
incomplete: $incomplete
) { ) {
id id
course { course {
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
}, },
"filter": { "filter": {
"own": "Nur eigene Stunden anzeigen", "own": "Nur eigene Stunden anzeigen",
"missing": "Nur unvollständige Stunden anzeigen",
"groups": "Gruppen", "groups": "Gruppen",
"courses": "Kurse", "courses": "Kurse",
"filter_for_obj": "Nach Gruppe und Kurs filtern" "filter_for_obj": "Nach Gruppe und Kurs filtern"
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
}, },
"filter": { "filter": {
"own": "Only show own lessons", "own": "Only show own lessons",
"missing": "Only show incomplete lessons",
"groups": "Groups", "groups": "Groups",
"courses": "Courses", "courses": "Courses",
"filter_for_obj": "Filter for group and course" "filter_for_obj": "Filter for group and course"
......
...@@ -534,8 +534,9 @@ class Documentation(CalendarEvent): ...@@ -534,8 +534,9 @@ class Documentation(CalendarEvent):
date_start: datetime, date_start: datetime,
date_end: datetime, date_end: datetime,
request: HttpRequest, request: HttpRequest,
obj_type: Optional[str], obj_type: Optional[str] = None,
obj_id: Optional[str], obj_id: Optional[str] = None,
incomplete: Optional[bool] = False,
) -> list: ) -> list:
"""Get all the documentations for an object and a time frame. """Get all the documentations for an object and a time frame.
...@@ -564,28 +565,35 @@ class Documentation(CalendarEvent): ...@@ -564,28 +565,35 @@ class Documentation(CalendarEvent):
# 2. For each lessonEvent → check if there is a documentation # 2. For each lessonEvent → check if there is a documentation
# if so, add the documentation to a list, if not, create a new one # if so, add the documentation to a list, if not, create a new one
return [ docs = []
( for event in events:
existing_documentations.first() if incomplete and event["STATUS"] == "CANCELLED":
if ( continue
existing_documentations := (
event_reference_obj := event["REFERENCE_OBJECT"] event_reference_obj = event["REFERENCE_OBJECT"]
).documentation.filter( existing_documentations = event_reference_obj.documentation.filter(
datetime_start=event["DTSTART"].dt,
datetime_end=event["DTEND"].dt,
)
if existing_documentations.exists():
doc = existing_documentations.first()
if incomplete and doc.topic:
continue
docs.append(doc)
else:
docs.append(
cls(
pk=f"DUMMY;{event_reference_obj.id};{event['DTSTART'].dt.isoformat()};{event['DTEND'].dt.isoformat()}",
lesson_event=event_reference_obj,
course=event_reference_obj.course,
subject=event_reference_obj.subject,
datetime_start=event["DTSTART"].dt, datetime_start=event["DTSTART"].dt,
datetime_end=event["DTEND"].dt, datetime_end=event["DTEND"].dt,
) )
).exists()
else cls(
pk=f"DUMMY;{event_reference_obj.id};{event['DTSTART'].dt.isoformat()};{event['DTEND'].dt.isoformat()}",
lesson_event=event_reference_obj,
course=event_reference_obj.course,
subject=event_reference_obj.subject,
datetime_start=event["DTSTART"].dt,
datetime_end=event["DTEND"].dt,
) )
)
for event in events return docs
]
class ParticipationStatus(ExtensibleModel): class ParticipationStatus(ExtensibleModel):
......
...@@ -35,6 +35,7 @@ class Query(graphene.ObjectType): ...@@ -35,6 +35,7 @@ class Query(graphene.ObjectType):
obj_id=graphene.ID(required=False), obj_id=graphene.ID(required=False),
date_start=graphene.Date(required=True), date_start=graphene.Date(required=True),
date_end=graphene.Date(required=True), date_end=graphene.Date(required=True),
incomplete=graphene.Boolean(required=False),
) )
groups_by_person = FilterOrderList(GroupType, person=graphene.ID()) groups_by_person = FilterOrderList(GroupType, person=graphene.ID())
...@@ -47,7 +48,15 @@ class Query(graphene.ObjectType): ...@@ -47,7 +48,15 @@ class Query(graphene.ObjectType):
return documentations return documentations
def resolve_documentations_for_coursebook( def resolve_documentations_for_coursebook(
root, info, own, date_start, date_end, obj_type=None, obj_id=None, **kwargs root,
info,
own,
date_start,
date_end,
obj_type=None,
obj_id=None,
incomplete=False,
**kwargs,
): ):
datetime_start = datetime.combine(date_start, datetime.min.time()) datetime_start = datetime.combine(date_start, datetime.min.time())
datetime_end = datetime.combine(date_end, datetime.max.time()) datetime_end = datetime.combine(date_end, datetime.max.time())
...@@ -75,7 +84,7 @@ class Query(graphene.ObjectType): ...@@ -75,7 +84,7 @@ class Query(graphene.ObjectType):
raise PermissionDenied() raise PermissionDenied()
return Documentation.get_for_coursebook( return Documentation.get_for_coursebook(
own, datetime_start, datetime_end, info.context, obj_type, obj_id own, datetime_start, datetime_end, info.context, obj_type, obj_id, incomplete
) )
@staticmethod @staticmethod
......
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