From 2cefc5e5fd1f98324c10aec4788ecea32d4477f4 Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Fri, 30 Nov 2018 22:11:00 +0100 Subject: [PATCH 1/2] 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%}
From 049b0e66ba1f89e882c1a4f25593164375e0cb4a Mon Sep 17 00:00:00 2001 From: Davide Bongiovanni Date: Fri, 30 Nov 2018 22:37:04 +0100 Subject: [PATCH 2/2] Correctly displaying stuff --- static/style.css | 2 +- templates/meal_list.html | 3 +-- test.py | 13 +++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/static/style.css b/static/style.css index 5cc3a66..bf87d02 100644 --- a/static/style.css +++ b/static/style.css @@ -92,7 +92,7 @@ h2 { .flex-card p { font-size: 14px; text-align: center; - line-height: 200%; + line-height: 280%; } .rect-button span { diff --git a/templates/meal_list.html b/templates/meal_list.html index 3b4126c..7f64720 100644 --- a/templates/meal_list.html +++ b/templates/meal_list.html @@ -40,8 +40,7 @@ {% endif %}
-

Cook   

-

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

+

{% if meal.kuk != "" %}    WILL cook for
{% for e in meal.eaters %}  {% endfor %}{% else %}    SHOULD cook for
{% for e in meal.eaters %}  {% endfor %}{% endif %}

Confirmed in {{meal.selection_deadline}}
diff --git a/test.py b/test.py index 0afdca9..2356fcf 100644 --- a/test.py +++ b/test.py @@ -34,7 +34,7 @@ pawel['score'] = 10 leaderboard.append(pawel) mark = {} -mark['name'] = 'Mark' +mark['name'] = 'Marek' mark['score'] = 1 leaderboard.append(mark) @@ -50,9 +50,9 @@ leaderboard.append(wille) c_davide = {} c_davide['name'] = 'Davide' -c_davide['confirmed'] = 'yes' +c_davide['confirmed'] = 'no' cook = c_davide -eaters = ["Pawel", "Mark", "Sven"] +eaters = ["Wille", "Marek", "Sven"] # flask-login login_manager = LoginManager() @@ -62,7 +62,12 @@ login_manager.login_view = "login" @app.route("/") @login_required def index(): - return render_template('index.html', leaderboard=leaderboard, cook=cook, eaters=eaters) + date = 'Friday 23rd of November' + meals = [] + meals.append({'id':1, 'kuk':'davide', 'eaters':['marek','sven','wille'], 'flavor_text':'Pizza', 'date':'Tuesday 21st of November', 'selection_deadline':'23 hours 14 minutes', 'status':0}) + meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Friday 23rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0}) + return render_template('index.html', leaderboard=leaderboard, cook=cook, eaters=eaters, date=date) + # return render_template('meal_list.html', leaderboard=leaderboard, cook=cook, eaters=eaters, meals=meals) # somewhere to login @app.route("/login", methods=["GET", "POST"])