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
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-Chronos
Commits
3683094f
Commit
3683094f
authored
5 years ago
by
Frank Poetzsch-Heffter
Browse files
Options
Downloads
Plain Diff
Merge branch 'dev-1.1' into feature/several-days-in-one-tex-document-#288
parents
a3ca9ba1
3bcc200e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
biscuit/apps/chronos/pdf.py
+1
-1
1 addition, 1 deletion
biscuit/apps/chronos/pdf.py
biscuit/apps/chronos/views.py
+56
-1
56 additions, 1 deletion
biscuit/apps/chronos/views.py
with
57 additions
and
2 deletions
biscuit/apps/chronos/pdf.py
+
1
−
1
View file @
3683094f
import
os
import
subprocess
import
inspect
# delete this line
from
django.template.loader
import
render_to_string
from
schoolapps.settings
import
BASE_DIR
from
debug.models
import
register_log_with_filename
LOGO_FILENAME
=
os
.
path
.
join
(
BASE_DIR
,
"
static
"
,
"
common
"
,
"
logo.png
"
)
...
...
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/views.py
+
56
−
1
View file @
3683094f
import
datetime
import
os
import
time
import
traceback
from
typing
import
List
from
PyPDF2
import
PdfFileMerger
from
django.contrib.auth.decorators
import
login_required
,
permission_required
...
...
@@ -17,7 +19,7 @@ from timetable.hints import get_all_hints_by_time_period, get_all_hints_by_class
from
timetable.pdf
import
generate_class_tex_header
,
generate_class_tex_body
,
generate_pdf
from
untisconnect.plan
import
get_plan
,
TYPE_TEACHER
,
TYPE_CLASS
,
TYPE_ROOM
,
parse_lesson_times
from
untisconnect.sub
import
get_substitutions_by_date
,
generate_sub_table
,
get_header_information
from
untisconnect.sub
import
get_substitutions_by_date
,
generate_sub_table
,
get_header_information
,
SubRow
from
untisconnect.api
import
*
from
untisconnect.events
import
get_all_events_by_date
from
userinformation
import
UserInformation
...
...
@@ -302,6 +304,55 @@ def get_next_weekday_with_time(date, time):
# SUBSTITUTIONS #
#################
# TODO: Move to own helper file later
def
equal
(
sub_row_1
:
SubRow
,
sub_row_2
:
SubRow
)
->
bool
:
"""
Checks the equality of two sub rows
:param sub_row_1: SubRow 1
:param sub_row_2: SubRow 2
:return: Equality
"""
return
sub_row_1
.
classes
==
sub_row_2
.
classes
and
sub_row_1
.
sub
and
sub_row_2
.
sub
and
\
sub_row_1
.
sub
.
teacher_old
==
sub_row_2
.
sub
.
teacher_old
and
\
sub_row_1
.
sub
.
teacher_new
==
sub_row_2
.
sub
.
teacher_new
and
\
sub_row_1
.
sub
.
subject_old
==
sub_row_2
.
sub
.
subject_old
and
\
sub_row_1
.
sub
.
subject_new
==
sub_row_2
.
sub
.
subject_new
and
\
sub_row_1
.
sub
.
room_old
==
sub_row_2
.
sub
.
room_old
and
\
sub_row_1
.
sub
.
room_new
==
sub_row_2
.
sub
.
room_new
and
\
sub_row_1
.
sub
.
text
==
sub_row_2
.
sub
.
text
def
merge_sub_rows
(
sub_table
:
List
[
SubRow
])
->
List
[
SubRow
]:
"""
Merge equal sub rows with different lesson numbers to one
:param sub_table:
:return:
"""
new_sub_table
=
[]
i
=
0
while
i
<
len
(
sub_table
)
-
1
:
j
=
1
while
equal
(
sub_table
[
i
],
sub_table
[
i
+
j
]):
j
+=
1
if
i
+
j
>
len
(
sub_table
)
-
1
:
break
if
j
>
1
:
new_sub_row
=
sub_table
[
i
]
new_sub_row
.
lesson
=
sub_table
[
i
].
lesson
+
'
-
'
+
sub_table
[
i
+
j
-
1
].
lesson
new_sub_table
.
append
(
new_sub_row
)
else
:
new_sub_table
.
append
(
sub_table
[
i
])
# get last item
if
i
==
len
(
sub_table
)
-
2
:
new_sub_table
.
append
(
sub_table
[
i
+
1
])
break
i
+=
j
return
new_sub_table
def
sub_pdf
(
request
,
plan_date
=
None
):
"""
Show substitutions as PDF for the next weekday (specially for monitors)
"""
...
...
@@ -326,6 +377,7 @@ def sub_pdf(request, plan_date=None):
subs
=
get_substitutions_by_date
(
date
)
sub_table
=
generate_sub_table
(
subs
,
events
)
sub_table
=
merge_sub_rows
(
sub_table
)
# Get header information and hints
header_info
=
get_header_information
(
subs
,
date
,
events
)
...
...
@@ -387,6 +439,9 @@ def substitutions(request, year=None, month=None, day=None):
sub_table
=
generate_sub_table
(
subs
,
events
)
# Merge Subs
sub_table
=
merge_sub_rows
(
sub_table
)
# Get header information and hints
header_info
=
get_header_information
(
subs
,
date
,
events
)
hints
=
list
(
get_all_hints_by_time_period
(
date
,
date
))
...
...
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