From f521a9c601ab0c6ede4d20a84f1e2a5232d2ecae Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Fri, 22 Jul 2016 01:28:41 +0530 Subject: [PATCH] Added Student Batch --- erpnext/schools/doctype/course/course.json | 76 +++++- erpnext/schools/doctype/program/program.json | 29 ++- .../schools/doctype/student_batch/__init__.py | 0 .../doctype/student_batch/student_batch.js | 10 + .../doctype/student_batch/student_batch.json | 237 ++++++++++++++++++ .../doctype/student_batch/student_batch.py | 16 ++ .../student_batch/test_student_batch.py | 12 + .../doctype/student_batch_student/__init__.py | 0 .../student_batch_student.json | 113 +++++++++ .../student_batch_student.py | 10 + .../doctype/student_group/student_group.json | 31 ++- .../doctype/student_group/student_group.py | 24 +- erpnext/schools/utils.py | 9 + 13 files changed, 556 insertions(+), 11 deletions(-) create mode 100644 erpnext/schools/doctype/student_batch/__init__.py create mode 100644 erpnext/schools/doctype/student_batch/student_batch.js create mode 100644 erpnext/schools/doctype/student_batch/student_batch.json create mode 100644 erpnext/schools/doctype/student_batch/student_batch.py create mode 100644 erpnext/schools/doctype/student_batch/test_student_batch.py create mode 100644 erpnext/schools/doctype/student_batch_student/__init__.py create mode 100644 erpnext/schools/doctype/student_batch_student/student_batch_student.json create mode 100644 erpnext/schools/doctype/student_batch_student/student_batch_student.py diff --git a/erpnext/schools/doctype/course/course.json b/erpnext/schools/doctype/course/course.json index f3d82e6814..ab73dcb15c 100644 --- a/erpnext/schools/doctype/course/course.json +++ b/erpnext/schools/doctype/course/course.json @@ -9,6 +9,7 @@ "docstatus": 0, "doctype": "DocType", "document_type": "", + "editable_grid": 0, "fields": [ { "allow_on_submit": 0, @@ -60,6 +61,55 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "column_break_3", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "course_abbreviation", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Course Abbreviation", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -86,6 +136,30 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "section_break_6", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -123,7 +197,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-07-18 10:30:50.243271", + "modified": "2016-07-22 06:02:14.586594", "modified_by": "Administrator", "module": "Schools", "name": "Course", diff --git a/erpnext/schools/doctype/program/program.json b/erpnext/schools/doctype/program/program.json index 8041f61e7a..279430d2b8 100644 --- a/erpnext/schools/doctype/program/program.json +++ b/erpnext/schools/doctype/program/program.json @@ -9,6 +9,7 @@ "docstatus": 0, "doctype": "DocType", "document_type": "", + "editable_grid": 0, "fields": [ { "allow_on_submit": 0, @@ -60,6 +61,31 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "program_abbreviation", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Program Abbreviation", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -216,6 +242,7 @@ "hide_heading": 0, "hide_toolbar": 0, "idx": 0, + "image_view": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 0, @@ -223,7 +250,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-07-18 10:30:50.243271", + "modified": "2016-07-22 05:35:14.470843", "modified_by": "Administrator", "module": "Schools", "name": "Program", diff --git a/erpnext/schools/doctype/student_batch/__init__.py b/erpnext/schools/doctype/student_batch/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/schools/doctype/student_batch/student_batch.js b/erpnext/schools/doctype/student_batch/student_batch.js new file mode 100644 index 0000000000..73d4faae01 --- /dev/null +++ b/erpnext/schools/doctype/student_batch/student_batch.js @@ -0,0 +1,10 @@ +// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Student Batch', { + refresh: function(frm) { + + } +}); + +cur_frm.add_fetch("student", "title", "student_name"); diff --git a/erpnext/schools/doctype/student_batch/student_batch.json b/erpnext/schools/doctype/student_batch/student_batch.json new file mode 100644 index 0000000000..f153845986 --- /dev/null +++ b/erpnext/schools/doctype/student_batch/student_batch.json @@ -0,0 +1,237 @@ +{ + "allow_copy": 0, + "allow_import": 0, + "allow_rename": 0, + "autoname": "", + "beta": 0, + "creation": "2016-07-21 15:49:53.776461", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "fields": [ + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "student_batch_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Student Batch Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "academic_year", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Academic Year", + "length": 0, + "no_copy": 0, + "options": "Academic Year", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "program", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Program", + "length": 0, + "no_copy": 0, + "options": "Program", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "academic_term", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Academic Term", + "length": 0, + "no_copy": 0, + "options": "Academic Year", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "section_break_8", + "fieldtype": "Section Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "students", + "fieldtype": "Table", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Students", + "length": 0, + "no_copy": 0, + "options": "Student Batch Student", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "in_dialog": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2016-07-22 05:31:12.683404", + "modified_by": "Administrator", + "module": "Schools", + "name": "Student Batch", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "Academics User", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "sort_field": "modified", + "sort_order": "DESC", + "title_field": "", + "track_seen": 0 +} \ No newline at end of file diff --git a/erpnext/schools/doctype/student_batch/student_batch.py b/erpnext/schools/doctype/student_batch/student_batch.py new file mode 100644 index 0000000000..7c7568dc77 --- /dev/null +++ b/erpnext/schools/doctype/student_batch/student_batch.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +from frappe.model.document import Document +from erpnext.schools.utils import validate_duplicate_student +import frappe + +class StudentBatch(Document): + def validate(self): + validate_duplicate_student(self.students) + prog_abb = frappe.db.get_value("Program", self.program, "program_abbreviation") + if not prog_abb: + prog_abb = self.program + self.name = prog_abb + "-"+ self.student_batch_name + "-" + self.academic_year \ No newline at end of file diff --git a/erpnext/schools/doctype/student_batch/test_student_batch.py b/erpnext/schools/doctype/student_batch/test_student_batch.py new file mode 100644 index 0000000000..55796eeb72 --- /dev/null +++ b/erpnext/schools/doctype/student_batch/test_student_batch.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +# test_records = frappe.get_test_records('Student Batch') + +class TestStudentBatch(unittest.TestCase): + pass diff --git a/erpnext/schools/doctype/student_batch_student/__init__.py b/erpnext/schools/doctype/student_batch_student/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/schools/doctype/student_batch_student/student_batch_student.json b/erpnext/schools/doctype/student_batch_student/student_batch_student.json new file mode 100644 index 0000000000..c9b1b01cc5 --- /dev/null +++ b/erpnext/schools/doctype/student_batch_student/student_batch_student.json @@ -0,0 +1,113 @@ +{ + "allow_copy": 0, + "allow_import": 0, + "allow_rename": 0, + "beta": 0, + "creation": "2016-07-22 03:27:20.120023", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "fields": [ + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "student", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Student", + "length": 0, + "no_copy": 0, + "options": "Student", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "column_break_2", + "fieldtype": "Column Break", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "student_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 1, + "label": "Student Name", + "length": 0, + "no_copy": 0, + "options": "", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_view": 0, + "in_create": 0, + "in_dialog": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 1, + "max_attachments": 0, + "modified": "2016-07-22 03:27:52.913126", + "modified_by": "Administrator", + "module": "Schools", + "name": "Student Batch Student", + "name_case": "", + "owner": "Administrator", + "permissions": [], + "quick_entry": 1, + "read_only": 0, + "read_only_onload": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_seen": 0 +} \ No newline at end of file diff --git a/erpnext/schools/doctype/student_batch_student/student_batch_student.py b/erpnext/schools/doctype/student_batch_student/student_batch_student.py new file mode 100644 index 0000000000..542f3c4da9 --- /dev/null +++ b/erpnext/schools/doctype/student_batch_student/student_batch_student.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class StudentBatchStudent(Document): + pass diff --git a/erpnext/schools/doctype/student_group/student_group.json b/erpnext/schools/doctype/student_group/student_group.json index 38a7747515..b2c115700d 100644 --- a/erpnext/schools/doctype/student_group/student_group.json +++ b/erpnext/schools/doctype/student_group/student_group.json @@ -2,33 +2,37 @@ "allow_copy": 0, "allow_import": 0, "allow_rename": 0, - "autoname": "field:group_name", + "autoname": "", + "beta": 0, "creation": "2015-09-07 12:55:52.072792", "custom": 0, "docstatus": 0, "doctype": "DocType", "document_type": "Document", + "editable_grid": 0, "fields": [ { "allow_on_submit": 0, "bold": 0, "collapsible": 0, - "fieldname": "group_name", - "fieldtype": "Data", + "fieldname": "student_batch", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, - "label": "Group Name", + "label": "Student Batch", "length": 0, "no_copy": 0, + "options": "Student Batch", "permlevel": 0, "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, "report_hide": 0, - "reqd": 1, + "reqd": 0, "search_index": 0, "set_only_once": 0, "unique": 0 @@ -41,6 +45,7 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Academic Term", @@ -66,6 +71,7 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Academic Year", @@ -91,6 +97,7 @@ "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "length": 0, @@ -114,6 +121,7 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Program", @@ -139,6 +147,7 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 1, "label": "Course", @@ -165,6 +174,7 @@ "fieldtype": "Int", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Max Strength", @@ -190,6 +200,7 @@ "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Students", @@ -214,6 +225,7 @@ "fieldtype": "Table", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Students", @@ -239,6 +251,7 @@ "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, + "ignore_xss_filter": 0, "in_filter": 0, "in_list_view": 0, "label": "Amended From", @@ -259,6 +272,7 @@ "hide_heading": 0, "hide_toolbar": 0, "idx": 0, + "image_view": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 0, @@ -266,7 +280,7 @@ "istable": 0, "max_attachments": 0, "menu_index": 0, - "modified": "2016-07-18 10:30:50.243271", + "modified": "2016-07-22 06:12:10.092544", "modified_by": "Administrator", "module": "Schools", "name": "Student Group", @@ -314,11 +328,12 @@ "write": 1 } ], + "quick_entry": 0, "read_only": 0, "read_only_onload": 0, "search_fields": "program, course", "sort_field": "modified", "sort_order": "DESC", - "title_field": "group_name", - "version": 0 + "title_field": "", + "track_seen": 0 } \ No newline at end of file diff --git a/erpnext/schools/doctype/student_group/student_group.py b/erpnext/schools/doctype/student_group/student_group.py index 0acbed9294..3cd9bfbee8 100644 --- a/erpnext/schools/doctype/student_group/student_group.py +++ b/erpnext/schools/doctype/student_group/student_group.py @@ -6,12 +6,32 @@ from __future__ import unicode_literals import frappe from frappe.model.document import Document from frappe import _ +from erpnext.schools.utils import validate_duplicate_student class StudentGroup(Document): def validate(self): + self.set_name() self.validate_strength() self.validate_student_name() - + validate_duplicate_student(self.students) + + def set_name(self): + self.name = frappe.db.get_value("Course", self.course, "course_abbreviation") + if not self.name: + self.name = self.course + if self.student_batch: + self.name += "-" + self.student_batch + else: + prog_abb = frappe.db.get_value("Program", self.program, "program_abbreviation") + if not prog_abb: + prog_abb = self.program + if prog_abb: + self.name += "-" + prog_abb + if self.academic_year: + self.name += "-" + self.academic_year + if self.academic_term: + self.name += "-" + self.academic_term + def validate_strength(self): if self.max_strength and len(self.students) > self.max_strength: frappe.throw(_("""Cannot enroll more than {0} students for this student group.""").format(self.max_strength)) @@ -19,3 +39,5 @@ class StudentGroup(Document): def validate_student_name(self): for d in self.students: d.student_name = frappe.db.get_value("Student", d.student, "title") + + \ No newline at end of file diff --git a/erpnext/schools/utils.py b/erpnext/schools/utils.py index c7e92c2c42..3adbae4b5e 100644 --- a/erpnext/schools/utils.py +++ b/erpnext/schools/utils.py @@ -42,3 +42,12 @@ def get_overlap_for(doc, doctype, fieldname, value=None): }, as_dict=True) return existing[0] if existing else None + +def validate_duplicate_student(students): + unique_students= [] + for stud in students: + if stud.student in unique_students: + frappe.throw(_("Student {0} - {1} appears Multiple times in row {2} & {3}") + .format(stud.student, stud.student_name, unique_students.index(stud.student)+1, stud.idx)) + else: + unique_students.append(stud.student)