From 2cefc5e5fd1f98324c10aec4788ecea32d4477f4 Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Fri, 30 Nov 2018 22:11:00 +0100 Subject: [PATCH] Fixed date format. Added time. Corrected template --- kukv1.py | 5 ++--- templates/meal_list.html | 14 +++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/kukv1.py b/kukv1.py index f509346..bb63f38 100644 --- a/kukv1.py +++ b/kukv1.py @@ -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 diff --git a/templates/meal_list.html b/templates/meal_list.html index 2cfeb86..3b4126c 100644 --- a/templates/meal_list.html +++ b/templates/meal_list.html @@ -33,13 +33,17 @@
-

{{meals[0].date}}

+

{{meals[0].meal_date}}

{% for meal in meals %} - {% if loop.index != 1 and (meal.date != meals[loop.index - 2].date) %} -

{{meal.date}}

+ {% if loop.index != 1 and (meal.meal_date != meals[loop.index - 2].meal_date) %} +

{{meal.meal_date}}

{% endif %} -
-
{{meal.date}}
+
+
+

Cook   

+

Eaters    {% for e in meal.eaters %} {% endfor %}

+
+ Confirmed in {{meal.selection_deadline}}
{% endfor%}