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
d07e75d9
Verified
Commit
d07e75d9
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Improve import process for rooms
parent
3207b91d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!13
Resolve "Support import from MySQL"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/untis/settings.py
+6
-0
6 additions, 0 deletions
aleksis/apps/untis/settings.py
aleksis/apps/untis/util/mysql/importers/common_data.py
+34
-7
34 additions, 7 deletions
aleksis/apps/untis/util/mysql/importers/common_data.py
with
40 additions
and
7 deletions
aleksis/apps/untis/settings.py
+
6
−
0
View file @
d07e75d9
...
...
@@ -48,6 +48,11 @@ CONSTANCE_CONFIG = {
_
(
"
Overwrite existing owners?
"
),
bool
,
),
"
UNTIS_IMPORT_MYSQL_UPDATE_ROOMS_NAME
"
:
(
True
,
_
(
"
Update name of existing rooms?
"
),
bool
,
),
}
CONSTANCE_CONFIG_FIELDSETS
=
{
...
...
@@ -65,5 +70,6 @@ CONSTANCE_CONFIG_FIELDSETS = {
"
UNTIS_IMPORT_MYSQL_UPDATE_GROUPS_SHORT_NAME
"
,
"
UNTIS_IMPORT_MYSQL_UPDATE_GROUPS_NAME
"
,
"
UNTIS_IMPORT_MYSQL_UPDATE_GROUPS_OVERWRITE_OWNERS
"
,
"
UNTIS_IMPORT_MYSQL_UPDATE_ROOMS_NAME
"
,
),
}
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/util/mysql/importers/common_data.py
+
34
−
7
View file @
d07e75d9
...
...
@@ -223,25 +223,52 @@ def import_classes(
def
import_rooms
()
->
Dict
[
int
,
chronos_models
.
Room
]:
"""
Import rooms
"""
rooms_ref
=
{}
ref
=
{}
# Get rooms
rooms
=
run_default_filter
(
mysql_models
.
Room
.
objects
)
for
room
in
rooms
:
if
not
room
.
name
:
raise
Exception
(
"
Short name needed.
"
)
logger
.
error
(
"
Room ID {}: Cannot import room without short name.
"
.
format
(
room
.
room_id
)
)
continue
# Build values
short_name
=
room
.
name
[:
10
]
name
=
room
.
longname
[:
30
]
if
room
.
longname
else
short_name
import_ref
=
room
.
room_id
logger
.
info
(
"
Import room {} …
"
.
format
(
short_name
))
new_room
,
created
=
chronos_models
.
Room
.
objects
.
get_or_create
(
short_name
=
short_name
,
defaults
=
{
"
name
"
:
name
}
short_name
=
short_name
,
defaults
=
{
"
name
"
:
name
,
"
import_ref_untis
"
:
import_ref
}
)
new_room
.
name
=
name
new_room
.
save
()
if
created
:
logger
.
info
(
"
New room created
"
)
changed
=
False
if
config
.
UNTIS_IMPORT_MYSQL_UPDATE_ROOMS_NAME
and
new_room
.
name
!=
name
:
new_room
.
name
=
name
changed
=
True
logger
.
info
(
"
Name updated
"
)
if
new_room
.
import_ref_untis
!=
import_ref
:
new_room
.
import_ref_untis
=
import_ref
changed
=
True
logger
.
info
(
"
Import reference updated
"
)
if
changed
:
new_room
.
save
()
r
ooms_ref
[
room
.
room_id
]
=
new_room
r
ef
[
import_ref
]
=
new_room
return
rooms_
ref
return
ref
def
import_supervision_areas
()
->
Dict
[
int
,
chronos_models
.
SupervisionArea
]:
...
...
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