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(() => {
|
||||
return courseSessionsStore.findAttendanceDay(props.content.slug);
|
||||
return courseSessionsStore.findAttendanceDay(props.content.id);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -213,14 +213,12 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
}
|
||||
|
||||
function findAttendanceDay(
|
||||
contentSlug: string
|
||||
contentId: number
|
||||
): CourseSessionAttendanceDay | undefined {
|
||||
const currentCourseSession = courseSessionForRoute.value;
|
||||
if (currentCourseSession) {
|
||||
const attendanceDays =
|
||||
currentCourseSession.additional_json_data?.attendanceDays ?? [];
|
||||
return attendanceDays.find(
|
||||
(attendanceDay) => attendanceDay.learningContentSlug === contentSlug
|
||||
return currentCourseSession.attendance_days.find(
|
||||
(attendanceDay) => attendanceDay.learningContentId === contentId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ export interface CircleDocument {
|
|||
|
||||
// TODO refactor, when a user can manually create these days
|
||||
export interface CourseSessionAttendanceDay {
|
||||
learningContentSlug: string;
|
||||
learningContentId: number;
|
||||
date: string;
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
|
|
@ -360,9 +360,7 @@ export interface CourseSession {
|
|||
competence_url: string;
|
||||
course_url: string;
|
||||
media_library_url: string;
|
||||
additional_json_data: {
|
||||
attendanceDays?: CourseSessionAttendanceDay[];
|
||||
};
|
||||
attendance_days: CourseSessionAttendanceDay[];
|
||||
documents: CircleDocument[];
|
||||
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 (
|
||||
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 (
|
||||
create_default_media_library,
|
||||
)
|
||||
|
|
@ -144,18 +144,18 @@ def create_course_uk_de():
|
|||
cs = CourseSession.objects.create(
|
||||
course_id=COURSE_UK,
|
||||
title="Bern 2023 a",
|
||||
additional_json_data={
|
||||
"attendanceDays": [
|
||||
{
|
||||
"learningContentSlug": "überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenztag-fahrzeug",
|
||||
"date": "2023-09-18",
|
||||
"startTime": "08:15",
|
||||
"endTime": "17:00",
|
||||
"location": "Handelsschule KV Bern, Zimmer 123, Eigerstrasse 16, 3012 Bern",
|
||||
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch",
|
||||
}
|
||||
]
|
||||
},
|
||||
attendance_days=[
|
||||
{
|
||||
"learningContentId": LearningContent.objects.get(
|
||||
slug="überbetriebliche-kurse-lp-circle-fahrzeug-lc-präsenztag-fahrzeug"
|
||||
).id,
|
||||
"date": "2023-09-18",
|
||||
"startTime": "08:15",
|
||||
"endTime": "17:00",
|
||||
"location": "Handelsschule KV Bern, Zimmer 123, Eigerstrasse 16, 3012 Bern",
|
||||
"trainer": "Roland Grossenbacher, roland.grossenbacher@helvetia.ch",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
# 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)
|
||||
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):
|
||||
return f"{self.title}"
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class CourseSessionSerializer(serializers.ModelSerializer):
|
|||
"start_date",
|
||||
"end_date",
|
||||
"additional_json_data",
|
||||
"attendance_days",
|
||||
"learning_path_url",
|
||||
"competence_url",
|
||||
"media_library_url",
|
||||
|
|
|
|||
Loading…
Reference in New Issue