Skip to content

Commit

Permalink
fix: certificate download template
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Oct 26, 2023
1 parent a6c2378 commit ad39530
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lms/www/courses/certificate.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

<div>

{% if doc.member == frappe.session.user %}
{% if doc.member == frappe.session.user or is_moderator %}
<div class="">
<a class="btn btn-default btn-sm" target="_blank" href="/api/method/frappe.utils.print_format.download_pdf?doctype=LMS%20Certificate&name={{ doc.name }}&_lang=en">
<a class="btn btn-default btn-sm" target="_blank" href="/api/method/frappe.utils.print_format.download_pdf?doctype=LMS%20Certificate&name={{ doc.name }}&format={{ print_format }}&_lang=en">
{{ _("Download") }}
</a>

Expand Down
3 changes: 3 additions & 0 deletions lms/www/courses/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from frappe import _
from frappe.utils.jinja import render_template
from frappe.utils import get_url
from lms.lms.utils import has_course_moderator_role


def get_context(context):
Expand Down Expand Up @@ -30,12 +31,14 @@ def get_context(context):
"User", context.doc.member, ["full_name", "username"], as_dict=True
)
context.url = f"{get_url()}/courses/{context.course.name}/{context.doc.name}"
context.is_moderator = has_course_moderator_role()

if context.doc.template:
print_format = context.doc.template
else:
print_format = get_print_format()

context.print_format = print_format
template = frappe.db.get_value(
"Print Format", print_format, ["html", "css"], as_dict=True
)
Expand Down

0 comments on commit ad39530

Please sign in to comment.