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
Merge requests
!77
Resolve "PDF export for timetables"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "PDF export for timetables"
51-pdf-export-for-timetables
into
master
Overview
21
Commits
22
Pipelines
29
Changes
1
Merged
Julian
requested to merge
51-pdf-export-for-timetables
into
master
4 years ago
Overview
2
Commits
22
Pipelines
29
Changes
1
Expand
Closes
#51 (closed)
Edited
3 years ago
by
Lloyd Meins
0
0
Merge request reports
Viewing commit
58efb529
Show latest version
1 file
+
5
−
12
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
58efb529
Use PDF rendering tools from core
· 58efb529
Jonathan Weth
authored
4 years ago
aleksis/apps/chronos/views.py
+
5
−
12
Options
@@ -17,9 +17,9 @@ from django_tables2 import RequestConfig
from
rules.contrib.views
import
permission_required
from
aleksis.core.models
import
Announcement
,
Group
,
Person
from
aleksis.core.settings
import
STATIC_ROOT
from
aleksis.core.util
import
messages
from
aleksis.core.util.core_helpers
import
get_site_preferences
,
has_person
from
aleksis.core.util.pdf
import
render_pdf
from
.forms
import
LessonSubstitutionForm
from
.managers
import
TimetableType
@@ -196,17 +196,10 @@ def timetable(
if
is_print
:
template_name
=
"
chronos/timetable_print.html
"
template
=
get_template
(
template_name
)
html_template
=
render_to_string
(
template_name
,
context
).
replace
(
"
/static
"
,
STATIC_ROOT
)
f
,
path
=
mkstemp
(
"
.html
"
)
print
(
path
)
with
open
(
path
,
"
w
"
)
as
f
:
f
.
write
(
html_template
)
f2
,
path2
=
mkstemp
(
"
.pdf
"
)
subprocess
.
run
([
"
electron-pdf
"
,
path
,
path2
])
file
=
open
(
path2
,
"
rb
"
)
return
FileResponse
(
file
,
content_type
=
"
application/pdf
"
)
context
[
"
back_url
"
]
=
reverse
(
"
timetable_by_week
"
,
args
=
[
type_
.
value
,
pk
,
wanted_week
.
year
,
wanted_week
.
week
],
)
return
render_pdf
(
request
,
template_name
,
context
)
else
:
template_name
=
"
chronos/timetable.html
"
Loading