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
b2614ea4
Verified
Commit
b2614ea4
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fix import of lessons: Check if there are lessons from other terms ending in this term
parent
848a5acf
No related branches found
No related tags found
1 merge request
!13
Resolve "Support import from MySQL"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/untis/util/mysql/importers/lessons.py
+13
-4
13 additions, 4 deletions
aleksis/apps/untis/util/mysql/importers/lessons.py
with
13 additions
and
4 deletions
aleksis/apps/untis/util/mysql/importers/lessons.py
+
13
−
4
View file @
b2614ea4
import
logging
from
datetime
import
timedelta
from
constance
import
config
from
django.utils.translation
import
gettext
as
_
...
...
@@ -28,6 +29,18 @@ def import_lessons(
# Get current term
term
=
get_term
()
date_start
=
untis_date_to_date
(
term
.
datefrom
)
date_end
=
untis_date_to_date
(
term
.
dateto
)
# Get all existing lessons for this term
lessons_in_term
=
chronos_models
.
Lesson
.
objects
.
filter
(
term_untis
=
term
.
term_id
).
values_list
(
"
id
"
,
flat
=
True
)
# Set the end date of all lessons from other terms ending in this term to the day before this term starts
chronos_models
.
Lesson
.
objects
.
filter
(
date_end__gte
=
date_start
).
exclude
(
id__in
=
lessons_in_term
).
update
(
date_end
=
date_start
-
timedelta
(
days
=
1
))
# Lessons
lessons
=
run_default_filter
(
mysql_models
.
Lesson
.
objects
)
...
...
@@ -178,10 +191,6 @@ def import_lessons(
else
:
groups
=
course_classes
# Create new lesson
date_start
=
untis_date_to_date
(
term
.
datefrom
)
date_end
=
untis_date_to_date
(
term
.
dateto
)
# Get old lesson
old_lesson_qs
=
chronos_models
.
Lesson
.
objects
.
filter
(
lesson_id_untis
=
lesson_id
,
element_id_untis
=
i
,
term_untis
=
term
.
term_id
...
...
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