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
f690dc2c
Verified
Commit
f690dc2c
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Use BASE_URL for PDF generation instead of own preference
parent
9b91f38e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!689
Support PDF generation without available request object
Pipeline
#23869
passed
3 years ago
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/core/preferences.py
+0
-15
0 additions, 15 deletions
aleksis/core/preferences.py
aleksis/core/util/pdf.py
+3
-4
3 additions, 4 deletions
aleksis/core/util/pdf.py
with
3 additions
and
19 deletions
aleksis/core/preferences.py
+
0
−
15
View file @
f690dc2c
from
django.conf
import
settings
from
django.core.validators
import
URLValidator
from
django.forms
import
EmailField
,
ImageField
,
URLField
from
django.forms.widgets
import
SelectMultiple
from
django.utils.translation
import
gettext_lazy
as
_
...
...
@@ -53,20 +52,6 @@ class SiteDescription(StringPreference):
verbose_name
=
_
(
"
Site description
"
)
@site_preferences_registry.register
class
PDFURL
(
StringPreference
):
"""
URL which should be used as base for PDF printing.
"""
section
=
general
name
=
"
pdf_url
"
default
=
""
required
=
False
verbose_name
=
_
(
"
PDF URL
"
)
help_text
=
_
(
"
This URL is used for PDF printing.
"
)
field_kwargs
=
{
"
validators
"
:
[
URLValidator
()]}
@site_preferences_registry.register
class
ColourPrimary
(
StringPreference
):
"""
Primary colour in AlekSIS frontend.
"""
...
...
This diff is collapsed.
Click to expand it.
aleksis/core/util/pdf.py
+
3
−
4
View file @
f690dc2c
...
...
@@ -4,6 +4,7 @@ from tempfile import TemporaryDirectory
from
typing
import
Optional
,
Tuple
from
urllib.parse
import
urljoin
from
django.conf
import
settings
from
django.core.files
import
File
from
django.core.files.base
import
ContentFile
from
django.http.request
import
HttpRequest
...
...
@@ -21,7 +22,6 @@ from celery_progress.backend import ProgressRecorder
from
aleksis.core.celery
import
app
from
aleksis.core.models
import
PDFFile
from
aleksis.core.util.celery_progress
import
recorded_task
,
render_progress_page
from
aleksis.core.util.core_helpers
import
get_site_preferences
@recorded_task
...
...
@@ -76,12 +76,11 @@ def generate_pdf_from_template(
file_object
=
PDFFile
.
objects
.
create
(
html_file
=
ContentFile
(
html_template
,
name
=
"
source.html
"
))
# As this method may be run in background and there is no request available,
# we have to use a predefined URL from
preference
s then
# we have to use a predefined URL from
setting
s then
if
request
:
html_url
=
request
.
build_absolute_uri
(
file_object
.
html_file
.
url
)
else
:
pdf_base_url
=
get_site_preferences
()[
"
general__pdf_url
"
]
html_url
=
urljoin
(
pdf_base_url
,
file_object
.
html_file
.
url
)
html_url
=
urljoin
(
settings
.
BASE_URL
,
file_object
.
html_file
.
url
)
result
=
generate_pdf
.
delay
(
file_object
.
pk
,
html_url
,
lang
=
get_language
())
...
...
This diff is collapsed.
Click to expand it.
Jonathan Weth
@hansegucker
mentioned in commit
85f2ce2c
·
3 years ago
mentioned in commit
85f2ce2c
mentioned in commit 85f2ce2c79771be418b94a5ad63003194b6e1f75
Toggle commit list
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