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
88b1c5f2
Verified
Commit
88b1c5f2
authored
2 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Support intersecting terms
parent
255f9d0a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!161
Resolve "Support overlapping terms"
Pipeline
#101222
passed with warnings
2 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.rst
+1
-0
1 addition, 0 deletions
CHANGELOG.rst
aleksis/apps/untis/util/mysql/importers/terms.py
+15
-3
15 additions, 3 deletions
aleksis/apps/untis/util/mysql/importers/terms.py
with
16 additions
and
3 deletions
CHANGELOG.rst
+
1
−
0
View file @
88b1c5f2
...
...
@@ -14,6 +14,7 @@ Fixed
* Importer failed sometimes on progressing absences.
* Exam import failed sometimes when data provided through Untis were incomplete.
* Importer now automatically fixes intersections of terms with previous terms.
`2.3.2`_ - 2022-09-01
---------------------
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/untis/util/mysql/importers/terms.py
+
15
−
3
View file @
88b1c5f2
import
logging
from
datetime
import
date
from
datetime
import
date
,
timedelta
from
typing
import
Dict
,
Optional
from
django.db.models
import
Max
,
OuterRef
,
Q
,
QuerySet
,
Subquery
...
...
@@ -71,7 +71,7 @@ def import_terms(
if
school_id
is
None
:
school_id
=
get_site_preferences
()[
"
untis_mysql__school_id
"
]
qs
=
qs
.
filter
(
school_id
=
school_id
)
qs
=
qs
.
filter
(
school_id
=
school_id
)
.
order_by
(
"
datefrom
"
)
if
version
is
None
:
# Select newest version per term / validity range
...
...
@@ -142,6 +142,7 @@ def import_terms(
school_term
.
date_start
=
date_start
school_term
.
save
()
school_terms
[
school_year_id
]
=
school_term
try
:
validity_range
=
chronos_models
.
ValidityRange
.
objects
.
get
(
...
...
@@ -151,13 +152,24 @@ def import_terms(
except
chronos_models
.
ValidityRange
.
DoesNotExist
:
try
:
validity_range
=
chronos_models
.
ValidityRange
.
objects
.
within_dates
(
date_start
,
date_end
date_start
__gte
=
date_start
,
date_end__lte
=
date_end
).
get
()
logger
.
info
(
"
Validity range found by time.
"
)
except
chronos_models
.
ValidityRange
.
DoesNotExist
:
validity_range
=
chronos_models
.
ValidityRange
()
logger
.
info
(
"
Validity range created newly.
"
)
# In Untis, you can set all the end dates of the terms to the same date
# and despite that, the terms still end if a new one starts.
# If this case occurs, we have to set the end date of the previous term
# to the start date of the next one.
validity_range_with_possible_intersection
=
chronos_models
.
ValidityRange
.
objects
.
filter
(
date_end__gte
=
date_start
,
date_start__lt
=
date_start
).
first
()
if
validity_range_with_possible_intersection
:
validity_range_with_possible_intersection
.
date_end
=
date_start
-
timedelta
(
days
=
1
)
validity_range_with_possible_intersection
.
save
()
validity_range
.
import_ref_untis
=
term_id
validity_range
.
date_start
=
date_start
validity_range
.
date_end
=
date_end
...
...
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