Rename schools to Education (#11524)
* renaming for the docs, demo data and patch * changes in the doctypes and reports * rename the config file * Few name changes in messages and license * rename the school settings to education settings * changes in the documentation * added the setup file for the fixtures * corrected the ui tests file path * fix the codacy * add the patch for renaming few doctypes and fields * changes in the patch
This commit is contained in:
committed by
Nabin Hait
parent
acccdb3890
commit
966f141f62
53
erpnext/education/utils.py
Normal file
53
erpnext/education/utils.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2015, Frappe Technologies and contributors
|
||||
# For lice
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
class OverlapError(frappe.ValidationError): pass
|
||||
|
||||
def validate_overlap_for(doc, doctype, fieldname, value=None):
|
||||
"""Checks overlap for specified field.
|
||||
|
||||
:param fieldname: Checks Overlap for this field
|
||||
"""
|
||||
|
||||
existing = get_overlap_for(doc, doctype, fieldname, value)
|
||||
if existing:
|
||||
frappe.throw(_("This {0} conflicts with {1} for {2} {3}").format(doc.doctype, existing.name,
|
||||
doc.meta.get_label(fieldname) if not value else fieldname , value or doc.get(fieldname)), OverlapError)
|
||||
|
||||
def get_overlap_for(doc, doctype, fieldname, value=None):
|
||||
"""Returns overlaping document for specified field.
|
||||
|
||||
:param fieldname: Checks Overlap for this field
|
||||
"""
|
||||
|
||||
existing = frappe.db.sql("""select name, from_time, to_time from `tab{0}`
|
||||
where `{1}`=%(val)s and schedule_date = %(schedule_date)s and
|
||||
(
|
||||
(from_time > %(from_time)s and from_time < %(to_time)s) or
|
||||
(to_time > %(from_time)s and to_time < %(to_time)s) or
|
||||
(%(from_time)s > from_time and %(from_time)s < to_time) or
|
||||
(%(from_time)s = from_time and %(to_time)s = to_time))
|
||||
and name!=%(name)s""".format(doctype, fieldname),
|
||||
{
|
||||
"schedule_date": doc.schedule_date,
|
||||
"val": value or doc.get(fieldname),
|
||||
"from_time": doc.from_time,
|
||||
"to_time": doc.to_time,
|
||||
"name": doc.name or "No Name"
|
||||
}, 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)
|
||||
Reference in New Issue
Block a user