Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Untis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Untis
Commits
18be8cdc
Commit
18be8cdc
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Plain Diff
Merge branch '35-disambiguate-long-group-names' into 'master'
Resolve "Disambiguate long group names" Closes
#35
See merge request
!103
parents
7d215d70
c8d01034
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!103
Resolve "Disambiguate long group names"
Pipeline
#46348
canceled
3 years ago
Stage: test
Stage: build
Stage: publish
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.rst
+1
-0
1 addition, 0 deletions
CHANGELOG.rst
aleksis/apps/untis/preferences.py
+8
-0
8 additions, 0 deletions
aleksis/apps/untis/preferences.py
aleksis/apps/untis/util/mysql/importers/common_data.py
+25
-0
25 additions, 0 deletions
aleksis/apps/untis/util/mysql/importers/common_data.py
with
34 additions
and
0 deletions
CHANGELOG.rst
+
1
−
0
View file @
18be8cdc
...
...
@@ -13,6 +13,7 @@ Changed
~~~~~~~
* Wrap all imports in complete revisions to make it possible to undo them completely and to track changes correctly.
* Group names are now optionally disambiguated on collisions in Untis
Fixed
~~~~~
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/preferences.py
+
8
−
0
View file @
18be8cdc
...
...
@@ -48,6 +48,14 @@ class UpdateGroupsName(BooleanPreference):
verbose_name
=
_
(
"
Update name of existing groups
"
)
@site_preferences_registry.register
class
DisambiguateGroupsName
(
BooleanPreference
):
section
=
untis_mysql
name
=
"
disambiguate_groups_name
"
default
=
True
verbose_name
=
_
(
"
Disambiguate name of new groups
"
)
@site_preferences_registry.register
class
OverwriteGroupOwners
(
BooleanPreference
):
section
=
untis_mysql
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/util/mysql/importers/common_data.py
+
25
−
0
View file @
18be8cdc
import
logging
import
re
from
datetime
import
time
from
enum
import
Enum
from
typing
import
Dict
...
...
@@ -191,6 +192,30 @@ def import_classes(
school_term__in
=
[
None
,
validity_range
.
school_term
],
)
except
core_models
.
Group
.
DoesNotExist
:
# Determine collisions of long name
while
core_models
.
Group
.
objects
.
filter
(
name
=
name
,
school_term
=
validity_range
.
school_term
).
exists
():
if
not
get_site_preferences
()[
"
untis_mysql__disambiguate_groups_name
"
]:
# Do not try to disambiguate it not enabled
break
suffix
=
f
"
(
{
short_name
}
)
"
if
name
.
endswith
(
suffix
):
# First try, add a counter
name
=
f
"
{
name
}
(2)
"
else
:
# Second or more tries, determine last counter, if any
match
=
re
.
match
(
r
"
^(.*)(\(\d+\))$
"
,
name
)
if
match
:
# Counter found, increase
prefix
=
match
.
group
(
1
)
counter
=
int
(
match
.
group
(
2
))
+
1
name
=
f
"
{
prefix
}
(
{
counter
}
)
"
else
:
# Counter not found, add one
name
=
f
"
{
name
}
(2)
"
new_group
=
core_models
.
Group
.
objects
.
create
(
short_name
=
short_name
,
name
=
name
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment