Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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-Core
Commits
875a90d1
Commit
875a90d1
authored
6 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Show two days in PDF (issue
#134
)
parent
9334b0aa
No related branches found
No related tags found
1 merge request
!86
Merge school-apps
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-0
1 addition, 0 deletions
README.md
schoolapps/timetable/views.py
+27
-10
27 additions, 10 deletions
schoolapps/timetable/views.py
with
28 additions
and
10 deletions
README.md
+
1
−
0
View file @
875a90d1
...
...
@@ -49,6 +49,7 @@ pip install django-material
pip install django-filter
pip install django_react_templatetags
pip install kanboard
pip install PyPDF2
```
-
`example_secure_settings.py`
zu
`secure_settings.py`
kopieren und anpassen
...
...
This diff is collapsed.
Click to expand it.
schoolapps/timetable/views.py
+
27
−
10
View file @
875a90d1
import
datetime
import
os
from
PyPDF2
import
PdfFileMerger
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.http
import
Http404
,
FileResponse
from
django.shortcuts
import
render
,
redirect
...
...
@@ -192,18 +193,34 @@ def sub_pdf(request):
# Get the next weekday
today
=
timezone
.
datetime
.
now
()
first_day
=
get_next_weekday
(
today
)
second_day
=
get_next_weekday
(
today
+
datetime
.
timedelta
(
days
=
1
))
print
(
second_day
)
# Get subs and generate table
subs
=
get_substitutions_by_date
(
first_day
)
sub_table
=
generate_sub_table
(
subs
)
header_info
=
get_header_information
(
subs
)
# print(header_info.affected_teachers)
# Generate LaTeX
tex
=
generate_class_tex
(
sub_table
,
first_day
,
header_info
)
# Generate PDF
generate_pdf
(
tex
,
"
class
"
)
for
i
,
day
in
enumerate
([
first_day
,
second_day
]):
print
(
i
,
day
)
subs
=
get_substitutions_by_date
(
day
)
sub_table
=
generate_sub_table
(
subs
)
header_info
=
get_header_information
(
subs
)
# print(header_info.affected_teachers)
# Generate LaTeX
tex
=
generate_class_tex
(
sub_table
,
day
,
header_info
)
# Generate PDF
generate_pdf
(
tex
,
"
class{}
"
.
format
(
i
))
# Merge PDFs
merger
=
PdfFileMerger
()
class0
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class0.pdf
"
),
"
rb
"
)
class1
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class1.pdf
"
),
"
rb
"
)
merger
.
append
(
fileobj
=
class0
)
merger
.
append
(
fileobj
=
class1
)
# Write merged PDF to class.pdf
output
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class.pdf
"
),
"
wb
"
)
merger
.
write
(
output
)
output
.
close
()
# Read and response PDF
file
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class.pdf
"
),
"
rb
"
)
...
...
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