|
@@ -11,7 +11,7 @@ from flask import render_template, request
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
gancio_instance = 'balotta.org'
|
|
|
-templates = [x.stem for x in pathlib.Path('./templates/flyers/').glob("*.html")]
|
|
|
+templates = json.load(open('./templates.json'))
|
|
|
default_template = 'simple'
|
|
|
events_ep = f'https://{gancio_instance}/api/events'
|
|
|
|
|
@@ -60,10 +60,14 @@ def main():
|
|
|
def flyer():
|
|
|
relevant_events = request.args.getlist('events', type=int)
|
|
|
template = request.args.get("template", default=default_template, type=str)
|
|
|
- if template not in templates:
|
|
|
+ if template not in [ t['name'] for t in templates ]:
|
|
|
return "template not found", 404
|
|
|
+ template = [t for t in templates if t['name'] == template][0]
|
|
|
events = fetch_events(events_ep)
|
|
|
- events = [ e for e in events if e['id'] in relevant_events ]
|
|
|
- return render_template(f'flyers/{template}.html', events=events)
|
|
|
+ events = [ e for e in events if e['id'] in relevant_events ]
|
|
|
+ params = {}
|
|
|
+ if 'params' in template:
|
|
|
+ params = template['params']
|
|
|
+ return render_template(f'flyers/{template["baseTemplate"]}.html', events=events, params=params)
|
|
|
|
|
|
|