Added ability to mark student batch in-active

This commit is contained in:
Neil Trini Lasrado
2016-11-28 18:09:50 +05:30
parent 331361d03b
commit 87edfef0bb
12 changed files with 149 additions and 43 deletions

View File

@@ -7,6 +7,16 @@ cur_frm.add_fetch("supervisor", "instructor_name", "supervisor_name");
cur_frm.add_fetch("student", "title", "student_name"); cur_frm.add_fetch("student", "title", "student_name");
frappe.ui.form.on("Assessment" ,{ frappe.ui.form.on("Assessment" ,{
onload: function(frm){
cur_frm.set_query("student_batch", function(){
return{
"filters": {
"active": 1
}
};
});
},
student_group : function(frm) { student_group : function(frm) {
frm.set_value("results" ,""); frm.set_value("results" ,"");
if (frm.doc.student_group) { if (frm.doc.student_group) {

View File

@@ -6,11 +6,15 @@ from __future__ import unicode_literals
from frappe.model.document import Document from frappe.model.document import Document
import frappe import frappe
from frappe import _ from frappe import _
from erpnext.schools.doctype.student_batch.student_batch import validate_active_student_batch
class Assessment(Document): class Assessment(Document):
def validate(self): def validate(self):
self.validate_overlap() self.validate_overlap()
if self.student_batch:
validate_active_student_batch(self.student_batch)
def validate_overlap(self): def validate_overlap(self):
"""Validates overlap for Student Group/Student Batch, Instructor, Room""" """Validates overlap for Student Group/Student Batch, Instructor, Room"""

View File

@@ -9,6 +9,14 @@ frappe.ui.form.on("Course Schedule" ,{
frm.doc.from_time = from_datetime.format("HH:mm:ss"); frm.doc.from_time = from_datetime.format("HH:mm:ss");
frm.doc.to_time = to_datetime.format("HH:mm:ss"); frm.doc.to_time = to_datetime.format("HH:mm:ss");
} }
cur_frm.set_query("student_batch", function(){
return{
"filters": {
"active": 1
}
};
});
}, },
refresh :function(frm) { refresh :function(frm) {

View File

@@ -6,6 +6,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe import _ from frappe import _
from frappe.model.document import Document from frappe.model.document import Document
from erpnext.schools.doctype.student_batch.student_batch import validate_active_student_batch
class CourseSchedule(Document): class CourseSchedule(Document):
def validate(self): def validate(self):
@@ -17,6 +18,9 @@ class CourseSchedule(Document):
self.validate_date() self.validate_date()
self.validate_overlap() self.validate_overlap()
if self.student_batch:
validate_active_student_batch(self.student_batch)
def set_title(self): def set_title(self):
"""Set document Title""" """Set document Title"""
self.title = self.course + " by " + (self.instructor_name if self.instructor_name else self.instructor) self.title = self.course + " by " + (self.instructor_name if self.instructor_name else self.instructor)

View File

@@ -7,12 +7,25 @@ cur_frm.add_fetch("student_group", "course", "course");
cur_frm.add_fetch("student_group", "academic_year", "academic_year"); cur_frm.add_fetch("student_group", "academic_year", "academic_year");
cur_frm.add_fetch("student_group", "academic_term", "academic_term"); cur_frm.add_fetch("student_group", "academic_term", "academic_term");
frappe.ui.form.on("Course Scheduling Tool", "refresh", function(frm) { frappe.ui.form.on("Course Scheduling Tool", {
frm.disable_save();
frm.page.set_primary_action(__("Schedule Course"), function() { refresh: function(frm) {
frappe.call({ frm.disable_save();
method: "schedule_course", frm.page.set_primary_action(__("Schedule Course"), function() {
doc:frm.doc frappe.call({
}) method: "schedule_course",
}); doc:frm.doc
})
});
},
onload: function(frm){
cur_frm.set_query("student_batch", function(){
return{
"filters": {
"active": 1
}
};
});
}
}); });

View File

@@ -5,7 +5,13 @@ cur_frm.add_fetch("course_schedule", "schedule_date", "date");
cur_frm.add_fetch("course_schedule", "student_batch", "student_batch"); cur_frm.add_fetch("course_schedule", "student_batch", "student_batch");
frappe.ui.form.on('Student Attendance', { frappe.ui.form.on('Student Attendance', {
refresh: function(frm) { onload: function(frm){
cur_frm.set_query("student_batch", function(){
return{
"filters": {
"active": 1
}
};
});
} }
}); });

View File

@@ -6,6 +6,7 @@ from __future__ import unicode_literals
import frappe import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe import _ from frappe import _
from erpnext.schools.doctype.student_batch.student_batch import validate_active_student_batch
class StudentAttendance(Document): class StudentAttendance(Document):
def validate(self): def validate(self):
@@ -13,6 +14,9 @@ class StudentAttendance(Document):
self.validate_mandatory() self.validate_mandatory()
self.validate_duplication() self.validate_duplication()
if self.student_batch:
validate_active_student_batch(self.student_batch)
def validate_date(self): def validate_date(self):
if self.course_schedule: if self.course_schedule:
self.date = frappe.db.get_value("Course Schedule", self.course_schedule, "schedule_date") self.date = frappe.db.get_value("Course Schedule", self.course_schedule, "schedule_date")

View File

@@ -70,6 +70,35 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 0 "unique": 0
}, },
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "1",
"fieldname": "active",
"fieldtype": "Check",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Active",
"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_on_submit": 0, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@@ -280,7 +309,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-11-21 19:08:05.775954", "modified": "2016-11-28 16:59:31.270816",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Schools", "module": "Schools",
"name": "Student Batch", "name": "Student Batch",

View File

@@ -6,14 +6,18 @@ from __future__ import unicode_literals
from frappe.model.document import Document from frappe.model.document import Document
from erpnext.schools.utils import validate_duplicate_student from erpnext.schools.utils import validate_duplicate_student
import frappe import frappe
from frappe import _
class StudentBatch(Document): class StudentBatch(Document):
def autoname(self): def autoname(self):
prog_abb = frappe.db.get_value("Program", self.program, "program_abbreviation") prog_abb = frappe.db.get_value("Program", self.program, "program_abbreviation")
if not prog_abb: if not prog_abb:
prog_abb = self.program prog_abb = self.program
self.name = prog_abb + "-"+ self.student_batch_name + "-" + self.academic_year self.name = prog_abb + "-"+ self.student_batch_name + "-" + self.academic_year
def validate(self): def validate(self):
validate_duplicate_student(self.students) validate_duplicate_student(self.students)
def validate_active_student_batch(student_batch):
if not frappe.db.get_value("Student Batch", student_batch, "active"):
frappe.throw(_("Student Batch is not Active."))

View File

@@ -8,6 +8,16 @@ frappe.ui.form.on('Student Batch Attendance Tool', {
hide_field('attendance'); hide_field('attendance');
}, },
onload: function(frm){
cur_frm.set_query("student_batch", function(){
return{
"filters": {
"active": 1
}
};
});
},
student_batch :function(frm) { student_batch :function(frm) {
if(frm.doc.student_batch && frm.doc.date) { if(frm.doc.student_batch && frm.doc.date) {
frappe.call({ frappe.call({

View File

@@ -1,33 +1,43 @@
cur_frm.add_fetch("student", "title", "student_name"); cur_frm.add_fetch("student", "title", "student_name");
frappe.ui.form.on("Student Group", "refresh", function(frm) { frappe.ui.form.on("Student Group", {
if(!frm.doc.__islocal) { refresh: function(frm) {
frm.add_custom_button(__("Course Schedule"), function() { if(!frm.doc.__islocal) {
frappe.route_options = { frm.add_custom_button(__("Course Schedule"), function() {
student_group: frm.doc.name frappe.route_options = {
} student_group: frm.doc.name
frappe.set_route("List", "Course Schedule"); }
frappe.set_route("List", "Course Schedule");
});
frm.add_custom_button(__("Assessment"), function() {
frappe.route_options = {
student_group: frm.doc.name
}
frappe.set_route("List", "Assessment");
});
}
},
onload: function(frm){
cur_frm.set_query("academic_term",function(){
return{
"filters":{
"academic_year": (frm.doc.academic_year)
}
};
}); });
frm.add_custom_button(__("Assessment"), function() { cur_frm.set_query("student_batch", function(){
frappe.route_options = { return{
student_group: frm.doc.name "filters": {
} "active": 1
frappe.set_route("List", "Assessment"); }
};
}); });
} }
}); });
frappe.ui.form.on("Student Group", "onload", function(frm){
cur_frm.set_query("academic_term",function(){
return{
"filters":{
"academic_year": (frm.doc.academic_year)
}
};
});
});
//If Student Batch is entered, deduce program, academic_year and academic term from it //If Student Batch is entered, deduce program, academic_year and academic term from it
cur_frm.add_fetch("student_batch", "program", "program"); cur_frm.add_fetch("student_batch", "program", "program");
cur_frm.add_fetch("student_batch", "academic_term", "academic_term"); cur_frm.add_fetch("student_batch", "academic_term", "academic_term");

View File

@@ -7,6 +7,7 @@ import frappe
from frappe.model.document import Document from frappe.model.document import Document
from frappe import _ from frappe import _
from erpnext.schools.utils import validate_duplicate_student from erpnext.schools.utils import validate_duplicate_student
from erpnext.schools.doctype.student_batch.student_batch import validate_active_student_batch
class StudentGroup(Document): class StudentGroup(Document):
def autoname(self): def autoname(self):
@@ -31,6 +32,9 @@ class StudentGroup(Document):
self.validate_student_name() self.validate_student_name()
validate_duplicate_student(self.students) validate_duplicate_student(self.students)
if self.student_batch:
validate_active_student_batch(self.student_batch)
def validate_strength(self): def validate_strength(self):
if self.max_strength and len(self.students) > self.max_strength: 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)) frappe.throw(_("""Cannot enroll more than {0} students for this student group.""").format(self.max_strength))