diff --git a/lms/lms/doctype/class_student/class_student.json b/lms/lms/doctype/class_student/class_student.json index 3442dd7c..302f602f 100644 --- a/lms/lms/doctype/class_student/class_student.json +++ b/lms/lms/doctype/class_student/class_student.json @@ -7,39 +7,30 @@ "editable_grid": 1, "engine": "InnoDB", "field_order": [ - "student", - "student_name", - "username" + "class_student", + "student" ], "fields": [ { "fieldname": "student", "fieldtype": "Link", - "in_list_view": 1, + "hidden": 1, "label": "Student", - "options": "User", - "reqd": 1 + "options": "User" }, { - "fetch_from": "student.full_name", - "fieldname": "student_name", - "fieldtype": "Data", + "fieldname": "class_student", + "fieldtype": "Link", "in_list_view": 1, - "label": "Student Name", - "read_only": 1 - }, - { - "fetch_from": "student.username", - "fieldname": "username", - "fieldtype": "Data", - "label": "Username", - "read_only": 1 + "label": "Class Student", + "options": "Class Student Registration", + "reqd": 1 } ], "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2022-11-15 11:13:39.410578", + "modified": "2023-08-18 16:56:34.435008", "modified_by": "Administrator", "module": "LMS", "name": "Class Student", diff --git a/lms/lms/doctype/class_student_registration/__init__.py b/lms/lms/doctype/class_student_registration/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lms/lms/doctype/class_student_registration/class_student_registration.js b/lms/lms/doctype/class_student_registration/class_student_registration.js new file mode 100644 index 00000000..15fa2b5e --- /dev/null +++ b/lms/lms/doctype/class_student_registration/class_student_registration.js @@ -0,0 +1,14 @@ +// Copyright (c) 2023, Frappe and contributors +// For license information, please see license.txt + +frappe.ui.form.on("Class Student Registration", { + onload: function (frm) { + frm.set_query("member", function (doc) { + return { + filters: { + ignore_user_type: 1, + }, + }; + }); + }, +}); diff --git a/lms/lms/doctype/class_student_registration/class_student_registration.json b/lms/lms/doctype/class_student_registration/class_student_registration.json new file mode 100644 index 00000000..4e7ef27d --- /dev/null +++ b/lms/lms/doctype/class_student_registration/class_student_registration.json @@ -0,0 +1,102 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "format:CLS-REG-{#####}", + "creation": "2023-08-18 15:46:54.616815", + "default_view": "List", + "doctype": "DocType", + "editable_grid": 1, + "engine": "InnoDB", + "field_order": [ + "member", + "member_name", + "member_username", + "column_break_zrly", + "class_name", + "address", + "amount", + "currency" + ], + "fields": [ + { + "fieldname": "member", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Member", + "options": "User", + "reqd": 1 + }, + { + "fieldname": "address", + "fieldtype": "Link", + "label": "Address", + "options": "Address" + }, + { + "fieldname": "column_break_zrly", + "fieldtype": "Column Break" + }, + { + "fieldname": "amount", + "fieldtype": "Currency", + "label": "Amount" + }, + { + "fieldname": "currency", + "fieldtype": "Link", + "label": "Currency", + "options": "Currency" + }, + { + "fetch_from": "member.username", + "fieldname": "member_username", + "fieldtype": "Data", + "label": "Member Username", + "read_only": 1 + }, + { + "fieldname": "class_name", + "fieldtype": "Link", + "in_list_view": 1, + "in_standard_filter": 1, + "label": "Class Name", + "options": "LMS Class" + }, + { + "fetch_from": "member.full_name", + "fieldname": "member_name", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Member Name", + "read_only": 1 + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2023-08-18 16:40:01.740071", + "modified_by": "Administrator", + "module": "LMS", + "name": "Class Student Registration", + "naming_rule": "Expression", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "show_title_field_in_link": 1, + "sort_field": "modified", + "sort_order": "DESC", + "states": [], + "title_field": "member_name" +} \ No newline at end of file diff --git a/lms/lms/doctype/class_student_registration/class_student_registration.py b/lms/lms/doctype/class_student_registration/class_student_registration.py new file mode 100644 index 00000000..1555d33f --- /dev/null +++ b/lms/lms/doctype/class_student_registration/class_student_registration.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 ClassStudentRegistration(Document): + pass diff --git a/lms/lms/doctype/class_student_registration/test_class_student_registration.py b/lms/lms/doctype/class_student_registration/test_class_student_registration.py new file mode 100644 index 00000000..62e78c41 --- /dev/null +++ b/lms/lms/doctype/class_student_registration/test_class_student_registration.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestClassStudentRegistration(FrappeTestCase): + pass diff --git a/lms/lms/doctype/lms_class/lms_class.js b/lms/lms/doctype/lms_class/lms_class.js index 7f3c4299..342b6ae2 100644 --- a/lms/lms/doctype/lms_class/lms_class.js +++ b/lms/lms/doctype/lms_class/lms_class.js @@ -3,10 +3,10 @@ frappe.ui.form.on("LMS Class", { onload: function (frm) { - frm.set_query("student", "students", function (doc) { + frm.set_query("class_student", "students", function (doc) { return { filters: { - ignore_user_type: 1, + class_name: doc.name, }, }; }); diff --git a/lms/patches.txt b/lms/patches.txt index bcabe386..dea5f0b6 100644 --- a/lms/patches.txt +++ b/lms/patches.txt @@ -61,4 +61,5 @@ execute:frappe.permissions.reset_perms("LMS Class") execute:frappe.permissions.reset_perms("Course Evaluator") execute:frappe.permissions.reset_perms("LMS Certificate Request") execute:frappe.permissions.reset_perms("LMS Certificate Evaluation") -lms.patches.v1_0.paid_certificate_to_paid_course \ No newline at end of file +lms.patches.v1_0.paid_certificate_to_paid_course #18-08-2023 +lms.patches.v1_0.create_class_student_registration #19-08-2023 \ No newline at end of file diff --git a/lms/patches/v1_0/create_class_student_registration.py b/lms/patches/v1_0/create_class_student_registration.py new file mode 100644 index 00000000..7507f28b --- /dev/null +++ b/lms/patches/v1_0/create_class_student_registration.py @@ -0,0 +1,23 @@ +import frappe + + +def execute(): + frappe.reload_doc("lms", "doctype", "class_student") + frappe.reload_doc("lms", "doctype", "class_student_registration") + + students = frappe.get_all( + "Class Student", {"parent": ["is", "set"]}, ["name", "student", "parent"] + ) + + for student in students: + student_details = frappe.db.get_value( + "User", student.student, ["full_name", "username"], as_dict=1 + ) + registration = frappe.new_doc("Class Student Registration") + registration.member = student.student + registration.member_name = student_details.full_name + registration.member_username = student_details.username + registration.class_name = student.parent + registration.save() + + frappe.db.set_value("Class Student", student.name, "class_student", registration.name) diff --git a/lms/patches/v1_0/paid_certificate_to_paid_course.py b/lms/patches/v1_0/paid_certificate_to_paid_course.py index 88ec708b..64b744cf 100644 --- a/lms/patches/v1_0/paid_certificate_to_paid_course.py +++ b/lms/patches/v1_0/paid_certificate_to_paid_course.py @@ -2,6 +2,7 @@ import frappe def execute(): + frappe.reload_doc("lms", "doctype", "lms_course") courses = frappe.get_all( "LMS Course", {"paid_certificate": ["is", "set"]},