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
9b940618
Verified
Commit
9b940618
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Import absences related to school term
parent
e2b081dd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!26
Fix lint issues and reformat
,
!24
Resolve "Import school terms and validity ranges"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/untis/util/mysql/importers/events.py
+9
-11
9 additions, 11 deletions
aleksis/apps/untis/util/mysql/importers/events.py
aleksis/apps/untis/util/mysql/main.py
+2
-2
2 additions, 2 deletions
aleksis/apps/untis/util/mysql/main.py
with
11 additions
and
13 deletions
aleksis/apps/untis/util/mysql/importers/events.py
+
9
−
11
View file @
9b940618
import
logging
from
aleksis.apps.chronos.models
import
ValidityRange
from
tqdm
import
tqdm
from
aleksis.apps.chronos
import
models
as
chronos_models
...
...
@@ -10,27 +11,21 @@ from ..util import (
connect_untis_fields
,
get_first_period
,
get_last_period
,
get_term
,
move_weekday_to_range
,
run_default_filter
,
untis_date_to_date
,
untis_date_to_date
,
date_to_untis_date
,
)
logger
=
logging
.
getLogger
(
__name__
)
def
import_events
(
time_periods_ref
,
teachers_ref
,
classes_ref
,
rooms_ref
):
def
import_events
(
validity_range
:
ValidityRange
,
time_periods_ref
,
teachers_ref
,
classes_ref
,
rooms_ref
):
ref
=
{}
# Get term
term
=
get_term
()
term_date_start
=
untis_date_to_date
(
term
.
datefrom
)
term_date_end
=
untis_date_to_date
(
term
.
dateto
)
# Get absences
events
=
(
run_default_filter
(
mysql_models
.
Event
.
objects
,
filter_term
=
False
)
.
filter
(
datefrom__lte
=
term
.
dateto
,
dateto__gte
=
term
.
datefrom
)
run_default_filter
(
validity_range
,
mysql_models
.
Event
.
objects
,
filter_term
=
False
)
.
filter
(
datefrom__lte
=
date_to_untis_date
(
validity_range
.
date_end
),
dateto__gte
=
date_to_untis_date
(
validity_range
.
date_start
)
)
.
order_by
(
"
event_id
"
)
)
...
...
@@ -98,6 +93,7 @@ def import_events(time_periods_ref, teachers_ref, classes_ref, rooms_ref):
"
period_from
"
:
time_period_from
,
"
period_to
"
:
time_period_to
,
"
title
"
:
comment
,
"
school_term
"
:
validity_range
.
school_term
,
},
)
...
...
@@ -111,12 +107,14 @@ def import_events(time_periods_ref, teachers_ref, classes_ref, rooms_ref):
or
new_event
.
period_from
!=
time_period_from
or
new_event
.
period_to
!=
time_period_to
or
new_event
.
title
!=
comment
or
new_event
.
school_term
!=
validity_range
.
school_term
):
new_event
.
date_start
=
date_from
new_event
.
date_end
=
date_to
new_event
.
period_from
=
time_period_from
new_event
.
period_to
=
time_period_to
new_event
.
title
=
comment
new_event
.
school_term
=
validity_range
.
school_term
new_event
.
save
()
logger
.
info
(
"
Time range and title updated
"
)
...
...
@@ -130,7 +128,7 @@ def import_events(time_periods_ref, teachers_ref, classes_ref, rooms_ref):
# Delete all no longer existing events
for
e
in
chronos_models
.
Event
.
objects
.
filter
(
date_start__lte
=
term_
date_start
,
date_end__gte
=
term_
date_end
date_start__lte
=
validity_range
.
date_start
,
date_end__gte
=
validity_range
.
date_end
):
if
e
.
import_ref_untis
and
e
.
import_ref_untis
not
in
existing_events
:
logger
.
info
(
"
Event {} deleted
"
.
format
(
e
.
id
))
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/util/mysql/main.py
+
2
−
2
View file @
9b940618
...
...
@@ -55,5 +55,5 @@ def untis_import_mysql():
validity_range
,
teachers_ref
,
subjects_ref
,
rooms_ref
,
classes_ref
,
supervision_areas_ref
,
time_periods_ref
,
)
# Events
import_events
(
time_periods_ref
,
teachers_ref
,
classes_ref
,
rooms_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