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
a43f2d7b
Verified
Commit
a43f2d7b
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add API view for accessing the PDF file of live documents
parent
b8a68452
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!21
Resolve "Support OAuth2 authentication for LiveDocument PDF view"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/resint/urls.py
+6
-0
6 additions, 0 deletions
aleksis/apps/resint/urls.py
aleksis/apps/resint/views.py
+14
-4
14 additions, 4 deletions
aleksis/apps/resint/views.py
with
20 additions
and
4 deletions
aleksis/apps/resint/urls.py
+
6
−
0
View file @
a43f2d7b
...
...
@@ -5,6 +5,7 @@ from .views import (
LiveDocumentDeleteView
,
LiveDocumentEditView
,
LiveDocumentListView
,
LiveDocumentShowAPIView
,
LiveDocumentShowView
,
PosterCurrentView
,
PosterDeleteView
,
...
...
@@ -42,4 +43,9 @@ urlpatterns = [
path
(
"
live_documents/<str:slug>.pdf
"
,
LiveDocumentShowView
.
as_view
(),
name
=
"
show_live_document
"
,
),
path
(
"
api/live_documents/<str:slug>.pdf
"
,
LiveDocumentShowAPIView
.
as_view
(),
name
=
"
api_show_live_document
"
,
),
]
This diff is collapsed.
Click to expand it.
aleksis/apps/resint/views.py
+
14
−
4
View file @
a43f2d7b
...
...
@@ -15,6 +15,7 @@ from django.views.generic.list import ListView
from
django_tables2
import
SingleTableView
from
guardian.shortcuts
import
get_objects_for_user
from
oauth2_provider.views.mixins
import
ClientProtectedResourceMixin
from
reversion.views
import
RevisionMixin
from
rules.contrib.views
import
PermissionRequiredMixin
...
...
@@ -221,15 +222,24 @@ class LiveDocumentDeleteView(PermissionRequiredMixin, RevisionMixin, AdvancedDel
success_message
=
_
(
"
The live document has been deleted.
"
)
class
LiveDocumentShowView
(
PermissionRequiredMixin
,
SingleObjectMixin
,
View
):
"""
Show the current version of the
live document.
"""
class
LiveDocumentShow
Base
View
(
SingleObjectMixin
,
View
):
"""
Base view for showing
live document
s
.
"""
model
=
LiveDocument
permission_required
=
"
resint.view_livedocument_rule
"
def
get
(
self
,
request
:
HttpRequest
,
*
args
:
Any
,
**
kwargs
:
Any
)
->
FileResponse
:
live_document
=
self
.
get_object
()
file
=
live_document
.
get_current_file
()
if
not
file
:
raise
Http404
return
FileResponse
(
file
.
file
,
content_type
=
"
application/pdf
"
)
return
FileResponse
(
file
,
content_type
=
"
application/pdf
"
)
class
LiveDocumentShowView
(
PermissionRequiredMixin
,
LiveDocumentShowBaseView
):
"""
Show the current version of the live document.
"""
permission_required
=
"
resint.view_livedocument_rule
"
class
LiveDocumentShowAPIView
(
ClientProtectedResourceMixin
,
LiveDocumentShowBaseView
):
"""
Show the current version of the live document in API.
"""
This diff is collapsed.
Click to expand it.
Jonathan Weth
@hansegucker
mentioned in commit
f4d9a990
·
3 years ago
mentioned in commit
f4d9a990
mentioned in commit f4d9a99048117d085ef186f48296c527c5886c00
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