feat: add course session group
This commit is contained in:
parent
61c57c4cb4
commit
c7920430ca
|
|
@ -0,0 +1,21 @@
|
||||||
|
<script setup lang="ts">
|
||||||
|
import * as log from "loglevel";
|
||||||
|
import { useQuery } from "@urql/vue";
|
||||||
|
import { DASH_QUERY } from "@/graphql/queries";
|
||||||
|
|
||||||
|
log.debug("Dash created", DASH_QUERY);
|
||||||
|
const queryResult = useQuery({
|
||||||
|
query: DASH_QUERY,
|
||||||
|
variables: {
|
||||||
|
course_id: "-3",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main class="px-8 py-8">
|
||||||
|
{{ queryResult.data }}
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
|
|
@ -129,6 +129,7 @@ LOCAL_APPS = [
|
||||||
"vbv_lernwelt.duedate",
|
"vbv_lernwelt.duedate",
|
||||||
"vbv_lernwelt.importer",
|
"vbv_lernwelt.importer",
|
||||||
"vbv_lernwelt.edoniq_test",
|
"vbv_lernwelt.edoniq_test",
|
||||||
|
"vbv_lernwelt.course_session_group",
|
||||||
]
|
]
|
||||||
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
|
||||||
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from vbv_lernwelt.course_session_group.models import CourseSessionGroup
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(CourseSessionGroup)
|
||||||
|
class CourseSessionAssignmentAdmin(admin.ModelAdmin):
|
||||||
|
...
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class CourseSessionGroupConfig(AppConfig):
|
||||||
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
|
name = "vbv_lernwelt.course_session_group"
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
import vbv_lernwelt.course_session_group.signals # noqa F401
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Generated by Django 3.2.20 on 2023-10-23 14:53
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("course", "0004_auto_20230823_1744"),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="CourseSessionGroup",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True,
|
||||||
|
primary_key=True,
|
||||||
|
serialize=False,
|
||||||
|
verbose_name="ID",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=255)),
|
||||||
|
(
|
||||||
|
"course",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to="course.course"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"course_session",
|
||||||
|
models.ManyToManyField(blank=True, to="course.CourseSession"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"supervisor",
|
||||||
|
models.ManyToManyField(blank=True, to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"ordering": ["name"],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
from vbv_lernwelt.core.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class CourseSessionGroup(models.Model):
|
||||||
|
name = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
course = models.ForeignKey("course.Course", on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
course_session = models.ManyToManyField(
|
||||||
|
"course.CourseSession",
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
supervisor = models.ManyToManyField(
|
||||||
|
User,
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ["name"]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
|
from django.db.models.signals import m2m_changed
|
||||||
|
from django.dispatch import receiver
|
||||||
|
|
||||||
|
from .models import CourseSessionGroup
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(m2m_changed, sender=CourseSessionGroup.course_session.through)
|
||||||
|
def validate_course(sender, instance, action, reverse, model, pk_set, **kwargs):
|
||||||
|
if action == "pre_add":
|
||||||
|
course_sessions = model.objects.filter(pk__in=pk_set)
|
||||||
|
for session in course_sessions:
|
||||||
|
if session.course != instance.course:
|
||||||
|
raise ValidationError(
|
||||||
|
"CourseSession does not match the Course of this Group."
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
import graphene
|
import graphene
|
||||||
|
|
||||||
from vbv_lernwelt.course.models import (
|
from vbv_lernwelt.course.models import CourseCompletion, CourseCompletionStatus
|
||||||
CourseCompletion,
|
|
||||||
CourseCompletionStatus,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class CompletionSummary(graphene.ObjectType):
|
class CompletionSummary(graphene.ObjectType):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue