Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
43f604ec
Commit
43f604ec
authored
Jul 22, 2021
by
Matheus Miranda
Browse files
Merge branch 'develop' into 'master'
Create course certification PDF view See merge request
!72
parents
aa9a225a
97ee60c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
courses/certification/views.py
courses/certification/views.py
+29
-0
No files found.
courses/certification/views.py
View file @
43f604ec
...
...
@@ -3,9 +3,12 @@ from rest_framework.response import Response
from
rest_framework.decorators
import
action
from
django.views.generic
import
DetailView
from
django.views.generic.detail
import
SingleObjectMixin
from
django.urls
import
resolve
from
django.http
import
Http404
from
django_renderpdf.views
import
PDFView
from
courses.permissions
import
IsProfessorCoordinatorOrAdminPermissionOrReadOnly
from
courses.certification.serializers
import
(
...
...
@@ -246,3 +249,29 @@ class CourseCertificationDetailView(DetailView):
url_name
=
resolve
(
self
.
request
.
path_info
).
url_name
return
super
().
render_to_response
(
context
,
**
response_kwargs
)
class
CourseCertificationPDFView
(
PDFView
,
SingleObjectMixin
):
model
=
CourseCertification
template_name
=
'certificate.html'
slug_field
=
"link_hash"
serializer_class
=
CourseCertificationSerializer
def
get_context_data
(
self
,
*
args
,
**
kwargs
):
"""Pass some extra context to the template."""
self
.
object
=
self
.
get_object
()
context
=
super
().
get_context_data
(
*
args
,
**
kwargs
)
certificate
=
self
.
object
if
not
certificate
.
course_student
.
can_emmit_receipt
():
raise
Http404
if
certificate
:
context
[
'cert_template'
]
=
CertificateTemplate
.
objects
.
get
(
course
=
certificate
.
course_student
.
course
,
document_type
=
certificate
.
type
,
)
return
context
\ No newline at end of file
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