diff --git a/docker-installation.md b/docker-installation.md index 99a272f1..b5c8ef80 100644 --- a/docker-installation.md +++ b/docker-installation.md @@ -4,6 +4,8 @@ $ git clone https://github.com/frappe/lms.git $ cd lms + +$ cd docker ``` **Step 2:** Run docker-compose diff --git a/frontend/src/components/BatchOverlay.vue b/frontend/src/components/BatchOverlay.vue index bcd5413c..a01b7388 100644 --- a/frontend/src/components/BatchOverlay.vue +++ b/frontend/src/components/BatchOverlay.vue @@ -66,7 +66,13 @@ - + +
+ {{ course.data.price }} +
diff --git a/frontend/src/pages/BatchDetail.vue b/frontend/src/pages/BatchDetail.vue index fa006df5..916df2b5 100644 --- a/frontend/src/pages/BatchDetail.vue +++ b/frontend/src/pages/BatchDetail.vue @@ -14,7 +14,7 @@
- {{ batch.data.courses.length }} {{ __('Courses') }} + {{ batch.data?.courses?.length }} {{ __('Courses') }}
·
diff --git a/lms/lms/doctype/batch_student/batch_student.py b/lms/lms/doctype/batch_student/batch_student.py index 7cd9a61a..d3168f71 100644 --- a/lms/lms/doctype/batch_student/batch_student.py +++ b/lms/lms/doctype/batch_student/batch_student.py @@ -1,9 +1,19 @@ # Copyright (c) 2022, Frappe and contributors # For license information, please see license.txt -# import frappe +import frappe from frappe.model.document import Document class BatchStudent(Document): 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) diff --git a/lms/lms/doctype/lms_batch/lms_batch.json b/lms/lms/doctype/lms_batch/lms_batch.json index 9643d41f..82023f6f 100644 --- a/lms/lms/doctype/lms_batch/lms_batch.json +++ b/lms/lms/doctype/lms_batch/lms_batch.json @@ -15,6 +15,7 @@ "start_time", "end_time", "published", + "allow_self_enrollment", "section_break_rgfj", "medium", "category", @@ -293,11 +294,17 @@ "fieldname": "amount_usd", "fieldtype": "Currency", "label": "Amount (USD)" + }, + { + "default": "0", + "fieldname": "allow_self_enrollment", + "fieldtype": "Check", + "label": "Allow Self Enrollment" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-01-08 09:58:23.212334", + "modified": "2024-01-22 10:42:42.872995", "modified_by": "Administrator", "module": "LMS", "name": "LMS Batch", diff --git a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json index b334eabf..0335d51b 100644 --- a/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json +++ b/lms/lms/notification/certificate_request_reminder/certificate_request_reminder.json @@ -11,7 +11,7 @@ "event": "Days Before", "idx": 0, "is_standard": 1, - "message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\n

{{ _('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\")) }}

\n\n

{{ _(\"Please prepare well and be on time for the evaluations.\") }}

\n", + "message": "{% set title = frappe.db.get_value(\"LMS Course\", doc.course, \"title\") %}\n\n

{{ _('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\")) }}

\n\n

{{ _(\"Please prepare well and be on time for the evaluations.\") }}

\n", "message_type": "HTML", "modified": "2023-11-29 17:26:53.355501", "modified_by": "Administrator", @@ -29,4 +29,4 @@ "send_system_notification": 0, "send_to_all_assignees": 0, "subject": "Reminder for Certificate Evaluation" -} \ No newline at end of file +} diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 5c676eeb..7fce3473 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -1194,6 +1194,7 @@ def get_course_details(course): "paid_course", "course_price", "currency", + "amount_usd", ], as_dict=1, ) @@ -1214,6 +1215,9 @@ def get_course_details(course): course_details.instructors = get_instructors(course_details.name) 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.course_price, 0, course_details.currency ) @@ -1385,9 +1389,11 @@ def get_batch_details(batch): "seat_count", "published", "amount", + "amount_usd", "currency", "paid_batch", "evaluation_end_date", + "allow_self_enrollment", ], as_dict=True, ) @@ -1398,7 +1404,11 @@ def get_batch_details(batch): batch_details.students = frappe.get_all( "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: students_enrolled = frappe.db.count( diff --git a/lms/www/batches/batch.html b/lms/www/batches/batch.html index cc501ddc..f368c70c 100644 --- a/lms/www/batches/batch.html +++ b/lms/www/batches/batch.html @@ -49,11 +49,14 @@ - {{ frappe.utils.format_date(batch_info.start_date, "long") }} - + {{ frappe.utils.format_date(batch_info.start_date, "long") }} + + {% if batch_info.start_date != batch_info.end_date %} - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + {% endif %}
@@ -646,4 +649,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/lms/www/batches/batch_details.html b/lms/www/batches/batch_details.html index 9fd5c93e..ddfbba43 100644 --- a/lms/www/batches/batch_details.html +++ b/lms/www/batches/batch_details.html @@ -57,11 +57,13 @@ - {{ frappe.utils.format_date(batch_info.start_date, "long") }} - - - - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + {{ frappe.utils.format_date(batch_info.start_date, "long") }} + {% if batch_info.start_date != batch_info.end_date %} + + - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + + {% endif %}
{% if batch_info.start_time and batch_info.end_time %} @@ -115,11 +117,13 @@ - {{ frappe.utils.format_date(batch_info.start_date, "long") }} - - - - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + {{ frappe.utils.format_date(batch_info.start_date, "long") }} + {% if batch_info.start_date != batch_info.end_date %} + + - {{ frappe.utils.format_date(batch_info.end_date, "long") }} + + {% endif %}
{% if batch_info.start_time and batch_info.end_time %} @@ -146,6 +150,10 @@ href="/billing/batch/{{ batch_info.name }}"> {{ _("Register Now") }} + {% elif batch_info.allow_self_enrollment %} + {% else %}
{{ _("To join this batch, please contact the Administrator.") }} @@ -235,4 +243,4 @@ let batch_info = {{ batch_info | json }}; {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/lms/www/batches/batch_details.js b/lms/www/batches/batch_details.js index 92070ece..9e1eeeb5 100644 --- a/lms/www/batches/batch_details.js +++ b/lms/www/batches/batch_details.js @@ -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", diff --git a/lms/www/batches/batch_details.py b/lms/www/batches/batch_details.py index fdeb035b..97f950d9 100644 --- a/lms/www/batches/batch_details.py +++ b/lms/www/batches/batch_details.py @@ -35,6 +35,7 @@ def get_context(context): "batch_details_raw", "evaluation_end_date", "amount_usd", + "allow_self_enrollment", ], as_dict=1, ) diff --git a/lms/www/batches/index.html b/lms/www/batches/index.html index 60eaad4f..cdcd56eb 100644 --- a/lms/www/batches/index.html +++ b/lms/www/batches/index.html @@ -140,11 +140,13 @@ - {{ frappe.utils.format_date(batch.start_date, "medium") }} - + {{ frappe.utils.format_date(batch.start_date, "medium") }} + {% if batch.start_date != batch.end_date %} - {{ frappe.utils.format_date(batch.end_date, "medium") }} + - {{ frappe.utils.format_date(batch.end_date, "long") }} + {% endif %}
@@ -204,4 +206,4 @@ let batch_info = null; {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %}