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
f4e61e9f
Commit
f4e61e9f
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Some improvements for events
parent
448035dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biscuit/apps/untis/sub.py
+9
-75
9 additions, 75 deletions
biscuit/apps/untis/sub.py
with
9 additions
and
75 deletions
biscuit/apps/untis/sub.py
+
9
−
75
View file @
f4e61e9f
...
...
@@ -124,7 +124,7 @@ def substitutions_sorter(sub):
"""
# First, sort by class
sort_by
=
""
.
join
(
class_
.
name
for
class_
in
sub
.
classes
)
sort_by
=
sub
.
classes
# If the sub hasn't got a class, then put it to the bottom
if
sort_by
==
""
:
...
...
@@ -146,7 +146,7 @@ class SubRow(object):
self
.
teacher
=
""
self
.
teacher_full
=
""
self
.
teachers
=
[]
# Only for events
self
.
rooms
=
[]
# Only for events
self
.
rooms
=
[]
# Only for events
self
.
absences
=
[]
# Only for events
self
.
subject
=
""
self
.
subject_full
=
""
...
...
@@ -157,63 +157,6 @@ class SubRow(object):
self
.
is_event
=
False
def
generate_teacher_row
(
sub
,
full
=
False
):
teacher
=
""
if
not
sub
.
teacher_old
and
not
sub
.
teacher_new
:
teacher
=
""
elif
sub
.
type
==
1
:
teacher
=
"
<s>{}</s>
"
.
format
(
sub
.
teacher_old
.
shortcode
if
not
full
else
sub
.
teacher_old
.
name
)
elif
sub
.
teacher_new
and
sub
.
teacher_old
:
teacher
=
"
<s>{}</s> → <strong>{}</strong>
"
.
format
(
sub
.
teacher_old
.
shortcode
if
not
full
else
sub
.
teacher_old
.
name
,
sub
.
teacher_new
.
shortcode
if
not
full
else
sub
.
teacher_new
.
name
)
elif
sub
.
teacher_new
and
not
sub
.
teacher_old
:
teacher
=
"
<strong>{}</strong>
"
.
format
(
sub
.
teacher_new
.
shortcode
if
not
full
else
sub
.
teacher_new
.
name
)
elif
sub
.
teacher_old
:
teacher
=
"
<strong>{}</strong>
"
.
format
(
sub
.
teacher_old
.
shortcode
if
not
full
else
sub
.
teacher_old
.
name
)
return
teacher
def
generate_subject_row
(
sub
,
full
=
False
):
if
sub
.
type
==
3
:
subject
=
"
Aufsicht
"
elif
not
sub
.
subject_new
and
not
sub
.
subject_old
:
subject
=
""
elif
sub
.
type
==
1
or
sub
.
type
==
2
:
subject
=
"
<s>{}</s>
"
.
format
(
sub
.
subject_old
.
shortcode
if
not
full
else
sub
.
subject_old
.
name
)
elif
sub
.
subject_new
and
sub
.
subject_old
:
subject
=
"
<s>{}</s> → <strong>{}</strong>
"
.
format
(
sub
.
subject_old
.
shortcode
if
not
full
else
sub
.
subject_old
.
name
,
sub
.
subject_new
.
shortcode
if
not
full
else
sub
.
subject_new
.
name
)
elif
sub
.
subject_new
and
not
sub
.
subject_old
:
subject
=
"
<strong>{}</strong>
"
.
format
(
sub
.
subject_new
.
shortcode
if
not
full
else
sub
.
subject_new
.
name
)
else
:
subject
=
"
<strong>{}</strong>
"
.
format
(
sub
.
subject_old
.
shortcode
if
not
full
else
sub
.
subject_old
.
name
)
return
subject
def
generate_room_row
(
sub
,
full
=
False
):
room
=
""
if
sub
.
type
==
3
:
room
=
sub
.
corridor
.
name
elif
sub
.
type
==
1
or
sub
.
type
==
2
:
pass
elif
sub
.
room_new
and
sub
.
room_old
:
room
=
"
<s>{}</s> → <strong>{}</strong>
"
.
format
(
sub
.
room_old
.
shortcode
if
not
full
else
sub
.
room_old
.
name
,
sub
.
room_new
.
shortcode
if
not
full
else
sub
.
room_new
.
name
)
elif
sub
.
room_new
and
not
sub
.
room_old
:
room
=
sub
.
room_new
.
shortcode
if
not
full
else
sub
.
room_new
.
name
elif
not
sub
.
room_new
and
not
sub
.
room_old
:
pass
else
:
room
=
sub
.
room_old
.
shortcode
if
not
full
else
sub
.
room_old
.
name
return
room
def
generate_sub_table
(
subs
,
events
=
[]):
"""
Parse substitutions and prepare than for displaying in plan
...
...
@@ -244,13 +187,6 @@ def generate_sub_table(subs, events=[]):
# Classes
sub_row
.
classes
=
format_classes
(
sub
.
classes
)
sub_row
.
teacher
=
generate_teacher_row
(
sub
)
sub_row
.
teacher_full
=
generate_teacher_row
(
sub
,
full
=
True
)
sub_row
.
subject
=
generate_subject_row
(
sub
)
sub_row
.
subject_full
=
generate_subject_row
(
sub
,
full
=
True
)
sub_row
.
room
=
generate_room_row
(
sub
)
sub_row
.
room_full
=
generate_room_row
(
sub
,
full
=
True
)
# Hint text
sub_row
.
text
=
sub
.
text
...
...
@@ -270,9 +206,12 @@ def generate_sub_table(subs, events=[]):
sub_row
=
SubRow
()
sub_row
.
is_event
=
True
sub_row
.
classes
=
format_classes
(
event
.
classes
)
if
event
.
from_lesson
!=
event
.
to_lesson
:
sub_row
.
lesson
=
"
{}.-{}.
"
.
format
(
event
.
from_lesson
,
event
.
to_lesson
)
sub_row
.
classes
=
format_classes
(
event
.
classes
)
sub_row
.
teachers
=
event
.
teachers
sub_row
.
rooms
=
event
.
rooms
sub_row
.
rooms
=
event
.
rooms
sub_row
.
absences
=
event
.
absences
sub_row
.
color
=
"
purple
"
...
...
@@ -280,12 +219,7 @@ def generate_sub_table(subs, events=[]):
sub_rows
.
append
(
sub_row
)
def
returnClasses
(
sub_row
):
# print(sub_row.classes, end=" | ")
return
sub_row
.
classes
sub_rows
.
sort
(
key
=
returnClasses
)
sub_rows
.
sort
(
key
=
substitutions_sorter
)
return
sub_rows
...
...
@@ -361,7 +295,7 @@ def get_substitutions_by_date(date):
filter_term
=
False
)
subs
=
row_by_row_helper
(
subs_raw
,
Substitution
)
subs
.
sort
(
key
=
substitutions_sorter
)
#
subs.sort(key=substitutions_sorter)
return
subs
...
...
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