Refactor `attendance_days` to its own field
This commit is contained in:
parent
9ee97ffc55
commit
1d88117d99
|
|
@ -15,7 +15,7 @@ const props = defineProps<{
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const attendanceDay = computed(() => {
|
const attendanceDay = computed(() => {
|
||||||
return courseSessionsStore.findAttendanceDay(props.content.slug);
|
return courseSessionsStore.findAttendanceDay(props.content.id);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,14 +213,12 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function findAttendanceDay(
|
function findAttendanceDay(
|
||||||
contentSlug: string
|
contentId: number
|
||||||
): CourseSessionAttendanceDay | undefined {
|
): CourseSessionAttendanceDay | undefined {
|
||||||
const currentCourseSession = courseSessionForRoute.value;
|
const currentCourseSession = courseSessionForRoute.value;
|
||||||
if (currentCourseSession) {
|
if (currentCourseSession) {
|
||||||
const attendanceDays =
|
return currentCourseSession.attendance_days.find(
|
||||||
currentCourseSession.additional_json_data?.attendanceDays ?? [];
|
(attendanceDay) => attendanceDay.learningContentId === contentId
|
||||||
return attendanceDays.find(
|
|
||||||
(attendanceDay) => attendanceDay.learningContentSlug === contentSlug
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ export interface CircleDocument {
|
||||||
|
|
||||||
// TODO refactor, when a user can manually create these days
|
// TODO refactor, when a user can manually create these days
|
||||||
export interface CourseSessionAttendanceDay {
|
export interface CourseSessionAttendanceDay {
|
||||||
learningContentSlug: string;
|
learningContentId: number;
|
||||||
date: string;
|
date: string;
|
||||||
startTime: string;
|
startTime: string;
|
||||||
endTime: string;
|
endTime: string;
|
||||||
|
|
@ -360,9 +360,7 @@ export interface CourseSession {
|
||||||
competence_url: string;
|
competence_url: string;
|
||||||
course_url: string;
|
course_url: string;
|
||||||
media_library_url: string;
|
media_library_url: string;
|
||||||
additional_json_data: {
|
attendance_days: CourseSessionAttendanceDay[];
|
||||||
attendanceDays?: CourseSessionAttendanceDay[];
|
|
||||||
};
|
|
||||||
documents: CircleDocument[];
|
documents: CircleDocument[];
|
||||||
users: CourseSessionUser[];
|
users: CourseSessionUser[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ from vbv_lernwelt.feedback.creators.create_demo_feedback import create_feedback
|
||||||
from vbv_lernwelt.learnpath.create_vv_new_learning_path import (
|
from vbv_lernwelt.learnpath.create_vv_new_learning_path import (
|
||||||
create_vv_new_learning_path,
|
create_vv_new_learning_path,
|
||||||
)
|
)
|
||||||
from vbv_lernwelt.learnpath.models import Circle
|
from vbv_lernwelt.learnpath.models import Circle, LearningContent
|
||||||
from vbv_lernwelt.media_library.create_default_media_library import (
|
from vbv_lernwelt.media_library.create_default_media_library import (
|
||||||
create_default_media_library,
|
create_default_media_library,
|
||||||
)
|
)
|
||||||
|
|
@ -144,18 +144,18 @@ def create_course_uk_de():
|
||||||
cs = CourseSession.objects.create(
|
cs = CourseSession.objects.create(
|
||||||
course_id=COURSE_UK,
|
course_id=COURSE_UK,
|
||||||
title="Bern 2023 a",
|
title="Bern 2023 a",
|
||||||
additional_json_data={
|
attendance_days=[
|
||||||
"attendanceDays": [
|
{
|
||||||
{
|
"learningContentId": LearningContent.objects.get(
|
||||||
"learningContentSlug": "überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenztag-fahrzeug",
|
slug="überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenztag-fahrzeug"
|
||||||
"date": "2023-09-18",
|
).id,
|
||||||
"startTime": "08:15",
|
"date": "2023-09-18",
|
||||||
"endTime": "17:00",
|
"startTime": "08:15",
|
||||||
"location": "Handelsschule KV Bern, Zimmer 123, Eigerstrasse 16, 3012 Bern",
|
"endTime": "17:00",
|
||||||
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch",
|
"location": "Handelsschule KV Bern, Zimmer 123, Eigerstrasse 16, 3012 Bern",
|
||||||
}
|
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch",
|
||||||
]
|
}
|
||||||
},
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
# figma demo users and data
|
# figma demo users and data
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 3.2.13 on 2023-04-04 06:37
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("course", "0002_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="coursesession",
|
||||||
|
name="attendance_days",
|
||||||
|
field=models.JSONField(blank=True, default=list),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="coursesession",
|
||||||
|
name="additional_json_data",
|
||||||
|
field=models.JSONField(blank=True, default=dict),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -184,7 +184,9 @@ class CourseSession(models.Model):
|
||||||
start_date = models.DateField(null=True, blank=True)
|
start_date = models.DateField(null=True, blank=True)
|
||||||
end_date = models.DateField(null=True, blank=True)
|
end_date = models.DateField(null=True, blank=True)
|
||||||
|
|
||||||
additional_json_data = models.JSONField(default=dict)
|
attendance_days = models.JSONField(default=list, blank=True)
|
||||||
|
|
||||||
|
additional_json_data = models.JSONField(default=dict, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.title}"
|
return f"{self.title}"
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
||||||
"start_date",
|
"start_date",
|
||||||
"end_date",
|
"end_date",
|
||||||
"additional_json_data",
|
"additional_json_data",
|
||||||
|
"attendance_days",
|
||||||
"learning_path_url",
|
"learning_path_url",
|
||||||
"competence_url",
|
"competence_url",
|
||||||
"media_library_url",
|
"media_library_url",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue