feat: certificate generation dialog

This commit is contained in:
Jannat Patel
2023-08-29 16:50:14 +05:30
parent b940ddca25
commit f9f70f208f
7 changed files with 68 additions and 8 deletions

View File

@@ -58,13 +58,13 @@
"fieldname": "batch_name",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Batch Name",
"label": "Batch",
"options": "LMS Batch"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-23 14:48:49.351395",
"modified": "2023-08-29 15:23:08.637215",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Certificate",
@@ -81,6 +81,18 @@
"role": "System Manager",
"share": 1,
"write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "Moderator",
"share": 1,
"write": 1
}
],
"sort_field": "modified",

View File

@@ -116,6 +116,7 @@
</li>
{% endif %}
{% if is_moderator %}
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#students">
{{ _("Students") }}
@@ -125,7 +126,6 @@
</a>
</li>
{% if is_moderator %}
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#assessments">
{{ _("Assessments") }}
@@ -175,11 +175,11 @@
</div>
{% endif %}
{% if is_moderator %}
<div class="tab-pane" id="students" role="tabpanel" aria-labelledby="students">
{{ StudentsSection(batch_info, batch_students) }}
</div>
{% if is_moderator %}
<div class="tab-pane" id="assessments" role="tabpanel" aria-labelledby="assessments">
{{ AssessmentsSection(batch_info) }}
</div>

View File

@@ -27,7 +27,7 @@
</a>
<img class="icon icon-sm mr-0" src="/assets/lms/icons/chevron-right.svg">
<a class="dark-links" href="/batches/{{ batch.name }}">
{{ batch.name }}
{{ batch.title }}
</a>
<img class="icon icon-sm mr-0" src="/assets/lms/icons/chevron-right.svg">
<span class="breadcrumb-destination">
@@ -46,6 +46,9 @@
</button>
{% endif %}
{% if is_moderator %}
<button class="btn btn-default btn-sm btn-certification ml-2">
{{ _("Grant Certificate") }}
</button>
<a class="btn btn-primary btn-sm btn-evaluate ml-2" href="/evaluation/new?member={{student.name}}&date={{frappe.utils.getdate()}}&class_name={{batch.name}}">
{{ _("Evaluate") }}
</a>
@@ -86,5 +89,4 @@
let courses = {{ courses | json }};
let batch_name = "{{ batch.name }}";
</script>
{{ include_script('controls.bundle.js') }}
{% endblock %}

View File

@@ -1,5 +1,45 @@
frappe.ready(() => {
frappe.require("controls.bundle.js");
$(".clickable-row").click((e) => {
window.location.href = $(e.currentTarget).data("href");
});
$(".btn-certification").click((e) => {
show_certificate_dialog(e);
});
});
const show_certificate_dialog = (e) => {
this.certificate_dialog = new frappe.ui.Dialog({
title: __("Grant Certificate"),
fields: [
{
fieldtype: "Link",
fieldname: "course",
label: __("Course"),
options: "LMS Course",
reqd: 1,
filters: {
name: ["in", courses],
},
filter_description: " ",
only_select: 1,
},
{
fieldtype: "Date",
fieldname: "issue_date",
label: __("Issue Date"),
reqd: 1,
default: frappe.datetime.get_today(),
},
{
fieldtype: "Date",
fieldname: "expiry_date",
label: __("Expiry Date"),
},
],
});
this.certificate_dialog.show();
};

View File

@@ -29,7 +29,9 @@ def get_context(context):
):
raise frappe.PermissionError(_("You don't have permission to access this page."))
context.batch = frappe.db.get_value("LMS Batch", batch_name, ["name"], as_dict=True)
context.batch = frappe.db.get_value(
"LMS Batch", batch_name, ["name", "title"], as_dict=True
)
context.courses = frappe.get_all(
"Batch Course", {"parent": batch_name}, pluck="course"

View File

@@ -16,6 +16,7 @@ def get_context(context):
context.module = module
context.docname = docname
context.doctype = doctype
context.apply_gst = frappe.db.get_single_value("LMS Settings", "apply_gst")
if not frappe.db.exists(doctype, docname):
raise ValueError(_("Module Name is incorrect or does not exist."))
@@ -65,3 +66,6 @@ def get_context(context):
context.title = batch.title
context.amount = batch.amount
context.currency = batch.currency
if context.apply_gst:
context.gst_amount = context.amount * 1.18

View File

@@ -146,7 +146,7 @@
{{ _("Short Description") }}
</div>
<div class="field-description">
{{ _("A breif description about this chapter.") }}
{{ _("A brief description about this chapter.") }}
</div>
</div>
<div class="">