Added urlfield field and little fix in silly bug
This commit is contained in:
parent
509a14b165
commit
46a58d0bc9
2 changed files with 26 additions and 1 deletions
25
paramecio/cromosoma/extrafields/urlfield.py
Normal file
25
paramecio/cromosoma/extrafields/urlfield.py
Normal 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
|
||||||
|
|
@ -30,7 +30,7 @@ if config.yes_static==True:
|
||||||
|
|
||||||
path=workdir+'/themes/'+config.theme+'/media/'+module
|
path=workdir+'/themes/'+config.theme+'/media/'+module
|
||||||
|
|
||||||
file_path=path+filename
|
file_path=path+'/'+filename
|
||||||
|
|
||||||
if os.path.isfile(file_path):
|
if os.path.isfile(file_path):
|
||||||
mimetype=guess_type(path+'/'+filename)
|
mimetype=guess_type(path+'/'+filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue