fix: certificate custom and style
This commit is contained in:
@@ -5,18 +5,23 @@
|
||||
<div class="common-page-style">
|
||||
<div class="container certificate-page">
|
||||
|
||||
{% if certificate.member == frappe.session.user %}
|
||||
<!-- {% if certificate.member == frappe.session.user %}
|
||||
<div class="button is-secondary pull-right mt-4" id="export-as-pdf" data-certificate="{{ certificate.name }}"
|
||||
data-certificate-name="{{ member.full_name }} - {{ course.title }}">{{ _("Export") }}</div>
|
||||
{% endif %}
|
||||
{% endif %} -->
|
||||
|
||||
<div class="breadcrumb">
|
||||
<a class="dark-links" href="/courses">{{ _("All Courses") }}</a>
|
||||
<img class="ml-1 mr-1" src="/assets/lms/icons/chevron-right.svg">
|
||||
<a class="dark-links" href="/courses/{{ course.name }}">{{ course.title }}</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% if custom_template %}
|
||||
{{ custom_template }}
|
||||
{% else %}
|
||||
{% include "lms/templates/certificate.html" %}
|
||||
{% endif %}
|
||||
<script src="/assets/lms/js/html2canvas.js"></script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
frappe.ready(() => {
|
||||
|
||||
$("#export-as-pdf").click((e) => {
|
||||
export_as_pdf(e);
|
||||
})
|
||||
$("#export-as-pdf").click((e) => {
|
||||
export_as_pdf(e);
|
||||
})
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
var export_as_pdf = (e) => {
|
||||
var button = $(e.currentTarget);
|
||||
button.text(__("Exporting..."));
|
||||
const export_as_pdf = (e) => {
|
||||
let button = $(e.currentTarget);
|
||||
button.text(__("Exporting..."));
|
||||
|
||||
html2canvas(document.querySelector('.common-card-style'), {
|
||||
html2canvas(document.querySelector('.certificate-card'), {
|
||||
scrollY: -window.scrollY,
|
||||
scrollX: 0
|
||||
}).then(function(canvas) {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import frappe
|
||||
from frappe.utils.jinja import render_template
|
||||
from lms.lms.utils import get_instructors
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -15,16 +17,15 @@ def get_context(context):
|
||||
if context.certificate.course != course_name:
|
||||
redirect_to_course_list()
|
||||
|
||||
context.course = frappe.db.get_value("LMS Course", course_name,
|
||||
["instructor", "title", "name"], as_dict=True)
|
||||
|
||||
context.instructor = frappe.db.get_value("User", context.course.instructor,
|
||||
["full_name", "username"], as_dict=True)
|
||||
|
||||
context.course = frappe.db.get_value("LMS Course", course_name, ["title", "name"], as_dict=True)
|
||||
context.instructors = (", ").join([x.full_name for x in get_instructors(course_name)])
|
||||
context.member = frappe.db.get_value("User", context.certificate.member,
|
||||
["full_name"], as_dict=True)
|
||||
|
||||
context.logo = frappe.db.get_single_value("Website Settings", "banner_image")
|
||||
template_name = frappe.db.get_single_value("LMS Settings", "custom_certificate_template")
|
||||
context.custom_certificate_template = frappe.db.get_value("Web Template", template_name, "template")
|
||||
context.custom_template = render_template(context.custom_certificate_template, context)
|
||||
|
||||
def redirect_to_course_list():
|
||||
frappe.local.flags.redirect_location = "/courses"
|
||||
|
||||
Reference in New Issue
Block a user