seitime-frappe/frappe/desk/utils.py
Gavin D'souza 3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30

23 lines
No EOL
673 B
Python

# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# License: MIT. See LICENSE
import frappe
def validate_route_conflict(doctype, name):
'''
Raises exception if name clashes with routes from other documents for /app routing
'''
all_names = []
for _doctype in ['Page', 'Workspace', 'DocType']:
try:
all_names.extend([slug(d) for d in frappe.get_all(_doctype, pluck='name') if (doctype != _doctype and d != name)])
except frappe.db.TableMissingError:
pass
if slug(name) in all_names:
frappe.msgprint(frappe._('Name already taken, please set a new name'))
raise frappe.NameError
def slug(name):
return name.lower().replace(' ', '-')