From 1ff8514b22bb613c974c6f608260543e2e6a16ab Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Thu, 15 Jun 2023 17:07:28 +0530 Subject: [PATCH] feat: class medium and category --- lms/lms/doctype/lms_category/__init__.py | 0 lms/lms/doctype/lms_category/lms_category.js | 8 +++ .../doctype/lms_category/lms_category.json | 59 +++++++++++++++++++ lms/lms/doctype/lms_category/lms_category.py | 9 +++ .../doctype/lms_category/test_lms_category.py | 9 +++ lms/lms/doctype/lms_class/lms_class.json | 32 ++++++++-- lms/lms/doctype/lms_class/lms_class.py | 4 ++ lms/public/css/style.css | 4 ++ lms/public/js/common_functions.js | 32 +++++++--- lms/www/classes/class.html | 4 +- lms/www/classes/class.py | 2 + lms/www/classes/index.html | 11 ++++ 12 files changed, 160 insertions(+), 14 deletions(-) create mode 100644 lms/lms/doctype/lms_category/__init__.py create mode 100644 lms/lms/doctype/lms_category/lms_category.js create mode 100644 lms/lms/doctype/lms_category/lms_category.json create mode 100644 lms/lms/doctype/lms_category/lms_category.py create mode 100644 lms/lms/doctype/lms_category/test_lms_category.py diff --git a/lms/lms/doctype/lms_category/__init__.py b/lms/lms/doctype/lms_category/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lms/lms/doctype/lms_category/lms_category.js b/lms/lms/doctype/lms_category/lms_category.js new file mode 100644 index 00000000..00dd9559 --- /dev/null +++ b/lms/lms/doctype/lms_category/lms_category.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, Frappe and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("LMS Category", { +// refresh(frm) { + +// }, +// }); diff --git a/lms/lms/doctype/lms_category/lms_category.json b/lms/lms/doctype/lms_category/lms_category.json new file mode 100644 index 00000000..bd5ede67 --- /dev/null +++ b/lms/lms/doctype/lms_category/lms_category.json @@ -0,0 +1,59 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:category", + "creation": "2023-06-15 12:40:36.484165", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "category" + ], + "fields": [ + { + "fieldname": "category", + "fieldtype": "Data", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Category", + "unique": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2023-06-15 15:14:11.341961", + "modified_by": "Administrator", + "module": "LMS", + "name": "LMS Category", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "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", + "sort_order": "DESC", + "states": [], + "title_field": "category" +} \ No newline at end of file diff --git a/lms/lms/doctype/lms_category/lms_category.py b/lms/lms/doctype/lms_category/lms_category.py new file mode 100644 index 00000000..53344c7f --- /dev/null +++ b/lms/lms/doctype/lms_category/lms_category.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class LMSCategory(Document): + pass diff --git a/lms/lms/doctype/lms_category/test_lms_category.py b/lms/lms/doctype/lms_category/test_lms_category.py new file mode 100644 index 00000000..224a9e7c --- /dev/null +++ b/lms/lms/doctype/lms_category/test_lms_category.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestLMSCategory(FrappeTestCase): + pass diff --git a/lms/lms/doctype/lms_class/lms_class.json b/lms/lms/doctype/lms_class/lms_class.json index a1c69f44..6a69486d 100644 --- a/lms/lms/doctype/lms_class/lms_class.json +++ b/lms/lms/doctype/lms_class/lms_class.json @@ -11,11 +11,15 @@ "title", "start_date", "end_date", - "paid_class", "column_break_4", - "seat_count", - "start_time", "end_time", + "start_time", + "section_break_rgfj", + "medium", + "category", + "column_break_flwy", + "seat_count", + "paid_class", "section_break_6", "description", "students", @@ -109,11 +113,31 @@ "fieldtype": "Table", "label": "Assessment", "options": "LMS Assessment" + }, + { + "fieldname": "section_break_rgfj", + "fieldtype": "Section Break" + }, + { + "default": "Online", + "fieldname": "medium", + "fieldtype": "Select", + "label": "Medium", + "options": "Online\nOffline" + }, + { + "fieldname": "column_break_flwy", + "fieldtype": "Column Break" + }, + { + "fieldname": "category", + "fieldtype": "Autocomplete", + "label": "Category" } ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-05-29 14:52:45.866901", + "modified": "2023-06-15 12:30:26.929156", "modified_by": "Administrator", "module": "LMS", "name": "LMS Class", diff --git a/lms/lms/doctype/lms_class/lms_class.py b/lms/lms/doctype/lms_class/lms_class.py index abca9c15..634f41e6 100644 --- a/lms/lms/doctype/lms_class/lms_class.py +++ b/lms/lms/doctype/lms_class/lms_class.py @@ -160,6 +160,8 @@ def create_class( seat_count=0, start_time=None, end_time=None, + medium="Online", + category=None, name=None, ): if name: @@ -176,6 +178,8 @@ def create_class( "seat_count": seat_count, "start_time": start_time, "end_time": end_time, + "medium": medium, + "category": category, } ) class_details.save() diff --git a/lms/public/css/style.css b/lms/public/css/style.css index 7169ada5..241aab80 100644 --- a/lms/public/css/style.css +++ b/lms/public/css/style.css @@ -2163,4 +2163,8 @@ select { .list-row:last-child { border-bottom: none; +} + +.awesomplete ul li:last-child { + display: none; } \ No newline at end of file diff --git a/lms/public/js/common_functions.js b/lms/public/js/common_functions.js index 20686c04..9308c654 100644 --- a/lms/public/js/common_functions.js +++ b/lms/public/js/common_functions.js @@ -258,7 +258,7 @@ const show_no_preview_dialog = (e) => { $("#no-preview-modal").modal("show"); }; -const open_class_dialog = (e) => { +const open_class_dialog = () => { this.class_dialog = new frappe.ui.Dialog({ title: __("New Class"), fields: [ @@ -284,13 +284,14 @@ const open_class_dialog = (e) => { default: class_info && class_info.end_date, }, { - fieldtype: "Column Break", + fieldtype: "Select", + label: __("Medium"), + fieldname: "medium", + options: ["Online", "Offline"], + default: (class_info && class_info.medium) || "Online", }, { - fieldtype: "Int", - label: __("Seat Count"), - fieldname: "seat_count", - default: class_info && class_info.seat_count, + fieldtype: "Column Break", }, { fieldtype: "Time", @@ -304,6 +305,19 @@ const open_class_dialog = (e) => { fieldname: "end_time", default: class_info && class_info.end_time, }, + { + fieldtype: "Int", + label: __("Seat Count"), + fieldname: "seat_count", + default: class_info && class_info.seat_count, + }, + { + fieldtype: "Link", + label: __("Category"), + fieldname: "category", + options: "LMS Category", + default: class_info && class_info.category, + }, { fieldtype: "Section Break", }, @@ -316,13 +330,13 @@ const open_class_dialog = (e) => { ], primary_action_label: __("Save"), primary_action: (values) => { - create_class(values); + save_class(values); }, }); this.class_dialog.show(); }; -const create_class = (values) => { +const save_class = (values) => { frappe.call({ method: "lms.lms.doctype.lms_class.lms_class.create_class", args: { @@ -333,6 +347,8 @@ const create_class = (values) => { seat_count: values.seat_count, start_time: values.start_time, end_time: values.end_time, + medium: values.medium, + category: values.category, name: class_info && class_info.name, }, callback: (r) => { diff --git a/lms/www/classes/class.html b/lms/www/classes/class.html index 6822afd4..50cd4a0a 100644 --- a/lms/www/classes/class.html +++ b/lms/www/classes/class.html @@ -459,8 +459,8 @@ {% endif %}