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
7b228c51
Commit
7b228c51
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
[PDF] Remove code to replace static and media URLs with absolute URLs
parent
8bf6e49d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/util/pdf.py
+1
-12
1 addition, 12 deletions
aleksis/core/util/pdf.py
with
1 addition
and
12 deletions
aleksis/core/util/pdf.py
+
1
−
12
View file @
7b228c51
...
...
@@ -3,13 +3,11 @@ import subprocess # noqa
from
tempfile
import
TemporaryDirectory
from
typing
import
Optional
from
django.conf
import
settings
from
django.core.files
import
File
from
django.http.request
import
HttpRequest
from
django.http.response
import
HttpResponse
from
django.shortcuts
import
get_object_or_404
,
render
from
django.template.loader
import
render_to_string
from
django.test
import
override_settings
from
django.urls
import
reverse
from
django.utils
import
timezone
from
django.utils.translation
import
get_language
...
...
@@ -77,16 +75,7 @@ def render_pdf(request: HttpRequest, template_name: str, context: dict = None) -
if
not
context
:
context
=
{}
# Generate absolute URLs for static and media files
static_url
=
settings
.
STATIC_URL
media_url
=
settings
.
MEDIA_URL
if
not
static_url
.
startswith
((
"
http://
"
,
"
https://
"
)):
static_url
=
request
.
build_absolute_uri
(
static_url
)
if
not
media_url
.
startswith
((
"
http://
"
,
"
https://
"
)):
media_url
=
request
.
build_absolute_uri
(
media_url
)
with
override_settings
(
STATIC_URL
=
static_url
,
MEDIA_URL
=
media_url
):
html_template
=
render_to_string
(
template_name
,
context
)
html_template
=
render_to_string
(
template_name
,
context
)
file_object
=
PDFFile
.
objects
.
create
(
person
=
request
.
user
.
person
,
html
=
html_template
)
html_url
=
request
.
build_absolute_uri
(
file_object
.
html_url
)
...
...
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