Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Serhii Horichenko
AlekSIS-App-Chronos
Commits
25e46744
Verified
Commit
25e46744
authored
2 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Show lessons replaced by events as cancelled in all timetables
parent
937800a9
Branches
fix-broken-transparency
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.rst
+2
-0
2 additions, 0 deletions
CHANGELOG.rst
aleksis/apps/chronos/templates/chronos/partials/lesson.html
+8
-3
8 additions, 3 deletions
aleksis/apps/chronos/templates/chronos/partials/lesson.html
aleksis/apps/chronos/util/build.py
+40
-17
40 additions, 17 deletions
aleksis/apps/chronos/util/build.py
with
50 additions
and
20 deletions
CHANGELOG.rst
+
2
−
0
View file @
25e46744
...
...
@@ -24,6 +24,8 @@ Fixed
~~~~~
* Optimize exam model and add reference to exams at extra lessons.
* Lessons weren't shown as cancelled on teacher or room timetables
if events had replaced them.
`2.3`_ - 2022-03-21
-------------------
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/templates/chronos/partials/lesson.html
+
8
−
3
View file @
25e46744
...
...
@@ -5,7 +5,7 @@
{# Display background color only if lesson is not cancelled and it is not the old room #}
{% if not smart %}
{% include "
chronos
/
partials
/
subject_colour.html
"
with
subject=
lesson_period.lesson.subject
%}
{%
elif
not
sub.cancelled
and
not
lesson_period.get_substitution.cancelled_for_teachers
%}
{%
elif
not
sub.cancelled
and
not
lesson_period.get_substitution.cancelled_for_teachers
and
not
lesson_period.replaced_by_event
%}
{%
if
not
type.value =
=
"
room
"
or
lesson_period.room =
=
lesson_period.get_room
or
lesson_period.get_room =
=
el
%}
{%
if
sub
and
sub.subject
%}
{%
include
"
chronos
/
partials
/
subject_colour.html
"
with
subject=
sub.subject
%}
...
...
@@ -17,10 +17,15 @@
{%
endwith
%}
"
{
#
Add
CSS
class
for
sub
when
it
'
s
a
sub
#
}
class=
"{% if lesson_period.get_substitution
and smar
t %}lesson-with-sub{% endif %}"
class=
"{% if
smart %}{% if
lesson_period.get_substitution
or lesson_period.replaced_by_even
t %}lesson-with-sub{% endif
%}{% endif
%}"
>
<p>
{% if lesson_period.get_substitution and smart %}
{% if lesson_period.replaced_by_event and smart %}
{% include "chronos/partials/groups.html" with groups=lesson_period.lesson.groups.all %}
{% include "chronos/partials/subject.html" with subject=lesson_period.lesson.subject %}
<br/>
<span
class=
"badge new green"
>
{% trans "Cancelled due to an event" %}
</span>
{% elif lesson_period.get_substitution and smart %}
{% with sub=lesson_period.get_substitution %}
{# SUBSTITUTION #}
{% if type.value == "room" and lesson_period.room != lesson_period.get_room and lesson_period.get_room != el %}
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/chronos/util/build.py
+
40
−
17
View file @
25e46744
...
...
@@ -119,11 +119,6 @@ def build_timetable(
else
:
events
=
events
.
on_day
(
date_ref
)
if
is_person
:
events
=
events
.
filter_from_person
(
obj
)
else
:
events
=
events
.
filter_from_type
(
type_
,
obj
)
events
=
events
.
only
(
"
id
"
,
"
title
"
,
...
...
@@ -136,8 +131,15 @@ def build_timetable(
"
period_to__weekday
"
,
"
period_to__period
"
,
)
if
is_person
:
events_to_display
=
events
.
filter_from_person
(
obj
)
else
:
events_to_display
=
events
.
filter_from_type
(
type_
,
obj
)
# Sort events in a dict
events_per_period
=
{}
events_for_replacement_per_period
=
{}
for
event
in
events
:
if
is_week
and
event
.
date_start
<
date_ref
[
TimePeriod
.
weekday_min
]:
# If start date not in current week, set weekday and period to min
...
...
@@ -175,16 +177,30 @@ def build_timetable(
period_to
=
TimePeriod
.
period_max
for
period
in
range
(
period_from
,
period_to
+
1
):
if
period
not
in
events_per_period
:
events_per_period
[
period
]
=
{}
if
is_week
else
[]
# The following events are possibly replacing some lesson periods
if
period
not
in
events_for_replacement_per_period
:
events_for_replacement_per_period
[
period
]
=
{}
if
is_week
else
[]
if
is_week
and
weekday
not
in
events_per_period
[
period
]:
events_per_period
[
period
][
weekday
]
=
[]
if
is_week
and
weekday
not
in
events_
for_replacement_
per_period
[
period
]:
events_
for_replacement_
per_period
[
period
][
weekday
]
=
[]
if
not
is_week
:
events_per_period
[
period
].
append
(
event
)
events_
for_replacement_
per_period
[
period
].
append
(
event
)
else
:
events_per_period
[
period
][
weekday
].
append
(
event
)
events_for_replacement_per_period
[
period
][
weekday
].
append
(
event
)
# and the following will be displayed in the timetable
if
event
in
events_to_display
:
if
period
not
in
events_per_period
:
events_per_period
[
period
]
=
{}
if
is_week
else
[]
if
is_week
and
weekday
not
in
events_per_period
[
period
]:
events_per_period
[
period
][
weekday
]
=
[]
if
not
is_week
:
events_per_period
[
period
].
append
(
event
)
else
:
events_per_period
[
period
][
weekday
].
append
(
event
)
if
type_
==
TimetableType
.
TEACHER
:
# Get matching supervisions
...
...
@@ -297,6 +313,11 @@ def build_timetable(
if
period
in
events_per_period
else
[]
)
events_for_replacement_for_this_period
=
(
events_for_replacement_per_period
[
period
].
get
(
weekday
,
[])
if
period
in
events_for_replacement_per_period
else
[]
)
lesson_periods_for_this_period
=
(
lesson_periods_per_period
[
period
].
get
(
weekday
,
[])
if
period
in
lesson_periods_per_period
...
...
@@ -305,19 +326,21 @@ def build_timetable(
# Add lesson periods
if
lesson_periods_for_this_period
:
if
events_for_this_period
:
if
events_for_
replacement_for_
this_period
:
# If there is a event in this period,
# we have to check whether the actual lesson is taking place.
lesson_periods_to_keep
=
[]
for
lesson_period
in
lesson_periods_for_this_period
:
if
not
lesson_period
.
is_replaced_by_event
(
events_for_this_period
,
replaced_by_event
=
lesson_period
.
is_replaced_by_event
(
events_for_
replacement_for_
this_period
,
[
obj
]
if
type_
==
TimetableType
.
GROUP
else
None
,
)
lesson_period
.
replaced_by_event
=
replaced_by_event
if
not
replaced_by_event
or
(
replaced_by_event
and
not
type_
==
TimetableType
.
GROUP
):
lesson_periods_to_keep
.
append
(
lesson_period
)
col
.
append
(
lesson_period
)
col
+=
lesson_periods_to_keep
else
:
col
+=
lesson_periods_for_this_period
...
...
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