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
151aaf1e
Commit
151aaf1e
authored
6 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Get PDF for weekday [TIMETABLE/SUBSTITUTIONS]
parent
b453e14d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
biscuit/apps/chronos/pdf.py
+3
-2
3 additions, 2 deletions
biscuit/apps/chronos/pdf.py
biscuit/apps/chronos/urls.py
+2
-1
2 additions, 1 deletion
biscuit/apps/chronos/urls.py
biscuit/apps/chronos/views.py
+26
-1
26 additions, 1 deletion
biscuit/apps/chronos/views.py
with
31 additions
and
4 deletions
biscuit/apps/chronos/pdf.py
+
3
−
2
View file @
151aaf1e
import
os
import
subprocess
from
django.utils
import
timezone
...
...
@@ -85,11 +86,11 @@ TEX_HEADER_CLASS = """
def
generate_pdf
(
tex
,
filename
):
tex_file
=
open
(
filename
+
"
.tex
"
,
"
w
"
)
tex_file
=
open
(
os
.
path
.
join
(
"
latex
"
,
filename
+
"
.tex
"
)
,
"
w
"
)
tex_file
.
write
(
tex
)
tex_file
.
close
()
bash_command
=
"
pdflatex {}.tex
"
.
format
(
filename
)
bash_command
=
"
pdflatex
-output-directory latex
{}.tex
"
.
format
(
filename
)
process
=
subprocess
.
Popen
(
bash_command
.
split
(),
stdout
=
subprocess
.
PIPE
)
output
=
process
.
communicate
()[
0
]
# bash_command = "xreader {}.pdf".format(filename)
...
...
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/urls.py
+
2
−
1
View file @
151aaf1e
...
...
@@ -6,5 +6,6 @@ urlpatterns = [
path
(
'
quick/
'
,
views
.
quicklaunch
,
name
=
'
timetable_quicklaunch
'
),
path
(
'
<str:plan_type>/<int:plan_id>/
'
,
views
.
plan
,
name
=
'
timetable_plan
'
),
path
(
'
substitutions/
'
,
views
.
substitutions
,
name
=
'
timetable_substitutions
'
),
path
(
'
substitutions/<int:year>/<int:month>/<int:day>/
'
,
views
.
substitutions
,
name
=
'
timetable_substitutions
'
),
path
(
'
substitutions/<int:year>/<int:month>/<int:day>/
'
,
views
.
substitutions
,
name
=
'
timetable_substitutions_date
'
),
path
(
'
class.pdf
'
,
views
.
sub_pdf
,
name
=
"
timetable_substitutions_pdf
"
)
]
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/views.py
+
26
−
1
View file @
151aaf1e
import
datetime
import
os
from
django.contrib.auth.decorators
import
login_required
from
django.http
import
Http404
from
django.http
import
Http404
,
FileResponse
from
django.shortcuts
import
render
from
timetable.pdf
import
generate_class_tex
,
generate_pdf
...
...
@@ -64,6 +67,28 @@ def plan(request, plan_type, plan_id):
return
render
(
request
,
'
timetable/plan.html
'
,
context
)
def
get_next_weekday
(
date
):
if
date
.
isoweekday
()
in
{
6
,
7
}:
date
+=
datetime
.
timedelta
(
days
=
date
.
isoweekday
()
%
4
)
return
date
@login_required
def
sub_pdf
(
request
):
today
=
timezone
.
datetime
.
now
()
first_day
=
get_next_weekday
(
today
)
subs
=
get_substitutions_by_date
(
first_day
)
sub_table
=
generate_sub_table
(
subs
)
tex
=
generate_class_tex
(
sub_table
,
first_day
)
print
(
first_day
)
print
(
tex
)
generate_pdf
(
tex
,
"
class
"
)
file
=
open
(
os
.
path
.
join
(
"
latex
"
,
"
class.pdf
"
),
"
rb
"
)
return
FileResponse
(
file
,
content_type
=
"
application/pdf
"
)
@login_required
def
substitutions
(
request
,
year
=
None
,
day
=
None
,
month
=
None
):
date
=
timezone
.
datetime
.
now
()
...
...
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