Skip to content
Snippets Groups Projects
Commit ac770879 authored by Julian's avatar Julian
Browse files

Use timetable day preference in frontend

parent 35181bae
No related branches found
No related tags found
1 merge request!385Resolve "Hide days"
......@@ -4,6 +4,7 @@ import TimetableWrapper from "./TimetableWrapper.vue";
<script>
import { DateTime } from "luxon";
import { gqlTimetableDays } from "./timetables.graphql";
export default {
name: "Timetable",
......@@ -12,6 +13,7 @@ export default {
calendarFocus: "",
calendarType: "week",
initialRouteFocusSet: false,
timetableDays: [1, 2, 3, 4, 5],
};
},
methods: {
......@@ -79,6 +81,11 @@ export default {
});
},
},
apollo: {
timetableDays: {
query: gqlTimetableDays,
},
},
};
</script>
......@@ -93,7 +100,7 @@ export default {
]"
:params="{ type: selected.type, id: selected.objId }"
ref="calendarWithControls"
:calendar-days-of-week="[1,2,3,4,5]"
:calendar-days-of-week="timetableDays"
@changeCalendarFocus="setCalendarFocus"
@changeCalendarType="setCalendarType"
@calendarReady="setInnerFocusAndType"
......
......@@ -7,3 +7,7 @@ query gqlAvailableTimetables {
shortName
}
}
query gqlTimetableDays {
timetableDays
}
......@@ -10,6 +10,7 @@ from aleksis.core.schema.base import (
from aleksis.core.schema.group import GroupType
from aleksis.core.schema.person import PersonType
from aleksis.core.schema.room import RoomType
from aleksis.core.util.core_helpers import get_site_preferences, has_person
from ..models import LessonEvent
from ..util.build import build_substitutions_list
......@@ -234,6 +235,7 @@ class Query(graphene.ObjectType):
SubstitutionsForDateType,
date=graphene.Date(),
)
timetable_days = graphene.List(graphene.Int)
def resolve_timetable_teachers(self, info, **kwargs):
return get_teachers(info.context.user)
......@@ -285,6 +287,25 @@ class Query(graphene.ObjectType):
substitutions=[sub["el"] for sub in substitutions],
)
@staticmethod
def resolve_timetable_days(root, info, **kwargs):
first_day = "default"
if has_person(info.context):
first_day = info.context.user.person.preferences["calendar__first_day_of_the_week"]
if first_day == "default":
first_day = get_site_preferences()["calendar__first_day_of_the_week"]
first_day = int(first_day)
days = list(map(str, range(7)))
sorted_days = days[first_day:] + days[:first_day]
allowed_days = get_site_preferences()["chronos__days_in_calendar"]
return list(map(int, filter(lambda d: d in allowed_days, sorted_days)))
class Mutation(graphene.ObjectType):
create_amend_lessons = AmendLessonBatchCreateMutation.Field()
......
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