Merge pull request #1739 from vjFaLk/new-app-fix
Added validation for App Title
This commit is contained in:
commit
8ade543458
1 changed files with 5 additions and 2 deletions
7
frappe/utils/boilerplate.py
Normal file → Executable file
7
frappe/utils/boilerplate.py
Normal file → Executable file
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe, os
|
||||
import frappe, os, re
|
||||
from frappe.utils import touch_file, encode, cstr
|
||||
|
||||
def make_boilerplate(dest, app_name):
|
||||
|
|
@ -17,7 +17,7 @@ def make_boilerplate(dest, app_name):
|
|||
hooks = frappe._dict()
|
||||
hooks.app_name = app_name
|
||||
app_title = hooks.app_name.replace("_", " ").title()
|
||||
for key in ("App Title (defaut: {0})".format(app_title),
|
||||
for key in ("App Title (default: {0})".format(app_title),
|
||||
"App Description", "App Publisher", "App Email",
|
||||
"App Icon (default 'octicon octicon-file-directory')",
|
||||
"App Color (default 'grey')",
|
||||
|
|
@ -28,6 +28,9 @@ def make_boilerplate(dest, app_name):
|
|||
hook_val = cstr(raw_input(key + ": "))
|
||||
if hook_key=="app_name" and hook_val.lower().replace(" ", "_") != hook_val:
|
||||
print "App Name must be all lowercase and without spaces"
|
||||
hook_val = ""
|
||||
elif hook_key=="app_title" and not re.match("^(?![\W])[^\d_\s][\w -]+$", hook_val, re.UNICODE):
|
||||
print "App Title should start with a letter and it can only consist of letters, numbers, spaces and underscores"
|
||||
hook_val = ""
|
||||
elif not hook_val:
|
||||
defaults = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue