Fixed date format. Added time. Corrected template

master
Davide Bongiovanni 6 years ago
parent a24d793287
commit 2cefc5e5fd

@ -49,10 +49,7 @@ def getUpcomingMeals():
meals = []
for row in r:
meals.append(dict(row))
print (meals)
print ('deadline ' + str(meals[-1]['selection_deadline'] ))
seconds_to_deadline = (meals[-1]['selection_deadline'] - datetime.datetime.now()).total_seconds()
print(str(seconds_to_deadline) + ' s to dead')
if seconds_to_deadline < 0:
meals[-1]['selection_deadline'] = 'Deadline passed'
elif seconds_to_deadline > 3600:
@ -62,6 +59,8 @@ def getUpcomingMeals():
meals[-1]['selection_deadline'] = str(days_td) + ' days ' + str(hours_td) + ' hours'
else:
meals[-1]['selection_deadline'] = str(round(seconds_to_deadline / 60)) + ' minutes'
meals[-1]['meal_time'] = meals[-1]['meal_date'].strftime('%H:%M')
meals[-1]['meal_date'] = meals[-1]['meal_date'].strftime('%A %d %B')
r.close()
return meals

@ -33,13 +33,17 @@
</div>
<div class="right-pane">
<div class="meal-list">
<h2>{{meals[0].date}}</h2>
<h2>{{meals[0].meal_date}}</h2>
{% for meal in meals %}
{% if loop.index != 1 and (meal.date != meals[loop.index - 2].date) %}
<h2>{{meal.date}}</h2>
{% if loop.index != 1 and (meal.meal_date != meals[loop.index - 2].meal_date) %}
<h2>{{meal.meal_date}}</h2>
{% endif %}
<div class="meal">
<h5>{{meal.date}}</h5>
<div class="flex-card" onclick="location.href='/meal/{{meal.id}}';" style="cursor: pointer; width: 60%;">
<div class="people">
<p style="text-align: left;"><b>Cook</b> &nbsp;&nbsp; <img class="flex-small-thumb" src="{{url_for('static', filename=meal.kuk + '.png')}}" title="{{meal.kuk}}" align="middle" style="margin: " /></p>
<p style="text-align: left;"><b>Eaters</b> &nbsp;&nbsp; {% for e in meal.eaters %}<img class="flex-small-thumb" src="{{url_for('static', filename=e + '.png')}}" title="{{e}}" align="middle"/> {% endfor %}</p>
</div>
<span>Confirmed in {{meal.selection_deadline}}</span>
</div>
{% endfor%}
</div>

Loading…
Cancel
Save