instructor-naming (#10550)
This commit is contained in:
parent
579c8e68f9
commit
7dc113e977
@ -17,7 +17,7 @@ class TestCourseSchedule(unittest.TestCase):
|
||||
cs1 = make_course_schedule_test_record(simulate= True)
|
||||
|
||||
cs2 = make_course_schedule_test_record(schedule_date=cs1.schedule_date, from_time= cs1.from_time,
|
||||
to_time= cs1.to_time, instructor="_T-Instructor-00002", room="RM0002", do_not_save= 1)
|
||||
to_time= cs1.to_time, instructor="_Test Instructor 2", room="RM0002", do_not_save= 1)
|
||||
self.assertRaises(OverlapError, cs2.save)
|
||||
|
||||
def test_instructor_conflict(self):
|
||||
@ -31,14 +31,14 @@ class TestCourseSchedule(unittest.TestCase):
|
||||
cs1 = make_course_schedule_test_record(simulate= True)
|
||||
|
||||
cs2 = make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
|
||||
student_group="Course-TC101-2014-2015 (_Test Academic Term)", instructor="_T-Instructor-00002", do_not_save= 1)
|
||||
student_group="Course-TC101-2014-2015 (_Test Academic Term)", instructor="_Test Instructor 2", do_not_save= 1)
|
||||
self.assertRaises(OverlapError, cs2.save)
|
||||
|
||||
def test_no_conflict(self):
|
||||
cs1 = make_course_schedule_test_record(simulate= True)
|
||||
|
||||
make_course_schedule_test_record(from_time= cs1.from_time, to_time= cs1.to_time,
|
||||
student_group="Course-TC102-2014-2015 (_Test Academic Term)", instructor="_T-Instructor-00002", room="RM0002")
|
||||
student_group="Course-TC102-2014-2015 (_Test Academic Term)", instructor="_Test Instructor 2", room="RM0002")
|
||||
|
||||
def make_course_schedule_test_record(**args):
|
||||
args = frappe._dict(args)
|
||||
@ -46,7 +46,7 @@ def make_course_schedule_test_record(**args):
|
||||
course_schedule = frappe.new_doc("Course Schedule")
|
||||
course_schedule.student_group = args.student_group or "Course-TC101-2014-2015 (_Test Academic Term)"
|
||||
course_schedule.course = args.course or "TC101"
|
||||
course_schedule.instructor = args.instructor or "_T-Instructor-00001"
|
||||
course_schedule.instructor = args.instructor or "_Test Instructor"
|
||||
course_schedule.room = args.room or "RM0001"
|
||||
|
||||
course_schedule.schedule_date = args.schedule_date or today()
|
||||
|
@ -208,7 +208,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"menu_index": 0,
|
||||
"modified": "2017-06-30 08:21:49.055531",
|
||||
"modified": "2017-08-25 01:03:14.602994",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Schools",
|
||||
"name": "Instructor",
|
||||
|
@ -4,7 +4,21 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.model.naming import make_autoname
|
||||
|
||||
class Instructor(Document):
|
||||
pass
|
||||
def autoname(self):
|
||||
naming_method = frappe.db.get_value("School Settings", None, "instructor_created_by")
|
||||
if not naming_method:
|
||||
frappe.throw(_("Please setup Instructor Naming System in School > School Settings"))
|
||||
else:
|
||||
if naming_method == 'Naming Series':
|
||||
self.name = make_autoname(self.naming_series + '.####')
|
||||
elif naming_method == 'Employee Number':
|
||||
if not self.employee:
|
||||
frappe.throw("Please select Employee")
|
||||
self.name = self.employee
|
||||
elif naming_method == 'Full Name':
|
||||
self.name = self.instructor_name
|
||||
|
@ -194,6 +194,67 @@
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section 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": "Full Name",
|
||||
"fieldname": "instructor_created_by",
|
||||
"fieldtype": "Select",
|
||||
"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": "Instructor Records to be created by",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Full Name\nNaming Series\nEmployee Number",
|
||||
"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,
|
||||
@ -206,7 +267,7 @@
|
||||
"issingle": 1,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-06-30 08:21:50.339169",
|
||||
"modified": "2017-08-25 02:36:48.744456",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Schools",
|
||||
"name": "School Settings",
|
||||
|
@ -26,3 +26,10 @@ class SchoolSettings(Document):
|
||||
|
||||
def get_defaults(self):
|
||||
return frappe.defaults.get_defaults()
|
||||
|
||||
def validate(self):
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
if self.get('instructor_created_by')=='Naming Series':
|
||||
make_property_setter('Instructor', "naming_series", "hidden", 0, "Check")
|
||||
else:
|
||||
make_property_setter('Instructor', "naming_series", "hidden", 1, "Check")
|
||||
|
Loading…
x
Reference in New Issue
Block a user