Configurable validation setting for the student group
This commit is contained in:
parent
1b6270ef40
commit
71373a176d
@ -13,6 +13,7 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@ -43,6 +44,7 @@
|
|||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@ -73,6 +75,7 @@
|
|||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@ -100,6 +103,66 @@
|
|||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fieldname": "column_break_4",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "validation_from_pe",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Validate the Student Group from Program Enrollment",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"has_web_view": 0,
|
||||||
@ -112,7 +175,7 @@
|
|||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2017-04-05 13:34:57.493516",
|
"modified": "2017-04-27 15:37:00.159072",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "School Settings",
|
"name": "School Settings",
|
||||||
|
@ -11,6 +11,7 @@ school_keydict = {
|
|||||||
# "key in defaults": "key in Global Defaults"
|
# "key in defaults": "key in Global Defaults"
|
||||||
"academic_year": "current_academic_year",
|
"academic_year": "current_academic_year",
|
||||||
"academic_term": "current_academic_term",
|
"academic_term": "current_academic_term",
|
||||||
|
"student_validation_setting": "validation_from_pe",
|
||||||
}
|
}
|
||||||
|
|
||||||
class SchoolSettings(Document):
|
class SchoolSettings(Document):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
cur_frm.add_fetch("student", "title", "student_name");
|
cur_frm.add_fetch("student", "title", "student_name");
|
||||||
|
|
||||||
frappe.ui.form.on("Student Group", {
|
frappe.ui.form.on("Student Group", {
|
||||||
onload: function(frm) {
|
onload: function(frm) {
|
||||||
@ -43,6 +43,11 @@ frappe.ui.form.on("Student Group", {
|
|||||||
frm.doc.program = null;
|
frm.doc.program = null;
|
||||||
frm.doc.batch = null;
|
frm.doc.batch = null;
|
||||||
}
|
}
|
||||||
|
else if (frm.doc.group_based_on == "Activity") {
|
||||||
|
frm.doc.program =null;
|
||||||
|
frm.doc.batch =null;
|
||||||
|
frm.doc.CourseQ =null;
|
||||||
|
}
|
||||||
frm.trigger("set_name");
|
frm.trigger("set_name");
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -103,6 +108,7 @@ frappe.ui.form.on("Student Group", {
|
|||||||
s.group_roll_number = ++max_roll_no;
|
s.group_roll_number = ++max_roll_no;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
refresh_field("students");
|
||||||
frm.save();
|
frm.save();
|
||||||
} else {
|
} else {
|
||||||
frappe.msgprint(__("Student Group is already updated."))
|
frappe.msgprint(__("Student Group is already updated."))
|
||||||
|
@ -75,6 +75,37 @@
|
|||||||
"set_only_once": 1,
|
"set_only_once": 1,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"depends_on": "eval: doc.batch || doc.course || doc.group_based_on == \"Activity\"",
|
||||||
|
"fieldname": "student_group_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Student Group Name",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -172,7 +203,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"depends_on": "eval:doc.group_based_on == 'Batch'",
|
"depends_on": "eval:doc.group_based_on == 'Batch' || doc.group_based_on == 'Course' ",
|
||||||
"fieldname": "program",
|
"fieldname": "program",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -204,7 +235,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"depends_on": "eval:doc.group_based_on == 'Batch'",
|
"depends_on": "eval:doc.group_based_on == 'Batch' || doc.group_based_on == 'Course' ",
|
||||||
"fieldname": "batch",
|
"fieldname": "batch",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -262,37 +293,6 @@
|
|||||||
"set_only_once": 1,
|
"set_only_once": 1,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"depends_on": "group_based_on",
|
|
||||||
"fieldname": "student_group_name",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 0,
|
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Student Group Name",
|
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"print_hide_if_no_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"remember_last_selected_value": 0,
|
|
||||||
"report_hide": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"search_index": 0,
|
|
||||||
"set_only_once": 0,
|
|
||||||
"unique": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
@ -459,7 +459,7 @@
|
|||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"menu_index": 0,
|
"menu_index": 0,
|
||||||
"modified": "2017-04-24 15:53:35.593913",
|
"modified": "2017-04-25 18:26:27.414487",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Schools",
|
"module": "Schools",
|
||||||
"name": "Student Group",
|
"name": "Student Group",
|
||||||
|
@ -13,7 +13,8 @@ class StudentGroup(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_mandatory_fields()
|
self.validate_mandatory_fields()
|
||||||
self.validate_strength()
|
self.validate_strength()
|
||||||
self.validate_students()
|
if frappe.defaults.get_defaults().student_validation_setting
|
||||||
|
self.validate_students()
|
||||||
validate_duplicate_student(self.students)
|
validate_duplicate_student(self.students)
|
||||||
|
|
||||||
def validate_mandatory_fields(self):
|
def validate_mandatory_fields(self):
|
||||||
@ -39,6 +40,7 @@ class StudentGroup(Document):
|
|||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_students(academic_year, group_based_on, program=None, batch=None, course=None):
|
def get_students(academic_year, group_based_on, program=None, batch=None, course=None):
|
||||||
enrolled_students = get_program_enrollment(academic_year, group_based_on, program, batch, course)
|
enrolled_students = get_program_enrollment(academic_year, group_based_on, program, batch, course)
|
||||||
|
print enrolled_students
|
||||||
|
|
||||||
if enrolled_students:
|
if enrolled_students:
|
||||||
student_list = []
|
student_list = []
|
||||||
@ -51,18 +53,30 @@ def get_students(academic_year, group_based_on, program=None, batch=None, course
|
|||||||
return student_list
|
return student_list
|
||||||
|
|
||||||
def get_program_enrollment(academic_year, group_based_on, program=None, batch=None, course=None):
|
def get_program_enrollment(academic_year, group_based_on, program=None, batch=None, course=None):
|
||||||
if group_based_on == "Batch":
|
|
||||||
return frappe.db.sql('''select student, student_name from `tabProgram Enrollment` where academic_year = %s
|
condition_course = " and pe.name = pec.parent and pec.course = %(course)s"
|
||||||
and program = %s and student_batch_name = %s order by student_name asc''',(academic_year, program, batch), as_dict=1)
|
condition1_course = ", `tabProgram Enrollment Course` pec"
|
||||||
|
condition_batch = " and pe.program = %(program)s and pe.student_batch_name = %(batch)s"
|
||||||
|
|
||||||
|
if group_based_on == "Batch":
|
||||||
|
condition1 = ""
|
||||||
|
condition2 = condition_batch
|
||||||
|
elif group_based_on == "Course" and not (program and batch):
|
||||||
|
condition1 = condition1_course
|
||||||
|
condition2 = condition_course
|
||||||
|
elif group_based_on == "Course" and program and batch:
|
||||||
|
condition1 = condition1_course
|
||||||
|
condition2 = condition_course + condition_batch
|
||||||
|
|
||||||
|
return frappe.db.sql('''
|
||||||
|
select
|
||||||
|
pe.student, pe.student_name
|
||||||
|
from
|
||||||
|
`tabProgram Enrollment` pe {condition1}
|
||||||
|
where
|
||||||
|
pe.academic_year = %(academic_year)s {condition2}
|
||||||
|
order by
|
||||||
|
pe.student_name asc
|
||||||
|
'''.format(condition1=condition1, condition2=condition2),
|
||||||
|
({"academic_year": academic_year, "program": program, "batch": batch, "course": course}), as_dict=1)
|
||||||
|
|
||||||
elif group_based_on == "Course":
|
|
||||||
return frappe.db.sql('''
|
|
||||||
select
|
|
||||||
pe.student, pe.student_name
|
|
||||||
from
|
|
||||||
`tabProgram Enrollment` pe, `tabProgram Enrollment Course` pec
|
|
||||||
where
|
|
||||||
pe.name = pec.parent and pec.course = %s
|
|
||||||
order by
|
|
||||||
pe.student_name asc
|
|
||||||
''', (course), as_dict=1)
|
|
Loading…
Reference in New Issue
Block a user