Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
public-libs
latex-renderer
Commits
29110a77
Commit
29110a77
authored
1 year ago
by
Filip Štamcar
Browse files
Options
Download
Email Patches
Plain Diff
Fix not storing files
parent
7c61bfd1
develop
hr-management-integration
No related merge requests found
Pipeline
#9518
failed with stages
in 1 minute and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
render_latex/views.py
+7
-4
render_latex/views.py
with
7 additions
and
4 deletions
+7
-4
render_latex/views.py
+
7
-
4
View file @
29110a77
...
...
@@ -6,7 +6,7 @@ import tempfile
from
django.conf
import
settings
from
django.core.files
import
File
from
django.http
import
HttpResponse
,
HttpResponseBadRequest
,
HttpResponseServerError
from
django.http
import
FileResponse
,
HttpResponse
,
HttpResponseBadRequest
,
HttpResponseServerError
from
drf_spectacular.utils
import
extend_schema
from
rest_framework
import
parsers
,
viewsets
from
rest_framework.decorators
import
action
...
...
@@ -62,14 +62,17 @@ class LatexViewSet(viewsets.GenericViewSet):
logger
.
warning
(
error
,
exc_info
=
error
)
return
HttpResponseBadRequest
(
"Failed to render uploaded file"
)
# Get the rendered PDF file
output
=
open
(
os
.
path
.
join
(
directory
,
"report.pdf"
),
"rb"
)
filename
=
f
"report-
{
now
.
strftime
(
'%Y-%m-%d-%H-%M-%S'
)
}
.pdf"
# Store result in database
if
settings
.
RENDERER_STORE_FILES
:
filename
=
f
"report-
{
now
.
strftime
(
'%Y-%m-%d-%H-%M-%S'
)
}
.pdf"
document
.
output
.
save
(
filename
,
File
(
open
(
os
.
path
.
join
(
directory
,
"report.pdf"
),
"rb"
)))
document
.
output
.
save
(
filename
,
File
(
output
))
document
.
save
()
# Return the rendered PDF file
response
=
Http
Response
(
document
.
output
,
content_type
=
"application/pdf"
)
response
=
File
Response
(
output
,
content_type
=
"application/pdf"
)
response
[
"Content-Disposition"
]
=
f
'attachment; filename="
{
filename
}
"'
return
response
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help