Sfoglia il codice sorgente

Added validation for App title

version-14
Valmik Jangla 9 anni fa
parent
commit
1798d1701b
1 ha cambiato i file con 5 aggiunte e 2 eliminazioni
  1. +5
    -2
      frappe/utils/boilerplate.py

+ 5
- 2
frappe/utils/boilerplate.py Vedi File

@@ -3,7 +3,7 @@


from __future__ import unicode_literals from __future__ import unicode_literals


import frappe, os
import frappe, os, re
from frappe.utils import touch_file, encode, cstr from frappe.utils import touch_file, encode, cstr


def make_boilerplate(dest, app_name): def make_boilerplate(dest, app_name):
@@ -17,7 +17,7 @@ def make_boilerplate(dest, app_name):
hooks = frappe._dict() hooks = frappe._dict()
hooks.app_name = app_name hooks.app_name = app_name
app_title = hooks.app_name.replace("_", " ").title() 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 Description", "App Publisher", "App Email",
"App Icon (default 'octicon octicon-file-directory')", "App Icon (default 'octicon octicon-file-directory')",
"App Color (default 'grey')", "App Color (default 'grey')",
@@ -28,6 +28,9 @@ def make_boilerplate(dest, app_name):
hook_val = cstr(raw_input(key + ": ")) hook_val = cstr(raw_input(key + ": "))
if hook_key=="app_name" and hook_val.lower().replace(" ", "_") != hook_val: if hook_key=="app_name" and hook_val.lower().replace(" ", "_") != hook_val:
print "App Name must be all lowercase and without spaces" 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 = "" hook_val = ""
elif not hook_val: elif not hook_val:
defaults = { defaults = {


Caricamento…
Annulla
Salva