feat: class medium and category

This commit is contained in:
Jannat Patel
2023-06-15 17:07:28 +05:30
parent af9aa3e37b
commit 1ff8514b22
12 changed files with 160 additions and 14 deletions

View File

View File

@@ -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) {
// },
// });

View File

@@ -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"
}

View File

@@ -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

View File

@@ -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

View File

@@ -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",

View File

@@ -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()

View File

@@ -2163,4 +2163,8 @@ select {
.list-row:last-child {
border-bottom: none;
}
.awesomplete ul li:last-child {
display: none;
}

View File

@@ -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) => {

View File

@@ -459,8 +459,8 @@
<script>
frappe.boot.user = {
"can_create": [],
"can_select": ["User"],
"can_read": ["User"]
"can_select": ["User", "LMS Category"],
"can_read": ["User", "LMS Category"]
};
frappe.router = {

View File

@@ -25,6 +25,8 @@ def get_context(context):
"seat_count",
"start_time",
"end_time",
"category",
"medium",
],
as_dict=True,
)

View File

@@ -146,6 +146,17 @@
{{ include_script('controls.bundle.js') }}
{% if is_moderator %}
<script>
frappe.boot.user = {
"can_create": [],
"can_select": ["LMS Category"],
"can_read": ["LMS Category"]
};
frappe.router = {
slug (name) {
return name.toLowerCase().replace(/ /g, "-");
}
}
let class_info = null;
</script>
{% endif %}