Merge branch 'main' of https://github.com/frappe/lms into new-design-system
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "body",
|
||||
"fieldtype": "Text Editor",
|
||||
"fieldtype": "Markdown Editor",
|
||||
"ignore_xss_filter": 1,
|
||||
"label": "Body",
|
||||
"reqd": 1
|
||||
@@ -135,7 +135,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2023-04-05 12:42:16.926753",
|
||||
"modified": "2023-05-02 12:42:16.926753",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Course Lesson",
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"links": [],
|
||||
"modified": "2022-04-06 11:49:36.077370",
|
||||
"modified": "2023-04-14 12:33:37.839625",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Certificate",
|
||||
|
||||
@@ -5,8 +5,6 @@ import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import add_years, nowdate
|
||||
from frappe.utils.pdf import get_pdf
|
||||
|
||||
from lms.lms.utils import is_certified
|
||||
|
||||
|
||||
@@ -47,10 +45,3 @@ def create_certificate(course):
|
||||
)
|
||||
certificate.save(ignore_permissions=True)
|
||||
return certificate
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_certificate_pdf(html):
|
||||
frappe.local.response.filename = "certificate.pdf"
|
||||
frappe.local.response.filecontent = get_pdf(html, {"orientation": "LandScape"})
|
||||
frappe.local.response.type = "pdf"
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text Editor",
|
||||
"fieldtype": "Markdown Editor",
|
||||
"label": "Description",
|
||||
"reqd": 1
|
||||
},
|
||||
@@ -260,7 +260,7 @@
|
||||
}
|
||||
],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2023-02-23 09:45:54.826328",
|
||||
"modified": "2023-05-02 09:45:54.826328",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Course",
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
"search_placeholder",
|
||||
"portal_course_creation",
|
||||
"column_break_2",
|
||||
"custom_certificate_template",
|
||||
"livecode_url",
|
||||
"signup_settings_tab",
|
||||
"signup_settings_section",
|
||||
@@ -139,12 +138,6 @@
|
||||
"fieldtype": "Check",
|
||||
"label": "Ask User Category during Signup"
|
||||
},
|
||||
{
|
||||
"fieldname": "custom_certificate_template",
|
||||
"fieldtype": "Link",
|
||||
"label": "Custom Certificate Template",
|
||||
"options": "Web Template"
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "is_onboarding_complete",
|
||||
@@ -192,7 +185,7 @@
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2023-02-23 10:39:38.912549",
|
||||
"modified": "2023-04-17 12:54:44.706101",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
0
lms/lms/print_format/__init__.py
Normal file
0
lms/lms/print_format/__init__.py
Normal file
0
lms/lms/print_format/certificate/__init__.py
Normal file
0
lms/lms/print_format/certificate/__init__.py
Normal file
32
lms/lms/print_format/certificate/certificate.json
Normal file
32
lms/lms/print_format/certificate/certificate.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"absolute_value": 0,
|
||||
"align_labels_right": 0,
|
||||
"creation": "2023-02-22 21:36:54.560420",
|
||||
"css": ".outer-border {\n font-family: \"Inter\" sans-serif;\n font-size: 16px;\n border-radius: 0.5rem;\n border: 1px solid #E2E6E9;\n padding: 1rem;\n}\n\n.inner-border {\n border: 10px solid #0089FF;\n border-radius: 8px;\n text-align: center;\n padding: 6rem 4rem;\n background-color: #FFFFFF;\n}\n\n.certificate-logo {\n height: 1.5rem;\n margin-bottom: 4rem;\n}\n\n.certificate-name {\n font-size: 2rem;\n font-weight: 500;\n color: #192734;\n margin-bottom: 0.5rem;\n}\n\n.certificate-footer {\n margin: 4rem auto 0;\n width: 70%;\n text-align: center;\n}\n\n.certificate-footer-item {\n color: #192734;\n}\n\n.cursive-font {\n font-family: cursive;\n font-weight: 600;\n}\n\n.certificate-divider {\n margin: 0.5rem 0;\n}\n\n.certificate-expiry {\n margin-left: 2rem;\n}",
|
||||
"custom_format": 1,
|
||||
"disabled": 0,
|
||||
"doc_type": "LMS Certificate",
|
||||
"docstatus": 0,
|
||||
"doctype": "Print Format",
|
||||
"font_size": 14,
|
||||
"format_data": "{\"header\":\"<div class=\\\"document-header\\\">\\n\\t<h3>LMS Certificate</h3>\\n\\t<p>{{ doc.name }}</p>\\n</div>\",\"sections\":[{\"label\":\"\",\"columns\":[{\"label\":\"\",\"fields\":[{\"label\":\"Course\",\"fieldname\":\"course\",\"fieldtype\":\"Link\",\"options\":\"LMS Course\"},{\"label\":\"Member\",\"fieldname\":\"member\",\"fieldtype\":\"Link\",\"options\":\"User\"},{\"label\":\"Member Name\",\"fieldname\":\"member_name\",\"fieldtype\":\"Data\"},{\"label\":\"Evaluator\",\"fieldname\":\"evaluator\",\"fieldtype\":\"Data\",\"options\":\"\"}]},{\"label\":\"\",\"fields\":[{\"label\":\"Issue Date\",\"fieldname\":\"issue_date\",\"fieldtype\":\"Date\"},{\"label\":\"Expiry Date\",\"fieldname\":\"expiry_date\",\"fieldtype\":\"Date\"},{\"label\":\"Version\",\"fieldname\":\"version\",\"fieldtype\":\"Select\",\"options\":\"V13\\nV14\"},{\"label\":\"Module Names for Certificate\",\"fieldname\":\"module_names_for_certificate\",\"fieldtype\":\"Data\"}]}],\"has_fields\":true}]}",
|
||||
"html": "{% set certificate = frappe.db.get_value(\"LMS Certificate\", doc.name, [\"name\", \"member\", \"issue_date\", \"expiry_date\", \"course\"], as_dict=True) %}\n{% set member = frappe.db.get_value(\"User\", doc.member, [\"full_name\"], as_dict=True) %}\n{% set course = frappe.db.get_value(\"LMS Course\", doc.course, [\"title\", \"name\", \"image\"], as_dict=True) %}\n{% set logo = frappe.db.get_single_value(\"Website Settings\", \"banner_image\") %}\n{% set instructors = frappe.get_all(\"Course Instructor\", {\"parent\": doc.course}, pluck=\"instructor\", order_by=\"idx\") %}\n\n<meta name=\"pdfkit-orientation\" content=\"Landscape\">\n<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\n<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\n<link href=\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap\" rel=\"stylesheet\">\n\n<div class=\"outer-border\">\n <div class=\"inner-border\">\n \n <img src=\"{{ logo }}\" class=\"certificate-logo\">\n <div>\n {{ _(\"This certifies that\") }}\n </div>\n \n <div class=\"certificate-name\" style=\"\">\n {{ member.full_name }}\n </div>\n <div>\n {{ _(\"has successfully completed the course on\") }}\n <b> {{ course.title }} </b>\n on {{ frappe.utils.format_date(certificate.issue_date, \"medium\") }}.\n </div>\n \n <table class=\"certificate-footer\">\n <tr>\n {% if instructors %}\n <td>\n <div class=\"certificate-footer-item cursive-font\">\n {% for i in instructors %}\n \t\t\t\t\t{{ frappe.db.get_value(\"User\", i, \"full_name\") }}\n \t\t\t\t\t{% if not loop.last %}\n \t\t\t\t\t,\n \t\t\t\t\t{% endif %}\n \t\t\t\t\t{% endfor %}\n </div>\n <hr class=\"certificate-divider\">\n <div class=\"text-center\"> {{ _(\"Course Instructor\") }} </div>\n </td>\n {% endif %}\n \n {% if certificate.expiry_date %}\n <td style=\"width: 30%\"></td>\n \n <td class=\"certificate-expiry\">\n <div class=\"certificate-footer-item\">\n {{ frappe.utils.format_date(certificate.expiry_date, \"medium\") }}\n </div>\n <hr class=\"certificate-divider\">\n <div class=\"text-center\"> {{ _(\"Expiry Date\") }} </div>\n </td>\n {% endif %}\n </tr>\n </table>\n </div>\n </div>",
|
||||
"idx": 0,
|
||||
"line_breaks": 0,
|
||||
"margin_bottom": 0.0,
|
||||
"margin_left": 0.0,
|
||||
"margin_right": 0.0,
|
||||
"margin_top": 0.0,
|
||||
"modified": "2023-04-17 13:46:38.633751",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "Certificate",
|
||||
"owner": "Administrator",
|
||||
"page_number": "Hide",
|
||||
"print_format_builder": 0,
|
||||
"print_format_builder_beta": 1,
|
||||
"print_format_type": "Jinja",
|
||||
"raw_printing": 0,
|
||||
"show_section_headings": 0,
|
||||
"standard": "Yes"
|
||||
}
|
||||
@@ -50,6 +50,6 @@ lms.patches.v0_0.video_embed_link
|
||||
lms.patches.v0_0.rename_exercise_doctype
|
||||
lms.patches.v0_0.add_question_type #09-04-2023
|
||||
lms.patches.v0_0.add_evaluator_to_assignment #09-04-2023
|
||||
lms.patches.v0_0.convert_lesson_markdown_to_html #05-04-2023
|
||||
lms.patches.v0_0.convert_course_description_to_html
|
||||
lms.patches.v0_0.share_certificates
|
||||
execute:frappe.delete_doc("Web Form", "class", ignore_missing=True, force=True)
|
||||
lms.patches.v0_0.amend_course_and_lesson_editor_fields
|
||||
|
||||
37
lms/patches/v0_0/amend_course_and_lesson_editor_fields.py
Normal file
37
lms/patches/v0_0/amend_course_and_lesson_editor_fields.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import frappe
|
||||
from frappe.utils import to_markdown
|
||||
|
||||
|
||||
def execute():
|
||||
amend_lesson_content()
|
||||
amend_course_description()
|
||||
|
||||
|
||||
def amend_lesson_content():
|
||||
lesson_content_field = frappe.db.get_value(
|
||||
"DocField", {"parent": "Course Lesson", "fieldname": "body"}, "fieldtype"
|
||||
)
|
||||
|
||||
if lesson_content_field == "Text Editor":
|
||||
lessons = frappe.get_all("Course Lesson", fields=["name", "body"])
|
||||
|
||||
for lesson in lessons:
|
||||
frappe.db.set_value("Course Lesson", lesson.name, "body", to_markdown(lesson.body))
|
||||
|
||||
frappe.reload_doc("lms", "doctype", "course_lesson")
|
||||
|
||||
|
||||
def amend_course_description():
|
||||
course_description_field = frappe.db.get_value(
|
||||
"DocField", {"parent": "LMS Course", "fieldname": "description"}, "fieldtype"
|
||||
)
|
||||
|
||||
if course_description_field == "Text Editor":
|
||||
courses = frappe.get_all("LMS Course", fields=["name", "description"])
|
||||
|
||||
for course in courses:
|
||||
frappe.db.set_value(
|
||||
"LMS Course", course.name, "description", to_markdown(course.description)
|
||||
)
|
||||
|
||||
frappe.reload_doc("lms", "doctype", "lms_course")
|
||||
25
lms/patches/v0_0/share_certificates.py
Normal file
25
lms/patches/v0_0/share_certificates.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import frappe
|
||||
|
||||
|
||||
def execute():
|
||||
certificates = frappe.get_all("LMS Certificate", fields=["member", "name"])
|
||||
|
||||
for certificate in certificates:
|
||||
if not frappe.db.exists(
|
||||
"DocShare",
|
||||
{
|
||||
"share_doctype": "LMS Certificate",
|
||||
"share_name": certificate.name,
|
||||
"user": certificate.member,
|
||||
},
|
||||
):
|
||||
share = frappe.get_doc(
|
||||
{
|
||||
"doctype": "DocShare",
|
||||
"user": certificate.member,
|
||||
"share_doctype": "LMS Certificate",
|
||||
"share_name": certificate.name,
|
||||
"read": 1,
|
||||
}
|
||||
)
|
||||
share.save(ignore_permissions=True)
|
||||
@@ -974,71 +974,67 @@ pre {
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.certificate-content {
|
||||
background-color: #FFFFFF;
|
||||
border-width: 10px;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
@media (max-width: 500px) {
|
||||
.certificate-content {
|
||||
border-width: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.certificate-footer {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 4rem auto 0;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.certificate-ribbon {
|
||||
background-color: var(--primary-color);
|
||||
padding: 0.5rem;
|
||||
border-radius: var(--border-radius-md);
|
||||
}
|
||||
|
||||
.certificate-heading {
|
||||
font-size: 2rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.certificate-para {
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
.certificate-card {
|
||||
background: #FFFFFF;
|
||||
border-radius: var(--border-radius-md);
|
||||
position: relative;
|
||||
box-shadow: var(--shadow-sm);
|
||||
font-size: 14px
|
||||
}
|
||||
|
||||
.certificate-content {
|
||||
border-radius: 0.5rem;
|
||||
border: 1px solid #EEF0F2;
|
||||
padding: 1rem;
|
||||
font-size: var(--text-lg);
|
||||
}
|
||||
|
||||
.certificate-border {
|
||||
border: 10px solid #0089FF;
|
||||
/* border-image: url(/assets/lms/images/border.png);
|
||||
border-width: 100;
|
||||
border-style: solid ; */
|
||||
border-radius: 8px;
|
||||
padding: 6rem 4rem;
|
||||
background-color: #FFFFFF;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.certificate-footer-item {
|
||||
color: var(--text-color);
|
||||
font-weight: bold;
|
||||
font-family: cursive;
|
||||
font-size: 1.25rem;
|
||||
.certificate-parent {
|
||||
display: grid;
|
||||
grid-template-columns: 10fr 2fr;
|
||||
grid-gap: 3rem;
|
||||
}
|
||||
|
||||
.certificate-logo {
|
||||
height: 1.5rem;
|
||||
height: 1.5rem;
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.certificate-card {
|
||||
margin: 0;
|
||||
}
|
||||
.certificate-name {
|
||||
font-size: 2rem;
|
||||
font-weight: 500;
|
||||
color: #192734;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
@media (max-width: 550px) {
|
||||
.certificate-content {
|
||||
padding: 1rem;
|
||||
}
|
||||
.certificate-footer {
|
||||
margin: 4rem auto 0;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.certificate-footer-item {
|
||||
color: #192734;
|
||||
}
|
||||
|
||||
.cursive-font {
|
||||
font-family: cursive;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.certificate-divider {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.certificate-expiry {
|
||||
margin-left: 2rem;
|
||||
}
|
||||
|
||||
.column-card {
|
||||
@@ -1336,10 +1332,10 @@ pre {
|
||||
margin-bottom: 1.875rem;
|
||||
}
|
||||
|
||||
.job-card-heading {
|
||||
.card-heading {
|
||||
font-weight: 600;
|
||||
color: var(--gray-900);
|
||||
margin-bottom: 0.5rem;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.course-head-container {
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
|
||||
<div id="certificate-card" style="background: #FFFFFF; border-radius: 0.5rem; position: relative;
|
||||
box-shadow: 0px 1px 2px rgba(25, 39, 52, 0.05), 0px 0px 4px rgba(25, 39, 52, 0.1); padding: 1rem;">
|
||||
|
||||
<div style="border: 10px solid var(--primary-color); display: flex; flex-direction: column; align-items: center; padding: 4rem;
|
||||
justify-content: center; background-color: #FFFFFF;">
|
||||
|
||||
<img src="{{ logo }}" style="height: 1.5rem;">
|
||||
<div style="margin-top: 4rem;">
|
||||
{{ _("This certifies that") }}
|
||||
</div>
|
||||
|
||||
<div style="font-size: 2rem; font-weight: 500; color: #192734;">
|
||||
{{ member.full_name }}
|
||||
</div>
|
||||
<div style="margin-top: 0.5rem;">
|
||||
{{ _("has successfully completed the course on") }}
|
||||
<b> {{ course.title }} </b>
|
||||
on {{ frappe.utils.format_date(certificate.issue_date, "medium") }}.
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: center; margin: 4rem auto 0; width: fit-content;">
|
||||
{% if instructors %}
|
||||
<div>
|
||||
<div style="color: #192734; font-weight: bold; font-family: cursive; font-size: 1.25rem;">
|
||||
{{ instructors }}
|
||||
</div>
|
||||
<hr style="margin: 0.5rem 0;">
|
||||
<div class="text-center"> {{ _("Course Instructor") }} </div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if certificate.expiry_date %}
|
||||
<div style="margin-left: 2rem;">
|
||||
<div style="color: #192734; font-weight: bold; font-family: cursive; font-size: 1.25rem;">
|
||||
{{ frappe.utils.format_date(certificate.expiry_date, "medium") }}
|
||||
</div>
|
||||
<hr style="margin: 0.5rem 0;">
|
||||
<div class="text-center"> {{ _("Expiry date") }} </div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,25 +2,70 @@
|
||||
{% block title %} {{ member.full_name }} - {{ course.title }} {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="common-page-style">
|
||||
<div class="container certificate-page">
|
||||
|
||||
{% if certificate.member == frappe.session.user %}
|
||||
<div class="button is-secondary pull-right" id="export-as-pdf" data-certificate="{{ certificate.name }}"
|
||||
data-certificate-name="{{ member.full_name }} - {{ course.title }}">{{ _("Export") }}</div>
|
||||
{% endif %}
|
||||
<div class="common-page-style lms-page-style">
|
||||
<div class="container">
|
||||
|
||||
<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>
|
||||
{% if custom_template %}
|
||||
{{ custom_template }}
|
||||
{% else %}
|
||||
{% include "lms/templates/certificate.html" %}
|
||||
{% endif %}
|
||||
<script src="/assets/lms/js/html2canvas.js"></script>
|
||||
|
||||
<div class="certificate-parent">
|
||||
|
||||
<div>
|
||||
{{ final_template }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
{% if doc.member == frappe.session.user %}
|
||||
<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">
|
||||
{{ _("Download") }}
|
||||
</a>
|
||||
|
||||
<!-- <a class="btn btn-default btn-sm ml-2" target="_blank" href="https://www.linkedin.com/sharing/share-offsite?url={{ url | urlencode }}">
|
||||
{{ _("Share") }}
|
||||
</a> -->
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="card-heading mt-4">
|
||||
{{ _("Certificate Recipient") }}:
|
||||
</div>
|
||||
|
||||
<div class="certificate-recipient">
|
||||
{{ widgets.Avatar(member=member, avatar_class="avatar-small") }}
|
||||
<span class="ml-2">
|
||||
{{ member.full_name }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="card-heading mt-4">
|
||||
{{ _("Issued On") }}:
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ frappe.utils.format_date(doc.issue_date, "medium") }}
|
||||
</div>
|
||||
|
||||
<div class="card-heading mt-4">
|
||||
{{ _("About the Course") }}:
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ course.title }}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
frappe.ready(() => {
|
||||
$("#export-as-pdf").click((e) => {
|
||||
export_as_png(e);
|
||||
});
|
||||
});
|
||||
|
||||
const export_as_pdf = (e) => {
|
||||
var formData = new FormData();
|
||||
|
||||
//Push the HTML content into an element
|
||||
formData.append("html", $("#certificate-card").html());
|
||||
|
||||
var blob = new Blob([], { type: "text/xml" });
|
||||
formData.append("blob", blob);
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open(
|
||||
"POST",
|
||||
"/api/method/lms.lms.doctype.lms_certificate.lms_certificate.get_certificate_pdf"
|
||||
);
|
||||
xhr.setRequestHeader("X-Frappe-CSRF-Token", frappe.csrf_token);
|
||||
xhr.responseType = "arraybuffer";
|
||||
|
||||
xhr.onload = function (success) {
|
||||
if (this.status === 200) {
|
||||
var blob = new Blob([success.currentTarget.response], {
|
||||
type: "application/pdf",
|
||||
});
|
||||
var objectUrl = URL.createObjectURL(blob);
|
||||
|
||||
//Open report in a new window
|
||||
window.open(objectUrl);
|
||||
}
|
||||
};
|
||||
xhr.send(formData);
|
||||
};
|
||||
|
||||
const export_as_png = (e) => {
|
||||
let button = $(e.currentTarget);
|
||||
button.text(__("Exporting..."));
|
||||
|
||||
html2canvas(document.querySelector("#certificate-card"), {
|
||||
scrollY: -window.scrollY,
|
||||
scrollX: 0,
|
||||
})
|
||||
.then(function (canvas) {
|
||||
let dataURL = canvas.toDataURL("image/png");
|
||||
let a = document.createElement("a");
|
||||
a.href = dataURL;
|
||||
a.download = button.attr("data-certificate-name");
|
||||
a.click();
|
||||
})
|
||||
.finally(() => {
|
||||
button.text(__("Export"));
|
||||
});
|
||||
};
|
||||
@@ -1,7 +1,6 @@
|
||||
import frappe
|
||||
from frappe.utils.jinja import render_template
|
||||
|
||||
from lms.lms.utils import get_instructors
|
||||
from frappe.utils import get_url
|
||||
|
||||
|
||||
def get_context(context):
|
||||
@@ -13,32 +12,40 @@ def get_context(context):
|
||||
except KeyError:
|
||||
redirect_to_course_list()
|
||||
|
||||
context.certificate = frappe.db.get_value(
|
||||
context.doc = frappe.db.get_value(
|
||||
"LMS Certificate",
|
||||
certificate_name,
|
||||
["name", "member", "issue_date", "expiry_date", "course"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
if context.certificate.course != course_name:
|
||||
if context.doc.course != course_name:
|
||||
redirect_to_course_list()
|
||||
|
||||
context.course = frappe.db.get_value(
|
||||
"LMS Course", course_name, ["title", "name", "image"], 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
|
||||
"User", context.doc.member, ["full_name", "username"], as_dict=True
|
||||
)
|
||||
context.url = f"{get_url()}/courses/{context.course.name}/{context.doc.name}"
|
||||
|
||||
default_print_format = frappe.db.get_value(
|
||||
"Property Setter",
|
||||
{
|
||||
"doc_type": "LMS Certificate",
|
||||
"property": "default_print_format",
|
||||
},
|
||||
["value"],
|
||||
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"
|
||||
template = frappe.db.get_value(
|
||||
"Print Format", default_print_format.value, ["html", "css"], as_dict=True
|
||||
)
|
||||
context.custom_certificate_template = frappe.db.get_value(
|
||||
"Web Template", template_name, "template"
|
||||
)
|
||||
context.custom_template = render_template(context.custom_certificate_template, context)
|
||||
merged_template = "<style> " + template.css + " </style>" + template.html
|
||||
final_template = render_template(merged_template, context)
|
||||
context.final_template = final_template
|
||||
|
||||
|
||||
def redirect_to_course_list():
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<span title="{{ job.company_name}}" style="background-image: url( {{ job.company_logo | urlencode }} );"
|
||||
class="company-logo"></span>
|
||||
<div class="job-card-info">
|
||||
<div class="job-card-heading">{{ _(job.job_title) }}</div>
|
||||
<div class="card-heading">{{ _(job.job_title) }}</div>
|
||||
|
||||
<div class="job-company course-meta">
|
||||
<div class="mr-5">{{ job.company_name }}</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
class="company-logo"></span>
|
||||
|
||||
<div class="job-card-info">
|
||||
<div class="job-card-heading">{{ _(job.job_title) }}</div>
|
||||
<div class="card-heading">{{ _(job.job_title) }}</div>
|
||||
<div class="job-company course-meta">
|
||||
<div class="mr-5">{{ job.company_name }}</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user