diff --git a/lms/lms/doctype/class_student/class_student.json b/lms/lms/doctype/class_student/class_student.json index 55017ec0..819050fc 100644 --- a/lms/lms/doctype/class_student/class_student.json +++ b/lms/lms/doctype/class_student/class_student.json @@ -7,16 +7,25 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ + "student_details_section", "student", + "column_break_oduu", "student_name", "username", - "address", + "payment_details_section", "column_break_zvlp", "amount", "currency", + "column_break_clem", "order_id", "payment_id", - "payment_received" + "payment_received", + "address_details_section", + "address", + "pan", + "column_break_rqoj", + "gstin", + "gst_category" ], "fields": [ { @@ -78,12 +87,54 @@ "fieldname": "payment_received", "fieldtype": "Check", "label": "Payment Received" + }, + { + "fieldname": "student_details_section", + "fieldtype": "Section Break", + "label": "Student Details" + }, + { + "fieldname": "column_break_oduu", + "fieldtype": "Column Break" + }, + { + "fieldname": "payment_details_section", + "fieldtype": "Section Break", + "label": "Payment Details" + }, + { + "fieldname": "column_break_clem", + "fieldtype": "Column Break" + }, + { + "fieldname": "address_details_section", + "fieldtype": "Section Break", + "label": "Address Details" + }, + { + "fieldname": "pan", + "fieldtype": "Data", + "label": "PAN" + }, + { + "fieldname": "column_break_rqoj", + "fieldtype": "Column Break" + }, + { + "fieldname": "gstin", + "fieldtype": "Data", + "label": "GSTIN" + }, + { + "fieldname": "gst_category", + "fieldtype": "Select", + "label": "GST Category" } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2023-08-22 10:41:40.577437", + "modified": "2023-08-22 21:59:16.678547", "modified_by": "Administrator", "module": "LMS", "name": "Class Student", diff --git a/lms/lms/doctype/lms_class/lms_class.py b/lms/lms/doctype/lms_class/lms_class.py index 31db3d95..f7457ecd 100644 --- a/lms/lms/doctype/lms_class/lms_class.py +++ b/lms/lms/doctype/lms_class/lms_class.py @@ -185,6 +185,50 @@ def authenticate(): return response.json()["access_token"] +@frappe.whitelist() +def create_class( + title, + start_date, + end_date, + description=None, + prerequisite=None, + seat_count=0, + start_time=None, + end_time=None, + medium="Online", + category=None, + paid_class=0, + amount=0, + currency=None, + name=None, +): + frappe.only_for("Moderator") + if name: + class_details = frappe.get_doc("LMS Class", name) + else: + class_details = frappe.get_doc({"doctype": "LMS Class"}) + + class_details.update( + { + "title": title, + "start_date": start_date, + "end_date": end_date, + "description": description, + "prerequisite": prerequisite, + "seat_count": seat_count, + "start_time": start_time, + "end_time": end_time, + "medium": medium, + "category": category, + "paid_class": paid_class, + "amount": amount, + "currency": currency, + } + ) + class_details.save() + return class_details + + @frappe.whitelist() def fetch_lessons(courses): lessons = [] diff --git a/lms/lms/utils.py b/lms/lms/utils.py index 72832ad9..2385625b 100644 --- a/lms/lms/utils.py +++ b/lms/lms/utils.py @@ -987,5 +987,5 @@ def add_student_to_class(address, response, classname, client): return f"/classes/{classname}" except Exception as e: frappe.throw( - _("Error during payment: {0}. Please contact the Administrator.").format(e) + _("Error during payment: {0} Please contact the Administrator.").format(e) ) diff --git a/lms/public/js/common_functions.js b/lms/public/js/common_functions.js index 39adf583..b70e26f7 100644 --- a/lms/public/js/common_functions.js +++ b/lms/public/js/common_functions.js @@ -354,6 +354,7 @@ const open_class_dialog = () => { default: class_info && class_info.currency, mandatory_depends_on: "paid_class", depends_on: "paid_class", + only_select: 1, }, ], primary_action_label: __("Save"), @@ -365,20 +366,15 @@ const open_class_dialog = () => { }; const save_class = (values) => { - let method, args; + let args = {}; if (class_info) { - method = "frappe.client.save"; args = Object.assign(class_info, values); } else { - method = "frappe.client.insert"; args = values; - args.doctype = "LMS Class"; } frappe.call({ - method: method, - args: { - doc: args, - }, + method: "lms.lms.doctype.lms_class.lms_class.create_class", + args: args, callback: (r) => { if (r.message) { frappe.show_alert({ diff --git a/lms/www/billing/billing.html b/lms/www/billing/billing.html index 4229d863..56e693e1 100644 --- a/lms/www/billing/billing.html +++ b/lms/www/billing/billing.html @@ -20,7 +20,7 @@ {{ _("Order Details") }}
- {{ _("Enter the billing information and complete the payment to purchase this {0}.").format(module) }} + {{ _("Enter the billing information to complete the payment.").format(module) }}
{% endmacro %} @@ -59,11 +59,4 @@ {%- block script %} {{ super() }} - {% endblock %} diff --git a/lms/www/billing/billing.js b/lms/www/billing/billing.js index cc0c6413..9ff7480f 100644 --- a/lms/www/billing/billing.js +++ b/lms/www/billing/billing.js @@ -44,6 +44,7 @@ const setup_billing = () => { fieldname: "country", options: "Country", reqd: 1, + only_select: 1, }, { fieldtype: "Data", @@ -57,6 +58,18 @@ const setup_billing = () => { fieldname: "phone", reqd: 1, }, + { + fieldtype: "Data", + fieldname: "gstin", + label: __("GSTIN"), + depends_on: (doc) => console.log(doc.country), + }, + { + fieldtype: "Data", + fieldname: "pan", + label: __("PAN"), + depends_on: (doc) => console.log(doc.country), + }, ], body: $("#billing-form").get(0), }); diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html index a0a88962..1828fe50 100644 --- a/lms/www/classes/class.html +++ b/lms/www/classes/class.html @@ -600,26 +600,8 @@ {%- block script %} {{ super() }} - {% if is_moderator %} - {% else %} - - {% endif %} - {% endblock %} \ No newline at end of file diff --git a/lms/www/classes/class.js b/lms/www/classes/class.js index 2e629b5c..7ed03667 100644 --- a/lms/www/classes/class.js +++ b/lms/www/classes/class.js @@ -1,11 +1,13 @@ frappe.ready(() => { let self = this; + frappe.require("controls.bundle.js"); if ($("#live-class-form").length) { - frappe.require("controls.bundle.js", () => { + setTimeout(() => { make_live_class_form(); - }); + }, 1000); } + $(".btn-add-student").click((e) => { show_student_modal(e); }); @@ -308,12 +310,14 @@ const show_course_modal = () => { label: __("Course"), fieldname: "course", reqd: 1, + only_select: 1, }, { fieldtype: "Link", options: "Course Evaluator", label: __("Course Evaluator"), fieldname: "evaluator", + only_select: 1, }, ], primary_action_label: __("Add"), @@ -385,6 +389,7 @@ const show_student_modal = () => { label: __("Student"), fieldname: "student", reqd: 1, + only_select: 1, filters: { ignore_user_type: 1, }, @@ -463,6 +468,7 @@ const show_assessment_modal = (e) => { label: __("Assessment Type"), fieldname: "assessment_type", reqd: 1, + only_select: 1, filters: { name: ["in", ["LMS Assignment", "LMS Quiz"]], }, @@ -474,6 +480,7 @@ const show_assessment_modal = (e) => { label: __("Assessment"), fieldname: "assessment_name", reqd: 1, + only_select: 1, }, { fieldtype: "Section Break", diff --git a/lms/www/classes/class_details.html b/lms/www/classes/class_details.html index 713612cf..dff32a70 100644 --- a/lms/www/classes/class_details.html +++ b/lms/www/classes/class_details.html @@ -8,10 +8,10 @@
{{ ClassHeader(class_info) }}
- {{ CourseHeaderOverlay(class_info) }} + {{ CourseHeaderOverlay(class_info, courses, students) }}
{{ Prerequisites(class_info) }} - {{ CourseList(class_info) }} + {{ CourseList(courses) }}
@@ -22,7 +22,7 @@
{{ BreadCrumb(class_info) }} - {{ ClassHeaderDetails(class_info) }} + {{ ClassHeaderDetails(class_info, courses, students) }}
@@ -40,15 +40,15 @@ {% endmacro %} -{% macro ClassHeaderDetails(class_info) %} +{% macro ClassHeaderDetails(class_info, courses, students) %}
- {{ class_info.courses | length }} {{ _("Courses") }} + {{ courses | length }} {{ _("Courses") }} ยท - {{ class_info.students | length }} {{ _("Students") }} + {{ students | length }} {{ _("Students") }}
@@ -88,7 +88,7 @@
{% endmacro %} -{% macro CourseHeaderOverlay(class_info) %} +{% macro CourseHeaderOverlay(class_info, courses, students) %}
@@ -102,14 +102,14 @@ - {{ class_info.courses | length }} {{ _("Courses") }} + {{ courses | length }} {{ _("Courses") }}
- {{ class_info.students | length }} {{ _("Students") }} + {{ students | length }} {{ _("Students") }}
@@ -177,14 +177,14 @@ {% endmacro %} -{% macro CourseList(class_info) %} +{% macro CourseList(courses) %}
{{ _("Courses") }}
- {% if class_info.courses | length %} + {% if courses | length %}
- {% for course in class_info.courses %} + {% for course in courses %}
{{ widgets.CourseCard(course=course, read_only=False) }}