Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Resint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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-Resint
Commits
307dd1fb
Verified
Commit
307dd1fb
authored
3 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Port default LiveDocument.update() from Chronos
parent
54dfff3a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!38
Port default LiveDocument.update() from Chronos
Pipeline
#66003
failed
2 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.rst
+2
-0
2 additions, 0 deletions
CHANGELOG.rst
aleksis/apps/resint/models.py
+21
-2
21 additions, 2 deletions
aleksis/apps/resint/models.py
with
23 additions
and
2 deletions
CHANGELOG.rst
+
2
−
0
View file @
307dd1fb
...
...
@@ -13,6 +13,8 @@ Added
~~~~~
* Open poster group menu entries in new tab.
* [Dev] LiveDocument.update() now has a default implementaiton, rendering
``self.template`` using ``self.get_context_data()``
Fixed
~~~~~
...
...
This diff is collapsed.
Click to expand it.
aleksis/apps/resint/models.py
+
21
−
2
View file @
307dd1fb
from
datetime
import
datetime
from
typing
import
Optional
from
typing
import
Any
,
Optional
from
django.core.files
import
File
from
django.core.validators
import
FileExtensionValidator
,
MaxValueValidator
,
MinValueValidator
...
...
@@ -10,9 +10,12 @@ from django.utils.translation import gettext_lazy as _
import
reversion
from
calendarweek
import
CalendarWeek
from
calendarweek.django
import
i18n_day_name_choices_lazy
from
celery.result
import
allow_join_result
from
celery.states
import
SUCCESS
from
reversion.models
import
Revision
,
Version
from
aleksis.core.mixins
import
ExtensibleModel
,
ExtensiblePolymorphicModel
from
aleksis.core.util.pdf
import
generate_pdf_from_template
class
PosterGroup
(
ExtensibleModel
):
...
...
@@ -151,6 +154,8 @@ class LiveDocument(ExtensiblePolymorphicModel):
SCOPE_PREFIX
=
"
live_document_pdf
"
template
=
None
slug
=
models
.
SlugField
(
verbose_name
=
_
(
"
Slug
"
),
help_text
=
_
(
"
This will be used for the name of the current PDF file.
"
),
...
...
@@ -203,12 +208,26 @@ class LiveDocument(ExtensiblePolymorphicModel):
with
reversion
.
create_revision
():
super
().
save
(
*
args
,
**
kwargs
)
def
get_context_data
(
self
)
->
dict
[
str
,
Any
]:
"""
Get context to pass to the PDF template.
"""
return
{}
def
update
(
self
,
triggered_manually
:
bool
=
True
):
"""
Update the file with a new version.
Has to be implemented by subclasses.
"""
raise
NotImplementedError
(
"
Subclasses of LiveDocument must implement update()
"
)
if
not
self
.
template
:
raise
NotImplementedError
(
"
Subclasses of LiveDocument must implement update()
"
)
file_object
,
result
=
generate_pdf_from_template
(
self
.
template
,
self
.
get_context_data
())
with
allow_join_result
():
result
.
wait
()
file_object
.
refresh_from_db
()
if
result
.
status
==
SUCCESS
and
file_object
.
file
:
self
.
last_update_triggered_manually
=
triggered_manually
self
.
current_file
.
save
(
self
.
filename
,
file_object
.
file
.
file
)
self
.
save
()
def
__str__
(
self
)
->
str
:
return
self
.
name
...
...
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