Re #1052 - Watch 'open' link should use any dynamic/template info (#1063)

This commit is contained in:
dgtlmoon
2022-10-27 13:29:24 +02:00
committed by GitHub
parent 9874f0cbc7
commit 7f6a13ea6c
4 changed files with 13 additions and 7 deletions

View File

@@ -88,6 +88,16 @@ class model(dict):
print ("> Creating data dir {}".format(self.watch_data_dir))
os.mkdir(self.watch_data_dir)
@property
def link(self):
url = self.get('url', '')
if '{%' in url or '{{' in url:
from jinja2 import Environment
# Jinja2 available in URLs along with https://pypi.org/project/jinja2-time/
jinja2_env = Environment(extensions=['jinja2_time.TimeExtension'])
return str(jinja2_env.from_string(url).render())
return url
@property
def label(self):
# Used for sorting