fix: multicurrency on course cards
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
$ git clone https://github.com/frappe/lms.git
|
$ git clone https://github.com/frappe/lms.git
|
||||||
|
|
||||||
$ cd lms
|
$ cd lms
|
||||||
|
|
||||||
|
$ cd docker
|
||||||
```
|
```
|
||||||
|
|
||||||
**Step 2:** Run docker-compose
|
**Step 2:** Run docker-compose
|
||||||
|
|||||||
@@ -66,7 +66,13 @@
|
|||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
<Button
|
||||||
|
variant="solid"
|
||||||
|
class="w-full mt-2"
|
||||||
|
v-else-if="batch.data.allow_self_enrollment"
|
||||||
|
>
|
||||||
|
{{ __('Enroll Now') }}
|
||||||
|
</Button>
|
||||||
<Button v-if="user?.data?.is_moderator" class="w-full mt-2">
|
<Button v-if="user?.data?.is_moderator" class="w-full mt-2">
|
||||||
<span>
|
<span>
|
||||||
{{ __('Edit') }}
|
{{ __('Edit') }}
|
||||||
|
|||||||
@@ -62,6 +62,9 @@
|
|||||||
{{ __('Edit') }}
|
{{ __('Edit') }}
|
||||||
</span>
|
</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
<div class="text-lg font-semibold mb-3">
|
||||||
|
{{ course.data.price }}
|
||||||
|
</div>
|
||||||
<div class="flex items-center mb-3">
|
<div class="flex items-center mb-3">
|
||||||
<Users class="h-4 w-4 text-gray-700" />
|
<Users class="h-4 w-4 text-gray-700" />
|
||||||
<span class="ml-1">
|
<span class="ml-1">
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<div class="flex items-center justify-between w-1/2">
|
<div class="flex items-center justify-between w-1/2">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<BookOpen class="h-4 w-4 text-gray-700 mr-2" />
|
<BookOpen class="h-4 w-4 text-gray-700 mr-2" />
|
||||||
<span> {{ batch.data.courses.length }} {{ __('Courses') }} </span>
|
<span> {{ batch.data?.courses?.length }} {{ __('Courses') }} </span>
|
||||||
</div>
|
</div>
|
||||||
<span v-if="batch.data.courses">·</span>
|
<span v-if="batch.data.courses">·</span>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
# Copyright (c) 2022, Frappe and contributors
|
# Copyright (c) 2022, Frappe and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
# import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
|
||||||
class BatchStudent(Document):
|
class BatchStudent(Document):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def enroll_batch(batch_name):
|
||||||
|
enrollment = frappe.new_doc("Batch Student")
|
||||||
|
enrollment.student = frappe.session.user
|
||||||
|
enrollment.parent = batch_name
|
||||||
|
enrollment.parentfield = "students"
|
||||||
|
enrollment.parenttype = "LMS Batch"
|
||||||
|
enrollment.save(ignore_permissions=True)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"start_time",
|
"start_time",
|
||||||
"end_time",
|
"end_time",
|
||||||
"published",
|
"published",
|
||||||
|
"allow_self_enrollment",
|
||||||
"section_break_rgfj",
|
"section_break_rgfj",
|
||||||
"medium",
|
"medium",
|
||||||
"category",
|
"category",
|
||||||
@@ -293,11 +294,17 @@
|
|||||||
"fieldname": "amount_usd",
|
"fieldname": "amount_usd",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"label": "Amount (USD)"
|
"label": "Amount (USD)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "allow_self_enrollment",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Allow Self Enrollment"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-01-08 09:58:23.212334",
|
"modified": "2024-01-22 10:42:42.872995",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Batch",
|
"name": "LMS Batch",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
"event": "Days Before",
|
"event": "Days Before",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\n<p> {{ _('Your evaluation for the course ${0} has been scheduled on ${1} at ${2}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\")) }}</p>\n\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
"message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\n<p> {{ _('Your evaluation for the course {0} has been scheduled on {1} at {2}.').format(title, frappe.utils.format_date(doc.date, \"medium\"), frappe.utils.format_time(doc.start_time, \"short\")) }}</p>\n\n<p> {{ _(\"Please prepare well and be on time for the evaluations.\") }} </p>\n",
|
||||||
"message_type": "HTML",
|
"message_type": "HTML",
|
||||||
"modified": "2023-11-29 17:26:53.355501",
|
"modified": "2023-11-29 17:26:53.355501",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
@@ -29,4 +29,4 @@
|
|||||||
"send_system_notification": 0,
|
"send_system_notification": 0,
|
||||||
"send_to_all_assignees": 0,
|
"send_to_all_assignees": 0,
|
||||||
"subject": "Reminder for Certificate Evaluation"
|
"subject": "Reminder for Certificate Evaluation"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1194,6 +1194,7 @@ def get_course_details(course):
|
|||||||
"paid_course",
|
"paid_course",
|
||||||
"course_price",
|
"course_price",
|
||||||
"currency",
|
"currency",
|
||||||
|
"amount_usd",
|
||||||
],
|
],
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
)
|
)
|
||||||
@@ -1214,6 +1215,9 @@ def get_course_details(course):
|
|||||||
|
|
||||||
course_details.instructors = get_instructors(course_details.name)
|
course_details.instructors = get_instructors(course_details.name)
|
||||||
if course_details.paid_course:
|
if course_details.paid_course:
|
||||||
|
course_details.course_price, course_details.currency = check_multicurrency(
|
||||||
|
course_details.course_price, course_details.currency, None, course_details.amount_usd
|
||||||
|
)
|
||||||
course_details.price = fmt_money(
|
course_details.price = fmt_money(
|
||||||
course_details.course_price, 0, course_details.currency
|
course_details.course_price, 0, course_details.currency
|
||||||
)
|
)
|
||||||
@@ -1385,9 +1389,11 @@ def get_batch_details(batch):
|
|||||||
"seat_count",
|
"seat_count",
|
||||||
"published",
|
"published",
|
||||||
"amount",
|
"amount",
|
||||||
|
"amount_usd",
|
||||||
"currency",
|
"currency",
|
||||||
"paid_batch",
|
"paid_batch",
|
||||||
"evaluation_end_date",
|
"evaluation_end_date",
|
||||||
|
"allow_self_enrollment",
|
||||||
],
|
],
|
||||||
as_dict=True,
|
as_dict=True,
|
||||||
)
|
)
|
||||||
@@ -1398,7 +1404,11 @@ def get_batch_details(batch):
|
|||||||
batch_details.students = frappe.get_all(
|
batch_details.students = frappe.get_all(
|
||||||
"Batch Student", {"parent": batch}, pluck="student"
|
"Batch Student", {"parent": batch}, pluck="student"
|
||||||
)
|
)
|
||||||
batch_details.price = fmt_money(batch_details.amount, 0, batch_details.currency)
|
if batch_details.paid_batch:
|
||||||
|
batch_details.amount, batch_details.currency = check_multicurrency(
|
||||||
|
batch_details.amount, batch_details.currency, None, batch_details.amount_usd
|
||||||
|
)
|
||||||
|
batch_details.price = fmt_money(batch_details.amount, 0, batch_details.currency)
|
||||||
|
|
||||||
if batch_details.seat_count:
|
if batch_details.seat_count:
|
||||||
students_enrolled = frappe.db.count(
|
students_enrolled = frappe.db.count(
|
||||||
|
|||||||
@@ -49,11 +49,14 @@
|
|||||||
<use href="#icon-calendar"></use>
|
<use href="#icon-calendar"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<span>
|
<span>
|
||||||
{{ frappe.utils.format_date(batch_info.start_date, "long") }} -
|
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
{% if batch_info.start_date != batch_info.end_date %}
|
||||||
<span>
|
<span>
|
||||||
{{ frappe.utils.format_date(batch_info.end_date, "long") }}
|
- {{ frappe.utils.format_date(batch_info.end_date, "long") }}
|
||||||
</span>
|
</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="seperator"></span>
|
<span class="seperator"></span>
|
||||||
@@ -646,4 +649,4 @@
|
|||||||
|
|
||||||
<link rel="stylesheet" href="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.css" />
|
<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>
|
<script src="https://uicdn.toast.com/calendar/latest/toastui-calendar.min.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -57,11 +57,13 @@
|
|||||||
<use href="#icon-calendar"></use>
|
<use href="#icon-calendar"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<span>
|
<span>
|
||||||
{{ frappe.utils.format_date(batch_info.start_date, "long") }} -
|
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
{{ frappe.utils.format_date(batch_info.end_date, "long") }}
|
|
||||||
</span>
|
</span>
|
||||||
|
{% if batch_info.start_date != batch_info.end_date %}
|
||||||
|
<span>
|
||||||
|
- {{ frappe.utils.format_date(batch_info.end_date, "long") }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if batch_info.start_time and batch_info.end_time %}
|
{% if batch_info.start_time and batch_info.end_time %}
|
||||||
@@ -115,11 +117,13 @@
|
|||||||
<use href="#icon-calendar"></use>
|
<use href="#icon-calendar"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<span>
|
<span>
|
||||||
{{ frappe.utils.format_date(batch_info.start_date, "long") }} -
|
{{ frappe.utils.format_date(batch_info.start_date, "long") }}
|
||||||
</span>
|
|
||||||
<span>
|
|
||||||
{{ frappe.utils.format_date(batch_info.end_date, "long") }}
|
|
||||||
</span>
|
</span>
|
||||||
|
{% if batch_info.start_date != batch_info.end_date %}
|
||||||
|
<span>
|
||||||
|
- {{ frappe.utils.format_date(batch_info.end_date, "long") }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if batch_info.start_time and batch_info.end_time %}
|
{% if batch_info.start_time and batch_info.end_time %}
|
||||||
@@ -146,6 +150,10 @@
|
|||||||
href="/billing/batch/{{ batch_info.name }}">
|
href="/billing/batch/{{ batch_info.name }}">
|
||||||
{{ _("Register Now") }}
|
{{ _("Register Now") }}
|
||||||
</a>
|
</a>
|
||||||
|
{% elif batch_info.allow_self_enrollment %}
|
||||||
|
<button class="btn btn-primary wide-button enroll-batch">
|
||||||
|
{{ _("Enroll Now") }}
|
||||||
|
</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
{{ _("To join this batch, please contact the Administrator.") }}
|
{{ _("To join this batch, please contact the Administrator.") }}
|
||||||
@@ -235,4 +243,4 @@
|
|||||||
let batch_info = {{ batch_info | json }};
|
let batch_info = {{ batch_info | json }};
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ frappe.ready(() => {
|
|||||||
$(".btn-remove-course").click((e) => {
|
$(".btn-remove-course").click((e) => {
|
||||||
remove_course(e);
|
remove_course(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".enroll-batch").click((e) => {
|
||||||
|
enroll_batch(e);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const show_course_modal = (e) => {
|
const show_course_modal = (e) => {
|
||||||
@@ -54,6 +58,30 @@ const show_course_modal = (e) => {
|
|||||||
}, 1000);
|
}, 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) => {
|
const add_course = (values, course_name) => {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "lms.lms.doctype.lms_batch.lms_batch.add_course",
|
method: "lms.lms.doctype.lms_batch.lms_batch.add_course",
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ def get_context(context):
|
|||||||
"batch_details_raw",
|
"batch_details_raw",
|
||||||
"evaluation_end_date",
|
"evaluation_end_date",
|
||||||
"amount_usd",
|
"amount_usd",
|
||||||
|
"allow_self_enrollment",
|
||||||
],
|
],
|
||||||
as_dict=1,
|
as_dict=1,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -140,11 +140,13 @@
|
|||||||
<use href="#icon-calendar"></use>
|
<use href="#icon-calendar"></use>
|
||||||
</svg>
|
</svg>
|
||||||
<span>
|
<span>
|
||||||
{{ frappe.utils.format_date(batch.start_date, "medium") }} -
|
{{ frappe.utils.format_date(batch.start_date, "medium") }}
|
||||||
</span>
|
</span>
|
||||||
|
{% if batch.start_date != batch.end_date %}
|
||||||
<span>
|
<span>
|
||||||
{{ frappe.utils.format_date(batch.end_date, "medium") }}
|
- {{ frappe.utils.format_date(batch.end_date, "long") }}
|
||||||
</span>
|
</span>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
@@ -204,4 +206,4 @@
|
|||||||
let batch_info = null;
|
let batch_info = null;
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user