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

Merge branch '46-fuzzy-matching-of-course-groups' into 'master'

Resolve "Fuzzy matching of course groups"

Closes #46

See merge request !129
parents 50502d71 7f70d188
No related branches found
No related tags found
1 merge request!129Resolve "Fuzzy matching of course groups"
Pipeline #61096 canceled
......@@ -9,6 +9,12 @@ and this project adheres to `Semantic Versioning`_.
Unreleased
----------
Added
~~~~~
* Add fuzzy matching mode for searching course groups: If no 100 % match is found,
the importer will search a match by a subset of parent groups.
Changed
~~~~~~~
......
......@@ -91,6 +91,15 @@ class UseCourseGroups(BooleanPreference):
)
@site_preferences_registry.register
class CourseGroupsFuzzyMatching(BooleanPreference):
section = untis_mysql
name = "course_groups_fuzzy_matching"
default = False
verbose_name = _("Match course groups by a subset of parent groups if no 100% match is found")
help_text = _("Works only if 'Use course groups' is activated.")
@site_preferences_registry.register
class IgnoreIncompleteSubstitutions(BooleanPreference):
section = untis_mysql
......
......@@ -144,6 +144,34 @@ def import_lessons(
"teachers (owners) and subject"
)
if (
not match
and get_site_preferences()["untis_mysql__course_groups_fuzzy_matching"]
):
if qs.count() != 1:
logger.warning(
" Course group not found by searching by parent groups, "
"teachers (owners) and subject (fuzzy matching mode)"
)
else:
for found_group in qs:
if compare_m2m(teachers, found_group.owners.all()):
if match:
logger.warning(
" More than one course group found "
"by searching by parent groups, "
"teachers (owners) and subject (fuzzy matching mode)"
)
match = False
course_group = None
else:
match = True
course_group = found_group
logger.info(
" Course group found by searching by parent groups, "
"teachers (owners) and subject (fuzzy matching mode)"
)
changed = False
if not match:
# No matching group found
......
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