Marek Baczynski 6 years ago
commit 839942e9d7

@ -80,10 +80,7 @@ def getUpcomingMeals():
meals = [] meals = []
for row in r: for row in r:
meals.append(dict(row)) 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() 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: if seconds_to_deadline < 0:
meals[-1]['selection_deadline'] = 'Deadline passed' meals[-1]['selection_deadline'] = 'Deadline passed'
elif seconds_to_deadline > 3600: elif seconds_to_deadline > 3600:
@ -93,6 +90,8 @@ def getUpcomingMeals():
meals[-1]['selection_deadline'] = str(days_td) + ' days ' + str(hours_td) + ' hours' meals[-1]['selection_deadline'] = str(days_td) + ' days ' + str(hours_td) + ' hours'
else: else:
meals[-1]['selection_deadline'] = str(round(seconds_to_deadline / 60)) + ' minutes' 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() r.close()
return meals return meals

@ -92,7 +92,7 @@ h2 {
.flex-card p { .flex-card p {
font-size: 14px; font-size: 14px;
text-align: center; text-align: center;
line-height: 200%; line-height: 280%;
} }
.rect-button span { .rect-button span {

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

@ -34,7 +34,7 @@ pawel['score'] = 10
leaderboard.append(pawel) leaderboard.append(pawel)
mark = {} mark = {}
mark['name'] = 'Mark' mark['name'] = 'Marek'
mark['score'] = 1 mark['score'] = 1
leaderboard.append(mark) leaderboard.append(mark)
@ -50,9 +50,9 @@ leaderboard.append(wille)
c_davide = {} c_davide = {}
c_davide['name'] = 'Davide' c_davide['name'] = 'Davide'
c_davide['confirmed'] = 'yes' c_davide['confirmed'] = 'no'
cook = c_davide cook = c_davide
eaters = ["Pawel", "Mark", "Sven"] eaters = ["Wille", "Marek", "Sven"]
# flask-login # flask-login
login_manager = LoginManager() login_manager = LoginManager()
@ -62,7 +62,12 @@ login_manager.login_view = "login"
@app.route("/") @app.route("/")
@login_required @login_required
def index(): 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 # somewhere to login
@app.route("/login", methods=["GET", "POST"]) @app.route("/login", methods=["GET", "POST"])

Loading…
Cancel
Save