fix: multicurrency on course cards

This commit is contained in:
Jannat Patel
2024-01-23 17:03:15 +05:30
13 changed files with 102 additions and 22 deletions

View File

@@ -49,11 +49,14 @@
<use href="#icon-calendar"></use>
</svg>
<span>
{{ frappe.utils.format_date(batch_info.start_date, "long") }} -
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
</span>
{% if batch_info.start_date != batch_info.end_date %}
<span>
{{ frappe.utils.format_date(batch_info.end_date, "long") }}
- {{ frappe.utils.format_date(batch_info.end_date, "long") }}
</span>
{% endif %}
</div>
<span class="seperator"></span>
@@ -646,4 +649,4 @@
<link rel="stylesheet" href="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.css" />
<script src="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.js"></script>
{% endblock %}
{% endblock %}

View File

@@ -57,11 +57,13 @@
<use href="#icon-calendar"></use>
</svg>
<span>
{{ frappe.utils.format_date(batch_info.start_date, "long") }} -
</span>
<span>
{{ frappe.utils.format_date(batch_info.end_date, "long") }}
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
</span>
{% if batch_info.start_date != batch_info.end_date %}
<span>
- {{ frappe.utils.format_date(batch_info.end_date, "long") }}
</span>
{% endif %}
</div>
{% if batch_info.start_time and batch_info.end_time %}
@@ -115,11 +117,13 @@
<use href="#icon-calendar"></use>
</svg>
<span>
{{ frappe.utils.format_date(batch_info.start_date, "long") }} -
</span>
<span>
{{ frappe.utils.format_date(batch_info.end_date, "long") }}
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
</span>
{% if batch_info.start_date != batch_info.end_date %}
<span>
- {{ frappe.utils.format_date(batch_info.end_date, "long") }}
</span>
{% endif %}
</div>
{% if batch_info.start_time and batch_info.end_time %}
@@ -146,6 +150,10 @@
href="/billing/batch/{{ batch_info.name }}">
{{ _("Register Now") }}
</a>
{% elif batch_info.allow_self_enrollment %}
<button class="btn btn-primary wide-button enroll-batch">
{{ _("Enroll Now") }}
</button>
{% else %}
<div class="alert alert-info">
{{ _("To join this batch, please contact the Administrator.") }}
@@ -235,4 +243,4 @@
let batch_info = {{ batch_info | json }};
</script>
{% endif %}
{% endblock %}
{% endblock %}

View File

@@ -12,6 +12,10 @@ frappe.ready(() => {
$(".btn-remove-course").click((e) => {
remove_course(e);
});
$(".enroll-batch").click((e) => {
enroll_batch(e);
});
});
const show_course_modal = (e) => {
@@ -54,6 +58,30 @@ const show_course_modal = (e) => {
}, 1000);
};
const enroll_batch = (e) => {
let batch_name = $(".class-details").data("batch");
if (frappe.session.user == "Guest") {
window.location.href =
"/login?redirect-to=/batches/details/" + batch_name;
}
frappe.call({
method: "lms.lms.doctype.batch_student.batch_student.enroll_batch",
args: {
batch_name: batch_name,
},
callback(r) {
frappe.show_alert(
{
message: __("Successfully Enrolled"),
indicator: "green",
},
2000
);
window.location.href = `/batches/${batch_name}`;
},
});
};
const add_course = (values, course_name) => {
frappe.call({
method: "lms.lms.doctype.lms_batch.lms_batch.add_course",

View File

@@ -35,6 +35,7 @@ def get_context(context):
"batch_details_raw",
"evaluation_end_date",
"amount_usd",
"allow_self_enrollment",
],
as_dict=1,
)

View File

@@ -140,11 +140,13 @@
<use href="#icon-calendar"></use>
</svg>
<span>
{{ frappe.utils.format_date(batch.start_date, "medium") }} -
{{ frappe.utils.format_date(batch.start_date, "medium") }}
</span>
{% if batch.start_date != batch.end_date %}
<span>
{{ frappe.utils.format_date(batch.end_date, "medium") }}
- {{ frappe.utils.format_date(batch.end_date, "long") }}
</span>
{% endif %}
</div>
<div class="mb-2">
@@ -204,4 +206,4 @@
let batch_info = null;
</script>
{% endif %}
{% endblock %}
{% endblock %}