Added new field type called urlfield

This commit is contained in:
Antonio de la Rosa 2016-08-24 05:48:47 +02:00
parent dfe0ee6550
commit b5c05057e6
2 changed files with 19 additions and 2 deletions

View file

@ -73,7 +73,7 @@ def check_login():
return False
def base_admin(func_view, env, title):
def base_admin(func_view, env, title, **args):
env.directories.insert(1, config.paramecio_root+'/modules/admin/templates')
@ -94,7 +94,7 @@ def base_admin(func_view, env, title):
lang_selected=get_language(s)
content_index=func_view(connection, t, s)
content_index=func_view(connection, t, s, **args)
return t.load_template('admin/content.html', title=title, content_index=content_index, menu=menu, lang_selected=lang_selected, arr_i18n=I18n.dict_i18n)

View file

@ -23,3 +23,20 @@ class UrlField(CharField):
self.txt_error='No valid URL format'
return value
check_domain=re.compile('^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\.[a-zA-Z]{2,3})$')
class DomainField(CharField):
def check(self, value):
self.error=False
self.txt_error=''
if not check_domain.match(value):
self.error=True
value=""
self.txt_error='No valid domain format'
return value