Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to Set Different Certificate Print Format for each LMS Course #574

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion lms/fixtures/custom_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -2012,5 +2012,58 @@
"translatable": 0,
"unique": 0,
"width": null
}
},
{
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": null,
"columns": 0,
"default": null,
"depends_on": null,
"description": null,
"docstatus": 0,
"doctype": "Custom Field",
"dt": "LMS Course",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rola-anvil why add a custom field in LMS Course doctype when you can add a standard field.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you have made the changes in the main branch of your fork. Can you create another branch for this feature instead?

"fetch_from": null,
"fetch_if_empty": 0,
"fieldname": "print_format",
"fieldtype": "Link",
"hidden": 0,
"hide_border": 0,
"hide_days": 0,
"hide_seconds": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_preview": 0,
"in_standard_filter": 0,
"insert_after": "certification_section",
"is_system_generated": 0,
"is_virtual": 0,
"label": "Print Format",
"length": 0,
"mandatory_depends_on": null,
"modified": "2023-07-25 15:40:27.758797",
"module": null,
"name": "LMS Course-print_format",
"no_copy": 0,
"non_negative": 0,
"options": "Print Format",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": null,
"read_only": 0,
"read_only_depends_on": null,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"translatable": 0,
"unique": 0,
"width": null
}
]
8 changes: 8 additions & 0 deletions lms/lms/doctype/lms_course/lms_course.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@ frappe.ui.form.on("LMS Course", {
},
refresh: (frm) => {
frm.add_web_link(`/courses/${frm.doc.name}`, "See on Website");

frm.set_query("print_format", function () {
return {
filters: {
doc_type: "LMS Certificate",
},
};
});
},
});
8 changes: 7 additions & 1 deletion lms/www/courses/certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ def get_context(context):
as_dict=True,
)

# Get Each LMS Course different Certificate Print Format

course_print_format = frappe.db.get_value("LMS Course", course_name, "print_format")

template = frappe.db.get_value(
"Print Format", default_print_format.value, ["html", "css"], as_dict=True
"Print Format", course_print_format or default_print_format.value, ["html", "css"], as_dict=True
)

# inested of in certificate.py file
merged_template = "<style> " + template.css + " </style>" + template.html
final_template = render_template(merged_template, context)
context.final_template = final_template
Expand Down
Loading