Added urlfield field and little fix in silly bug

This commit is contained in:
Antonio de la Rosa 2016-04-07 03:39:17 +02:00
parent 509a14b165
commit 46a58d0bc9
2 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,25 @@
from paramecio.cromosoma.corefields import CharField
import re
check_url = re.compile(
r'^(?:http|ftp)s?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain...
r'localhost|' #localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip
r'(?::\d+)?' # optional port
r'(?:/?|[/?]\S+)$', re.IGNORECASE)
class UrlField(CharField):
def check(self, value):
self.error=False
self.txt_error=''
if not check_url.match(value):
self.error=True
value=""
self.txt_error='No valid URL format'
return value

View file

@ -30,7 +30,7 @@ if config.yes_static==True:
path=workdir+'/themes/'+config.theme+'/media/'+module
file_path=path+filename
file_path=path+'/'+filename
if os.path.isfile(file_path):
mimetype=guess_type(path+'/'+filename)