More sophisticated handling of event attending meta data.

pull/42/head
Markus Steinlein 4 years ago
parent 6a1ee41cee
commit ac7b6a4c75

@ -28,7 +28,7 @@ def format_date_string(date_string):
def sort_date_from_string(date_string): def sort_date_from_string(date_string):
try: try:
return datetime.strptime(date_string.split('-')[0].strip(), "%d.%m.%Y") return datetime.strptime(date_string.split('-')[0].strip(), "%d.%m.%Y")
except: except Exception:
return datetime.now() return datetime.now()
@ -66,7 +66,8 @@ def verein():
@app.route('/events.html') @app.route('/events.html')
def view_events(): def view_events():
posts = [p for p in events if "date" in p.meta] posts = [p for p in events if "date" in p.meta]
sorted_events = sorted(posts, reverse=False, key=lambda event: sort_date_from_string(event.meta["date"])) sorted_events = sorted(posts, reverse=False, key=lambda event:
sort_date_from_string(event.meta["date"]))
return render_template('events.html', events=sorted_events) return render_template('events.html', events=sorted_events)

@ -6,12 +6,13 @@
} }
{% endblock additional_style %} {% endblock additional_style %}
{% block title %} {% block title %}
Was liegt an? Events
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<p> <h3>Was liegt an?</h3>
Neben unseren eigenen Veranstaltungen trefft ihr uns auch auf Konzerten und <p>Neben unseren eigenen Veranstaltungen trefft ihr FdgLer:innen auch auf
Festivals an. Haltet nach unserem Patch Ausschau und sprecht uns an! Konzerten und Festivals an. Haltet nach unserem Patch Ausschau und sprecht
uns an!
</p> </p>
<div class="event-container"> <div class="event-container">
@ -33,10 +34,13 @@
<p> {{ event.html|safe }} </p> <p> {{ event.html|safe }} </p>
<p class="attending">vor Ort: <p class="attending">
{% for a in event.attending.split(',') %} {% if event.attending != None %}
<span class="attendee">{{ a }}{% if a != event.attending.split(',')[-1] %},{% endif %}</span> vor Ort:
{% endfor %} {% for a in event.attending.split(',') %}
<span class="attendee">{{ a }}{% if a != event.attending.split(',')[-1] %},{% endif %}</span>
{% endfor %}
{% endif %}
</p> </p>
</div> </div>
{% endfor %} {% endfor %}

Loading…
Cancel
Save