feat: certificate template
This commit is contained in:
@@ -10,6 +10,14 @@ frappe.ui.form.on("LMS Certificate", {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
frm.set_query("template", function (doc) {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
doc_type: "LMS Certificate",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
},
|
},
|
||||||
refresh: (frm) => {
|
refresh: (frm) => {
|
||||||
if (frm.doc.name)
|
if (frm.doc.name)
|
||||||
|
|||||||
@@ -8,11 +8,12 @@
|
|||||||
"course",
|
"course",
|
||||||
"member",
|
"member",
|
||||||
"member_name",
|
"member_name",
|
||||||
"published",
|
"template",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"issue_date",
|
"issue_date",
|
||||||
"expiry_date",
|
"expiry_date",
|
||||||
"batch_name"
|
"batch_name",
|
||||||
|
"published"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -67,11 +68,18 @@
|
|||||||
"fieldname": "published",
|
"fieldname": "published",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Publish on Participant Page"
|
"label": "Publish on Participant Page"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "template",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Template",
|
||||||
|
"options": "Print Format",
|
||||||
|
"reqd": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2023-09-13 11:03:23.479255",
|
"modified": "2023-10-25 12:20:56.091979",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Certificate",
|
"name": "LMS Certificate",
|
||||||
|
|||||||
@@ -48,6 +48,15 @@ def create_certificate(course):
|
|||||||
if expires_after_yrs:
|
if expires_after_yrs:
|
||||||
expiry_date = add_years(nowdate(), expires_after_yrs)
|
expiry_date = add_years(nowdate(), expires_after_yrs)
|
||||||
|
|
||||||
|
default_certificate_template = frappe.db.get_value(
|
||||||
|
"Property Setter",
|
||||||
|
{
|
||||||
|
"doc_type": "LMS Certificate",
|
||||||
|
"property": "default_print_format",
|
||||||
|
},
|
||||||
|
"value",
|
||||||
|
)
|
||||||
|
|
||||||
certificate = frappe.get_doc(
|
certificate = frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "LMS Certificate",
|
"doctype": "LMS Certificate",
|
||||||
@@ -55,6 +64,7 @@ def create_certificate(course):
|
|||||||
"course": course,
|
"course": course,
|
||||||
"issue_date": nowdate(),
|
"issue_date": nowdate(),
|
||||||
"expiry_date": expiry_date,
|
"expiry_date": expiry_date,
|
||||||
|
"template": default_certificate_template,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
certificate.save(ignore_permissions=True)
|
certificate.save(ignore_permissions=True)
|
||||||
|
|||||||
@@ -75,3 +75,4 @@ lms.patches.v1_0.create_student_role
|
|||||||
lms.patches.v1_0.mark_confirmation_for_batch_students
|
lms.patches.v1_0.mark_confirmation_for_batch_students
|
||||||
lms.patches.v1_0.create_quiz_questions
|
lms.patches.v1_0.create_quiz_questions
|
||||||
lms.patches.v1_0.add_default_marks #16-10-2023
|
lms.patches.v1_0.add_default_marks #16-10-2023
|
||||||
|
lms.patches.v1_0.add_certificate_template #25-10-2023
|
||||||
19
lms/patches/v1_0/add_certificate_template.py
Normal file
19
lms/patches/v1_0/add_certificate_template.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
default_certificate_template = frappe.db.get_value(
|
||||||
|
"Property Setter",
|
||||||
|
{
|
||||||
|
"doc_type": "LMS Certificate",
|
||||||
|
"property": "default_print_format",
|
||||||
|
},
|
||||||
|
"value",
|
||||||
|
)
|
||||||
|
|
||||||
|
if frappe.db.exists("Print Format", default_certificate_template):
|
||||||
|
certificates = frappe.get_all("LMS Certificate", pluck="name")
|
||||||
|
for certificate in certificates:
|
||||||
|
frappe.db.set_value(
|
||||||
|
"LMS Certificate", certificate, "template", default_certificate_template
|
||||||
|
)
|
||||||
@@ -16,7 +16,7 @@ def get_context(context):
|
|||||||
context.doc = frappe.db.get_value(
|
context.doc = frappe.db.get_value(
|
||||||
"LMS Certificate",
|
"LMS Certificate",
|
||||||
certificate_name,
|
certificate_name,
|
||||||
["name", "member", "issue_date", "expiry_date", "course"],
|
["name", "member", "issue_date", "expiry_date", "course", "template"],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -31,7 +31,10 @@ def get_context(context):
|
|||||||
)
|
)
|
||||||
context.url = f"{get_url()}/courses/{context.course.name}/{context.doc.name}"
|
context.url = f"{get_url()}/courses/{context.course.name}/{context.doc.name}"
|
||||||
|
|
||||||
print_format = get_print_format()
|
if context.doc.template:
|
||||||
|
print_format = context.doc.template
|
||||||
|
else:
|
||||||
|
print_format = get_print_format()
|
||||||
|
|
||||||
template = frappe.db.get_value(
|
template = frappe.db.get_value(
|
||||||
"Print Format", print_format, ["html", "css"], as_dict=True
|
"Print Format", print_format, ["html", "css"], as_dict=True
|
||||||
|
|||||||
Reference in New Issue
Block a user