Add more course config
This commit is contained in:
parent
e13d72eb8a
commit
d6885f4e7f
|
|
@ -23,6 +23,8 @@ class CourseConfigurationAdmin(admin.ModelAdmin):
|
|||
"enable_circle_documents",
|
||||
"enable_learning_mentor",
|
||||
"enable_competence_certificates",
|
||||
"is_vv",
|
||||
"is_uk",
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
# Generated by Django 3.2.20 on 2024-04-03 09:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
TEST_COURSE_ID = -1
|
||||
|
||||
UK_COURSE_IDS = [
|
||||
-3, # uk-de
|
||||
-6, # uk-training-de
|
||||
-5, # uk-fr
|
||||
-7, # uk-training-fr
|
||||
-8, # uk-it
|
||||
-9, # uk-training-it
|
||||
]
|
||||
|
||||
|
||||
VV_COURSE_IDS = [
|
||||
-4, # vv-de
|
||||
-10, # vv-fr
|
||||
-11, # vv-it
|
||||
-12, # vv-prüfung
|
||||
]
|
||||
|
||||
|
||||
def forward_migration(apps, schema_editor):
|
||||
Course = apps.get_model("course", "Course")
|
||||
CourseConfiguration = apps.get_model("course", "CourseConfiguration")
|
||||
|
||||
for course in Course.objects.all():
|
||||
config, created = CourseConfiguration.objects.get_or_create(
|
||||
course=course,
|
||||
)
|
||||
|
||||
# -> disable unnecessary features
|
||||
if course.id in UK_COURSE_IDS:
|
||||
config.is_uk = True
|
||||
elif course.id in VV_COURSE_IDS:
|
||||
config.is_vv = True
|
||||
|
||||
config.save()
|
||||
|
||||
|
||||
def backward_migration(apps, schema_editor):
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("course", "0007_auto_20240226_1553"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="courseconfiguration",
|
||||
name="is_uk",
|
||||
field=models.BooleanField(default=False, verbose_name="ÜK-Lehrgang"),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="courseconfiguration",
|
||||
name="is_vv",
|
||||
field=models.BooleanField(
|
||||
default=False, verbose_name="Versicherungsvermittler-Lehrgang"
|
||||
),
|
||||
),
|
||||
migrations.RunPython(forward_migration, backward_migration),
|
||||
]
|
||||
|
|
@ -149,7 +149,7 @@ class CourseBasePage(Page):
|
|||
def save(self, clean=True, user=None, log_action=False, **kwargs):
|
||||
slug_changed = False
|
||||
|
||||
if not self.id is None:
|
||||
if self.id is not None:
|
||||
old_record = Page.objects.get(id=self.id).specific
|
||||
if old_record.slug != self.slug:
|
||||
self.set_url_path(self.get_parent())
|
||||
|
|
@ -340,5 +340,8 @@ class CourseConfiguration(models.Model):
|
|||
_("Kompetenzweise ein/aus"), default=True
|
||||
)
|
||||
|
||||
is_vv = models.BooleanField(_("Versicherungsvermittler-Lehrgang"), default=False)
|
||||
is_uk = models.BooleanField(_("ÜK-Lehrgang"), default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f"Course Configuration for '{self.course.title}'"
|
||||
|
|
|
|||
|
|
@ -72,6 +72,16 @@ def get_course_sessions_with_roles_for_user(user: User) -> List[CourseSessionWit
|
|||
def get_dashboard_persons(request):
|
||||
try:
|
||||
course_sessions = get_course_sessions_with_roles_for_user(request.user)
|
||||
|
||||
persons = []
|
||||
for cs in course_sessions:
|
||||
if {"SUPERVISOR", "EXPERT", "MEMBER"} & cs.roles:
|
||||
persons.extend(
|
||||
CourseSessionUser.objects.filter(course_session=cs.id).values(
|
||||
"user"
|
||||
)
|
||||
)
|
||||
|
||||
all_to_serialize = course_sessions
|
||||
|
||||
return Response(
|
||||
|
|
|
|||
Loading…
Reference in New Issue