Skip to content
Snippets Groups Projects
Verified Commit 59eb6170 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/56-use-teachers-only-as-fallback-for-course-group-matching' into test-hhg
parents 770064ac b4dd1ad5
No related branches found
No related tags found
No related merge requests found
Pipeline #85507 passed
...@@ -183,5 +183,6 @@ def import_absences( ...@@ -183,5 +183,6 @@ def import_absences(
if a.import_ref_untis and a.import_ref_untis not in existing_absences: if a.import_ref_untis and a.import_ref_untis not in existing_absences:
logger.info("Absence {} deleted".format(a.id)) logger.info("Absence {} deleted".format(a.id))
a.delete() a.delete()
LessonSubstitution.objects.filter(absence_ref_untis=a.import_ref_untis).delete()
return ref, created_substitutions return ref, created_substitutions
...@@ -128,46 +128,49 @@ def import_lessons( ...@@ -128,46 +128,49 @@ def import_lessons(
qs = core_models.Group.objects.filter( qs = core_models.Group.objects.filter(
parent_groups__in=[c.id for c in course_classes], parent_groups__in=[c.id for c in course_classes],
subject_id=subject.id, 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)) ).filter(Q(school_term__isnull=True) | Q(school_term=validity_range.school_term))
if not qs.exists():
logger.warning(" Not matching course group not found")
# Check if found groups match # Check if found groups match
possible_groups = []
course_group = None course_group = None
for found_group in qs: for found_group in qs:
if compare_m2m(course_classes, found_group.parent_groups.all()) and compare_m2m( if compare_m2m(course_classes, found_group.parent_groups.all()) and compare_m2m(
teachers, found_group.owners.all() teachers, found_group.owners.all()
): ):
course_group = found_group possible_groups.append(found_group)
logger.info(
" Course group found by searching by parent groups, " if len(possible_groups) == 1:
"teachers (owners) and subject" course_group = possible_groups[0]
) logger.info(" Course group found by searching by parent groups, and subject")
else:
for found_group in possible_groups:
if compare_m2m(teachers, found_group.owners.all()):
course_group = found_group
logger.info(
" Course group found by searching by parent groups, "
"teachers (owners) and subject"
)
if ( if (
not course_group not course_group
and get_site_preferences()["untis_mysql__course_groups_fuzzy_matching"] and get_site_preferences()["untis_mysql__course_groups_fuzzy_matching"]
): ):
qs = qs.filter(owners__in=[t.id for t in teachers])
if qs.count() != 1: if qs.count() != 1:
logger.warning( logger.warning(
" Course group not found by searching by parent groups, " " Course group not found or more than one found "
"by searching by parent groups, "
"teachers (owners) and subject (fuzzy matching mode)" "teachers (owners) and subject (fuzzy matching mode)"
) )
else: else:
for found_group in qs: course_group = qs.first()
if compare_m2m(teachers, found_group.owners.all()): logger.info(
if course_group: " Course group found by searching by parent groups, "
logger.warning( "teachers (owners) and subject (fuzzy matching mode)"
" More than one course group found " )
"by searching by parent groups, "
"teachers (owners) and subject (fuzzy matching mode)"
)
course_group = None
else:
course_group = found_group
logger.info(
" Course group found by searching by parent groups, "
"teachers (owners) and subject (fuzzy matching mode)"
)
changed = False changed = False
register_data_check = get_site_preferences()[ register_data_check = get_site_preferences()[
......
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