|
|
@ -93,12 +93,23 @@ class model(dict):
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def link(self):
|
|
|
|
def link(self):
|
|
|
|
url = self.get('url', '')
|
|
|
|
url = self.get('url', '')
|
|
|
|
|
|
|
|
ready_url = ''
|
|
|
|
if '{%' in url or '{{' in url:
|
|
|
|
if '{%' in url or '{{' in url:
|
|
|
|
from jinja2 import Environment
|
|
|
|
from jinja2 import Environment
|
|
|
|
# Jinja2 available in URLs along with https://pypi.org/project/jinja2-time/
|
|
|
|
# Jinja2 available in URLs along with https://pypi.org/project/jinja2-time/
|
|
|
|
jinja2_env = Environment(extensions=['jinja2_time.TimeExtension'])
|
|
|
|
jinja2_env = Environment(extensions=['jinja2_time.TimeExtension'])
|
|
|
|
return str(jinja2_env.from_string(url).render())
|
|
|
|
try:
|
|
|
|
return url
|
|
|
|
ready_url = str(jinja2_env.from_string(url).render())
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
|
|
from flask import (
|
|
|
|
|
|
|
|
flash, Markup, url_for
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
message = Markup('<a href="{}#general">The URL {} is invalid and cannot be used, click to edit</a>'.format(
|
|
|
|
|
|
|
|
url_for('edit_page', uuid=self.get('uuid')), self.get('url', '')))
|
|
|
|
|
|
|
|
flash(message, 'error')
|
|
|
|
|
|
|
|
return ''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ready_url
|
|
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
@property
|
|
|
|
def label(self):
|
|
|
|
def label(self):
|
|
|
|