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
d54ba71d
Verified
Commit
d54ba71d
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Wrap the complete import in an atomic revision
parent
7d4ee88f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!80
Wrap the complete import in an atomic revision
Pipeline
#23766
passed
3 years ago
Stage: test
Stage: build
Stage: publish
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.rst
+8
-0
8 additions, 0 deletions
CHANGELOG.rst
aleksis/apps/untis/util/mysql/main.py
+49
-40
49 additions, 40 deletions
aleksis/apps/untis/util/mysql/main.py
with
57 additions
and
40 deletions
CHANGELOG.rst
+
8
−
0
View file @
d54ba71d
...
...
@@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog`_,
and this project adheres to `Semantic Versioning`_.
Unreleased
----------
Changed
~~~~~~~
* Wrap all imports in complete revisions to make it possible to undo them completely and to track changes correctly.
`2.0rc1`_ - 2021-06-23
----------------------
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/util/mysql/main.py
+
49
−
40
View file @
d54ba71d
from
typing
import
Optional
from
django.db
import
transaction
from
django.db.models
import
QuerySet
import
reversion
from
tqdm
import
tqdm
from
aleksis.apps.untis.util.mysql.importers.terms
import
import_terms
...
...
@@ -25,7 +25,6 @@ from .importers.lessons import import_lessons
from
.importers.substitutions
import
import_substitutions
@transaction.atomic
def
untis_import_mysql
(
terms
:
Optional
[
QuerySet
]
=
None
):
# School terms and validity ranges
validity_ref
=
import_terms
(
terms
)
...
...
@@ -33,48 +32,58 @@ def untis_import_mysql(terms: Optional[QuerySet] = None):
for
validity_range
in
tqdm
(
validity_ref
.
values
(),
desc
=
"
Import data for terms
"
,
**
TQDM_DEFAULTS
):
# Common data for Chronos
subjects_ref
=
import_subjects
(
validity_range
)
rooms_ref
=
import_rooms
(
validity_range
)
absence_reasons_ref
=
import_absence_reasons
(
validity_range
)
with
reversion
.
create_revision
(
atomic
=
True
):
reversion
.
set_comment
(
f
"
UNTIS import for validity range
{
validity_range
}
"
)
# Common data for core
teachers_ref
=
import_teachers
(
validity_range
)
classes_ref
=
import_classes
(
validity_range
,
teachers_ref
)
# Common data for Chronos
subjects_ref
=
import_subjects
(
validity_range
)
rooms_ref
=
import_rooms
(
validity_range
)
absence_reasons_ref
=
import_absence_reasons
(
validity_range
)
# Time periods
time_period
s_ref
=
import_t
ime_period
s
(
validity_range
)
break
s_ref
=
import_
break
s
(
validity_range
,
t
ime_period
s_ref
)
# Common data for core
teacher
s_ref
=
import_t
eacher
s
(
validity_range
)
classe
s_ref
=
import_
classe
s
(
validity_range
,
t
eacher
s_ref
)
# Holidays
holidays_ref
=
import_holidays
(
validity_range
)
# Time periods
time_periods_ref
=
import_time_periods
(
validity_range
)
breaks_ref
=
import_breaks
(
validity_range
,
time_periods_ref
)
# Supervision
s
supervision_areas_ref
=
import_supervision_areas
(
validity_range
,
breaks_ref
,
teachers_ref
)
# Holiday
s
holidays_ref
=
import_holidays
(
validity_range
)
# Less
ons
import_lesson
s
(
validity_range
,
time_periods_ref
,
rooms_ref
,
subject
s_ref
,
teachers_ref
,
classes_ref
,
)
# Supervisi
ons
supervision_areas_ref
=
import_supervision_area
s
(
validity_range
,
break
s_ref
,
teachers_ref
)
# Substitutions
import_absences
(
validity_range
,
absence_reasons_ref
,
time_periods_ref
,
teachers_ref
,
classes_ref
,
rooms_ref
,
)
import_substitutions
(
validity_range
,
teachers_ref
,
subjects_ref
,
rooms_ref
,
classes_ref
,
supervision_areas_ref
,
time_periods_ref
,
)
# Lessons
import_lessons
(
validity_range
,
time_periods_ref
,
rooms_ref
,
subjects_ref
,
teachers_ref
,
classes_ref
,
)
# Events
import_events
(
validity_range
,
time_periods_ref
,
teachers_ref
,
classes_ref
,
rooms_ref
)
# Substitutions
import_absences
(
validity_range
,
absence_reasons_ref
,
time_periods_ref
,
teachers_ref
,
classes_ref
,
rooms_ref
,
)
import_substitutions
(
validity_range
,
teachers_ref
,
subjects_ref
,
rooms_ref
,
classes_ref
,
supervision_areas_ref
,
time_periods_ref
,
)
# Events
import_events
(
validity_range
,
time_periods_ref
,
teachers_ref
,
classes_ref
,
rooms_ref
)
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