Skip to content
Snippets Groups Projects
Commit 50502d71 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '45-take-teachers-into-account-when-matching-course-groups' into 'master'

Resolve "Take teachers into account when matching course groups"

Closes #45

See merge request !128
parents 96b25680 8837b4ab
No related branches found
No related tags found
1 merge request!128Resolve "Take teachers into account when matching course groups"
Pipeline #60737 canceled
......@@ -15,6 +15,12 @@ Changed
* Let untis_import_mysql management command default to ``current`` instead of all
to prevent accidental imports of old plans
Fixed
~~~~~
* Search course groups not only by parent groups and subject, but also take
the teachers (group owners) into account
`2.1.3`_ - 2022-02-06
---------------------
......
......@@ -124,20 +124,24 @@ def import_lessons(
# Negative import_ref denotes a course group
group_import_ref = -int("{}{}".format(lesson_id, i))
# Search by parent groups and subject
# Search by parent groups, teachers/owners and subject
qs = core_models.Group.objects.filter(
parent_groups__in=[c.id for c in course_classes],
subject_id=subject.id,
owners__in=[t.id for t in teachers],
).filter(Q(school_term__isnull=True) | Q(school_term=validity_range.school_term))
# Check if found groups match
match = False
for found_group in qs:
if compare_m2m(course_classes, found_group.parent_groups.all()):
if compare_m2m(course_classes, found_group.parent_groups.all()) and compare_m2m(
teachers, found_group.owners.all()
):
match = True
course_group = found_group
logger.info(
" Course group found by searching by parent groups and subject"
" Course group found by searching by parent groups, "
"teachers (owners) and subject"
)
changed = False
......
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