Compare commits

...
36 Commits
Author SHA1 Message Date
davide 972461dab4 Merge branch 'master' of git.elab.kth.se:davide/KUKapp 2019-01-26 17:10:58 +01:00
davide 680be19b07 Started plan_meal function 2019-01-23 08:38:08 +01:00
davide f20243b247 Added pattern checking for deadline 2019-01-23 08:37:38 +01:00
marek 574e3114fa backendpoint for planing a new meal. Not particularily tested with a proper POST form though so use with care. 2018-12-15 19:44:15 +01:00
marek 18d8d2ede9 Merge branch 'master' of https://git.elab.kth.se/davide/KUKapp 2018-12-15 19:18:21 +01:00
marek 259961da6e adding me to meals 2018-12-15 19:18:09 +01:00
davide baeed56490 Merge branch 'master' of git.elab.kth.se:davide/KUKapp 2018-12-15 19:13:54 +01:00
davide b1d8323c30 IMPORTANT REFACTOR 2018-12-15 19:13:40 +01:00
marek 1061b7c08e Merge branch 'master' of https://git.elab.kth.se/davide/KUKapp 2018-12-15 19:04:31 +01:00
marek 77ecebc9c7 fixed "add me" on meal view page 2018-12-15 19:04:19 +01:00
davide d0ff0ceb46 I just fixed it 2018-12-15 19:03:07 +01:00
davide 37ee3a1611 Fixed confirmed cook size 2018-12-15 18:56:08 +01:00
davide 616840676f Merge branch 'master' of git.elab.kth.se:davide/KUKapp 2018-12-15 18:51:19 +01:00
davide fcbc47b3ae Fixed get estimated kuk 2018-12-15 18:50:56 +01:00
davide b535de925c Fixed ginormous user thumbnail 2018-12-15 18:50:11 +01:00
marek 0829704105 Merge branch 'master' of https://git.elab.kth.se/davide/KUKapp 2018-12-15 18:36:52 +01:00
marek 25024433a4 endpoint for removing me from meal 2018-12-15 18:36:22 +01:00
davide fd94641203 Added 'can join until' 2018-12-15 18:25:11 +01:00
davide fa7fcbb337 Merge branch 'master' of git.elab.kth.se:davide/KUKapp 2018-12-15 18:24:38 +01:00
davide ba5e35993d Implemented get kuk candidate 2018-12-15 18:24:26 +01:00
davide 64396c29d8 Implemented apply temp meal 2018-12-15 18:16:36 +01:00
davide 7cf3580844 Two different user search mode 2018-12-15 18:15:57 +01:00
davide e3bfe39695 Fetching is_lazy 2018-12-15 18:13:36 +01:00
davide 1e6137370e Differentiating between user search modes. Small fixes. 2018-12-15 18:12:49 +01:00
davide 1f5b4cedfd Fixed some styling 2018-12-15 18:11:42 +01:00
marek ce75733204 made app not crash when trying to plan a meal without being logged in 2018-12-15 17:43:46 +01:00
davide 68ef11a2b0 Updated point array 2018-12-15 17:32:58 +01:00
davide 423c8f227f Removed extra ahmed 2018-12-05 12:37:49 +01:00
davide d174707e21 Meal planner template 2018-12-05 12:25:53 +01:00
davide 36e16c511b Javascript for the meal planner page 2018-12-05 12:25:28 +01:00
davide 95dc07d1e7 Added get kuk candidate endpoint. Behaviour still to implement 2018-12-05 12:25:14 +01:00
davide 78a62e20b9 Some styling for meal plannes 2018-12-04 17:37:33 +01:00
davide 181214c5c6 Added mealplanner and searchuser endpoint 2018-12-04 17:36:58 +01:00
davide 5f7b38b839 Changed endpoint name 2018-12-04 17:36:21 +01:00
davide 7441ee742b Removed unnecessary file 2018-12-02 15:10:03 +01:00
davide 8d596a55ab Added view meal history button 2018-12-02 15:09:52 +01:00
7 changed files with 423 additions and 72 deletions
+90 -9
View File
@@ -21,6 +21,9 @@ db_metadata = {}
meals = {} meals = {}
users = {} users = {}
KUK_POINTS = [0, 0, 52, 69, 80, 90, 102, 112, 120, 126]
LAZY_KUK_POINTS = [0, 0, 38, 48, 56, 65, 72, 77, 80, 81]
class User(UserMixin): class User(UserMixin):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
@@ -57,9 +60,10 @@ def getUpcomingMeals():
# meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0}) # meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
# meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0}) # meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Sunday 25rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
# meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Monday 26rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0}) # meals.append({'id':2, 'kuk':'marek', 'eaters':['davide','sven','david', 'wille'], 'flavor_text':'Grzybowa', 'date':'Monday 26rd of November', 'selection_deadline':'3 Days 23 hours', 'status':0})
query = 'select foo.id, username as kuk, meal_date, array_agg as eaters, selection_deadline from (select meals.id, kuk, meal_date, selection_deadline, array_agg(username) from meals join users on users.id = any(meals.eaters) where meals.status=0 group by meals.id order by meal_date) as foo join users on kuk=users.id;' query = 'SELECT foo.id, username AS kuk, meal_date, array_agg AS eaters, selection_deadline, is_lazy FROM (SELECT is_lazy, meals.id, kuk, meal_date, selection_deadline, array_agg(username) FROM meals JOIN users ON users.id = any(meals.eaters) WHERE meals.status=0 GROUP BY meals.id ORDER BY meal_date) AS foo JOIN users ON kuk=users.id;'
r = db_engine.execute(text(query)) r = db_engine.execute(text(query))
meals = [] meals = []
leaderboard = getLeaderboard()
for row in r: for row in r:
meals.append(dict(row)) meals.append(dict(row))
seconds_to_deadline = (meals[-1]['selection_deadline'] - datetime.datetime.now()).total_seconds() seconds_to_deadline = (meals[-1]['selection_deadline'] - datetime.datetime.now()).total_seconds()
@@ -74,16 +78,38 @@ def getUpcomingMeals():
meals[-1]['friendly_selection_deadline'] = str(round(seconds_to_deadline / 60)) + ' minutes' meals[-1]['friendly_selection_deadline'] = str(round(seconds_to_deadline / 60)) + ' minutes'
meals[-1]['meal_time'] = meals[-1]['meal_date'].strftime('%H:%M') meals[-1]['meal_time'] = meals[-1]['meal_date'].strftime('%H:%M')
meals[-1]['meal_friendly_date'] = meals[-1]['meal_date'].strftime('%A %d %B') meals[-1]['meal_friendly_date'] = meals[-1]['meal_date'].strftime('%A %d %B')
meals[-1]['candidate'] = 'davide' meals[-1]['candidate'] = [l['name'] for l in leaderboard if l['name'] in meals[-1]['eaters']][0]
if (meals[-1]['meal_date'] - datetime.datetime.now()).total_seconds() < 0: if (meals[-1]['meal_date'] - datetime.datetime.now()).total_seconds() < 0:
meals[-1]['needs_confirmation'] = True meals[-1]['needs_confirmation'] = True
else: else:
meals[-1]['needs_confirmation'] = False meals[-1]['needs_confirmation'] = False
leaderboard = applyTempMeal(leaderboard, meals[-1])
r.close() r.close()
return meals return meals, leaderboard
def applyTempMeal(leaderboard, meal):
ld = leaderboard[:]
m = meal.copy()
if m['kuk'] == '':
m['kuk'] = m['candidate']
m['eaters'].remove(m['candidate'])
for i in range(len(ld)):
if ld[i]['name'] == m['kuk']:
if m['is_lazy']:
ld[i]['score'] += LAZY_KUK_POINTS[len(m['eaters'])]
else:
ld[i]['score'] += KUK_POINTS[len(m['eaters'])]
ld[i]['last_meal'] = m['meal_date']
elif ld[i]['name'] in m['eaters']:
if m['is_lazy']:
ld[i]['score'] -= LAZY_KUK_POINTS[len(m['eaters'])] / len(m['eaters'])
else:
ld[i]['score'] -= KUK_POINTS[len(m['eaters'])] / len(m['eaters'])
return sorted(ld, key=lambda i:(i['score'], i['last_meal'] or datetime.datetime(1970, 1, 1, 0, 0)))
def getMeal(meal_id): def getMeal(meal_id):
query = 'select foo.id, username as kuk, meal_date, array_agg as eaters, selection_deadline from (select meals.id, kuk, meal_date, selection_deadline, array_agg(username) from meals join users on users.id = any(meals.eaters) where meals.id=:meal_id group by meals.id order by meal_date) as foo join users on kuk=users.id;' query = 'SELECT foo.id, username AS kuk, meal_date, array_agg AS eaters, selection_deadline FROM (SELECT meals.id, kuk, meal_date, selection_deadline, array_agg(username) FROM meals JOIN users ON users.id = any(meals.eaters) WHERE meals.id=:meal_id GROUP BY meals.id ORDER BY meal_date) AS foo JOIN users ON kuk=users.id;'
r = db_engine.execute(text(query), meal_id=meal_id) r = db_engine.execute(text(query), meal_id=meal_id)
meals = [] meals = []
for row in r: for row in r:
@@ -117,22 +143,49 @@ def getMeal(meal_id):
@login_required @login_required
def addme(): def addme():
meal_id = request.args.get('meal') meal_id = request.args.get('meal')
query = 'select :user_id = any (eaters) as is_eater from meals where id =:meal_id;' query = 'SELECT :user_id = any (eaters) AS is_eater FROM meals WHERE id =:meal_id;'
r = db_engine.execute(text(query), user_id=current_user.user_id, meal_id = meal_id) r = db_engine.execute(text(query), user_id=current_user.user_id, meal_id = meal_id)
results = [] results = []
for row in r: for row in r:
results.append(dict(row)) results.append(dict(row))
if not results[0]['is_eater'] == 'True':
if not results['is_eater']: query = "UPDATE meals SET eaters = array_cat(eaters, '{:user_id}') where id=:meal_id;"
r = db_engine.execute(text(query), user_id=current_user.user_id, meal_id = meal_id)
return render_template('appresponse.html', message='Have a nice meal ' + meal_id + " mister " + str(current_user.name) ) return render_template('appresponse.html', message='Have a nice meal ' + meal_id + " mister " + str(current_user.name) )
else: else:
return render_template('appresponse.html', message='You are already a registered eater') return render_template('appresponse.html', message='You are already a registered eater')
@app.route("/removeme")
@login_required
def removeme():
meal_id = request.args.get('meal')
query = 'UPDATE meals SET eaters = array_remove(eaters, :user_id) WHERE id = :meal_id;'
r = db_engine.execute(text(query), user_id=current_user.user_id, meal_id = meal_id)
return render_template('appresponse.html', message='You were removed from that meal')
@app.route("/planmeal", methods=['POST'])
@login_required
def plan_meal():
if request.form['kuk'] == None:
return render_template('appresponse.html', message='Invalid request. Nothing to do here')
query = "insert into meals(kuk, eaters, flavor_text, meal_date, selection_deadline, status) values(:kuk, ':eaters', ':flavour_text', ':meal_date', ':selection_deadline', 0);"
# correct formating example:
# insert into meals(kuk, eaters, flavor_text, meal_date, selection_deadline, status) values(2, '{1,3,4}', 'yum', '2018-12-25 18:22:12', '2018-12-25 10:22:12', 0);
r = db_engine.execute(text(query),
kuk=request.form['kuk'],
eaters=request.form['eaters'],
flavour_text=request.form['flavour_text'],
meal_date=request.form['meal_date'],
selection_deadline=request.form['selection_deadline']
)
return render_template('appresponse.html', message='The meal is planned')
@app.route('/') @app.route('/')
def index(): def index():
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=getUpcomingMeals(), now=datetime.datetime.now()) meals, _ = getUpcomingMeals()
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=meals)
@app.route('/view_meal') @app.route('/viewmeal')
def view_meal(): def view_meal():
meal_id = request.args.get('meal') meal_id = request.args.get('meal')
meal = getMeal(meal_id) meal = getMeal(meal_id)
@@ -141,6 +194,34 @@ def view_meal():
print(meal) print(meal)
return render_template('view_meal.html', leaderboard=getLeaderboard(), meal=meal) return render_template('view_meal.html', leaderboard=getLeaderboard(), meal=meal)
@app.route('/mealplanner')
@login_required
def meal_planner():
return render_template('meal_planner.html')
@app.route('/searchusers')
def search_users():
q = request.args.get('q')
s = request.args.get('s')
query = 'SELECT username FROM users WHERE id>0 AND username LIKE :q;'
if s == '1':
r = db_engine.execute(text(query), q=(q+'%'))
else:
r = db_engine.execute(text(query), q=q)
result = []
for row in r:
result.append(list(row)[0])
r.close()
return str(result)
@app.route('/getkukcandidate')
def get_kuk_candidate():
date = datetime.datetime.strptime(request.args.get('date'), '%Y-%m-%d %H:%M')
meal_eaters = request.args.get('eaters').split(',')
u_meals, t_lb = getUpcomingMeals()
return [e['name'] for e in t_lb if e['name'] in meal_eaters][0]
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])
def login(): def login():
if request.method == 'POST': if request.method == 'POST':
+146
View File
@@ -0,0 +1,146 @@
var active_timer = 100;
var eaters = []
$( function() {
$(".user-result-container").position({
my: "left top",
at: "left bottom",
of: $('#search-user'),
collision: "fit"
});
$('.user-result-container').hide();
$( "#datepicker" ).datepicker({
dateFormat: 'D, yy-mm-dd'
});
$('#spinner-hour').spinner({
min: 0,
max: 23,
numberFormat: 'n'
});
$('#spinner-minute').spinner({
min: 0,
max: 59,
numberFormat: 'n'
});
$('#search-user').on('keyup', function(){
clearTimeout(active_timer);
active_timer = setTimeout(user_search, 500);
});
eaters.push($($('.username')[0]).text()); // Kinda weird but ok
});
function plan_meal() {
var meal_date = $('#datepicker').datepicker('getDate');
if(isNaN($('#spinner-hour').val()) || isNaN($('#spinner-minute').val())) {
alert('Invalid time entered.');
return;
}
if(isNaN($('#deadline').val())) {
alert('Invalid deadline entered.');
return;
}
if ((0 <= +$('#spinner-hour').val() <= 23) && (0 <= +$('#spinner-minute').val() <= 59)) {
meal_date.setHours(+$('#spinner-hour').val(), +$('#spinner-minute').val())
} else {
alert('Invalid time entered.');
return;
}
var description_v = $('#flavor-text').val();
var deadline_amount = $('#deadline').val();
}
function add_user() {
if (eaters.includes($('#search-user').val()))
return;
$.ajax({
url: "/searchusers?q=" + $('#search-user').val() + "&s=0"
}).done(function(results) {
if (results == '[]') {
alert('Invalid username');
return;
}
var meal_date = $('#datepicker').datepicker('getDate');
if (meal_date == null || $('#spinner-hour').val() == '' || $('#spinner-minute').val() == '') {
alert('Please select a date and a time.');
return;
}
names = results.substring(1, results.length - 1).split(', ');
new_eater = names[0].substring(1, names[0].length - 1);
eaters.push(new_eater);
var month = (meal_date.getMonth() + 1).toString();
if (month.length == 1)
month = '0' + month;
var date = (meal_date.getDate()).toString();
if (date.length == 1)
date = '0' + date;
if ($('#spinner-hour').val().length == 1)
$('#spinner-hour').val('0' + $('#spinner-hour').val());
if ($('#spinner-minute').val().length == 1)
$('#spinner-minute').val('0' + $('#spinner-minute').val());
var meal_timestamp = meal_date.getFullYear() + '-' +
month + '-' +
date + ' ' +
$('#spinner-hour').val() + ':' +
$('#spinner-minute').val();
$.ajax({
url: "/getkukcandidate?date=" + meal_timestamp + "&eaters=" + eaters.toString()
}).done(function(estkuk) {
$('#est-cook').attr('src', 'static/' + estkuk + '.png')
$('#est-cook').attr('title', estkuk)
});
e = '<div class="add-people-container" id="for-user-' + new_eater + '">\
<div class="flex-card" style="margin: 0">\
<img src="static/' + new_eater + '.png" class="flex-thumb">\
<span class="username">' + new_eater + '</span>\
</div>\
<div class="small-round-button" onclick="remove_user(\'' + new_eater + '\')"><i class="fa fa-minus" aria-hidden="true"></i></div>\
</div>';
$('#add-user').before(e);
$('.small-round-button').show();
});
}
function remove_user(name) {
eaters = eaters.filter(function(value, index, arr){
return value != name;
});
$('#for-user-' + name).remove();
if ($('#eaters-list > div').length == 2) {
$('.small-round-button').hide();
}
}
function fill_box(name) {
$('#search-user').val(name);
$('.user-result-container').hide();
}
function user_search() {
$('.user-result-container').hide();
if ($('#search-user').val() == '')
return;
$.ajax({
url: "/searchusers?q=" + $('#search-user').val() + "&s=1"
}).done(function(results) {
// Load results
if (results == '[]')
return;
$('.user-result-container').empty();
names = results.substring(1, results.length-1).split(', ');
$.each(names, function(i, r){
var name = r.substring(1, r.length-1);
e = '<div class="user-result" onclick="fill_box(\'' + name + '\')">\
<img src="static/' + name + '.png" class="user-result-thumb">\
<span class="username">' + name + '</span>\
</div>'
$('.user-result-container').append($(e));
});
// $(".user-result-container").position({
// my: "left top",
// at: "left bottom",
// of: $('#search-user'),
// collision: "fit"
// });
$('.user-result-container').show();
});
}
+102 -2
View File
@@ -63,13 +63,13 @@ h2 {
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5); box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
} }
.flex-card img { .flex-thumb {
height: 80px; height: 80px;
width: 80px; width: 80px;
margin: 16px 20px; margin: 16px 20px;
} }
.flex-card .flex-small-thumb { .flex-small-thumb {
height: 32px; height: 32px;
width: 32px; width: 32px;
display: inline-block; display: inline-block;
@@ -120,6 +120,37 @@ h2 {
margin: 16px 20px; margin: 16px 20px;
} }
.small-round-button {
display: flex;
align-items: center;
justify-content: center;
color: white;
background-color: #FF0000;
cursor: pointer;
width: 30px;
height: 30px;
border-radius: 15px;
font-size: 20px;
margin: auto 30px;
}
.floating-round-button {
display: flex;
align-items: center;
justify-content: center;
color: white;
background-color: #EE7500;
cursor: pointer;
width: 80px;
height: 80px;
border-radius: 40px;
font-size: 42px;
position: fixed;
-webkit-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
-moz-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
}
.user-card { .user-card {
display: flex; display: flex;
position: absolute; position: absolute;
@@ -188,3 +219,72 @@ h2 {
text-align: center; text-align: center;
color: white; color: white;
} }
.flex-card-vert {
width: 30%;
display: inline-flex;
flex-direction: column;
background-color: #F1EDEA;
-webkit-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
-moz-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
margin: 0.5%;
padding: 1em;
}
.add-people-container {
display: flex;
justify-content: space-between;
margin: 5px 0;
}
.sub-flex {
display: flex;
}
.sub-flex * {
margin: auto 3px;
}
#search-user, #flavor-text, #datepicker, #deadline-amount {
min-width: 0;
padding: 0.5em;
}
#search-user {
margin: auto 0;
}
.ui-spinner {
flex: 4;
}
.user-result-container {
display: flex;
flex-direction: column;
background-color: #F1EDEA;
-webkit-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
-moz-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
position: fixed;
}
.user-result {
display: flex;
align-items: center;
border: solid 1px #A8A4A1;
cursor: pointer;
}
.user-result:hover {
background-color: #A8A4A1;
}
.user-result span {
margin: auto 20px;
}
.user-result-thumb {
width: 50px;
margin: 10px 20px;
}
-55
View File
@@ -1,55 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>KUKapp</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
<script src="{{ url_for('static', filename='script.js') }}"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
<style type="text/css">
html {
background-image: url({{url_for('static', filename='burger.jpg')}});
background-position: left top;
background-repeat: no-repeat;
background-size: 100% auto;
background-color: #aeaeac;
}
</style>
</head>
<body>
<div class="leaderboard">
<h1 style="text-align: center">Leaderboard</h1>
<div class="leaderboard-contiainer">
{% for person in leaderboard %}
<div class="lb-entry">
<img src="{{url_for('static', filename=person['name'] + '.png')}}">
<span class="name">{{ person['name'] }}</span>
<span class="score">{{ person['score'] }}</span>
</div>
{% endfor %}
</div>
</div>
<div class="next-meal">
<h1 style="padding-left: 40pt">Next Meal</h1>
<h2>Cook</h2>
<div class="cook-entry">
Davide
</div>
<h2>Eaters</h2>
<div class="eater-entry">
Marek
</div>
<div class="eater-entry">
Sven
</div>
</div>
<div class="user-info">
<div class="user-card">
<img src="{{url_for('static', filename=current_user_name + '.png')}}">
<span>{{current_user_name}}</span>
<div class="logout-button" onclick="location.href='/logout';"><span>LOGOUT</span></div>
</div>
</div>
</body>
</html>
+2 -1
View File
@@ -41,7 +41,7 @@
{% if meal.needs_confirmation %} {% if meal.needs_confirmation %}
<div class="flex-card" onclick="location.href='/verify?meal={{meal.id}}';" style="cursor: pointer; width: 60%; justify-content: space-between;"> <div class="flex-card" onclick="location.href='/verify?meal={{meal.id}}';" style="cursor: pointer; width: 60%; justify-content: space-between;">
{% else %} {% else %}
<div class="flex-card" onclick="location.href='/view_meal?meal={{meal.id}}';" style="cursor: pointer; width: 60%; justify-content: space-between;"> <div class="flex-card" onclick="location.href='/viewmeal?meal={{meal.id}}';" style="cursor: pointer; width: 60%; justify-content: space-between;">
{% endif %} {% endif %}
<span{% if meal.needs_confirmation%} style="color: #EE7500;"{% endif %}><b>{{meal.meal_time}}</b></span> <span{% if meal.needs_confirmation%} style="color: #EE7500;"{% endif %}><b>{{meal.meal_time}}</b></span>
<p style="text-align: left;">{% if meal.needs_confirmation %}Did &nbsp;{% endif %}{% if meal.kuk != "" %}<img class="flex-small-thumb" src="{{url_for('static', filename=meal.kuk + '.png')}}" title="{{meal.kuk}}" align="middle" style="margin: " /> &nbsp; {% if not meal.needs_confirmation %}<b>WILL</b>{% endif %}{% else %}<img class="flex-small-thumb" src="{{url_for('static', filename=meal.candidate + '.png')}}" title="{{meal.kuk}}" align="middle" style="margin: " /> &nbsp; {% if not meal.needs_confirmation %}<b>SHOULD</b>{% endif %}{% endif%} 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 %}{% if meal.needs_confirmation %}<b>?</b>{% endif %}</p> <p style="text-align: left;">{% if meal.needs_confirmation %}Did &nbsp;{% endif %}{% if meal.kuk != "" %}<img class="flex-small-thumb" src="{{url_for('static', filename=meal.kuk + '.png')}}" title="{{meal.kuk}}" align="middle" style="margin: " /> &nbsp; {% if not meal.needs_confirmation %}<b>WILL</b>{% endif %}{% else %}<img class="flex-small-thumb" src="{{url_for('static', filename=meal.candidate + '.png')}}" title="{{meal.kuk}}" align="middle" style="margin: " /> &nbsp; {% if not meal.needs_confirmation %}<b>SHOULD</b>{% endif %}{% endif%} 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 %}{% if meal.needs_confirmation %}<b>?</b>{% endif %}</p>
@@ -67,6 +67,7 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="floating-round-button" onclick="location.href='/mealhistory';" title="View meal history" style="bottom: 20px; right: 20px;"><i class="fa fa-history" aria-hidden="true"></i></div>
</div> </div>
</body> </body>
</html> </html>
+78
View File
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html>
<head>
<title>Plan a meal</title>
<meta name="viewport" content="width=device-width">
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="{{ url_for('static', filename='mealplanner_script.js') }}"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
<style type="text/css">
html {
background-image: url({{url_for('static', filename='burger.jpg')}});
background-position: left top;
background-repeat: no-repeat;
background-size: 100% auto;
background-color: #aeaeac;
background-attachment: fixed;
}
</style>
</head>
<body>
<h1 style="margin: 40px;">Plan a meal</h1>
<div class="flex-card-vert">
<h3>When</h3>
<div class="sub-flex" id="when">
<input type="text" id="datepicker" name="date" style="flex: 7;">
<span style="flex: 0.5;">@</span>
<input type="text" id="spinner-hour" name="hour" style="flex: 4;">
<span style="flex: 0.5;">:</span>
<input type="text" id="spinner-minute" name="minute" style="flex: 4;">
</div>
<h3>Choose a description</h3>
<input type="text" name="flavor_text" id="flavor-text">
<h3>Can join until</h3>
<div class="sub-flex" id="deadline">
<input type="text" name="deadline-amount" id="deadline-amount" pattern="^\d+(\.\d+)?$">
<select id="deadline-unit">
<option value="m">Minutes</option>
<option value="h" selected>Hours</option>
<option value="d">Days</option>
</select>
<span>before</span>
</div>
<h3>Estimated cook: <img src="{{url_for('static', filename=current_user.name + '.png')}}" id="est-cook" class="flex-small-thumb" title="{{current_user.name}}"></h3>
</div>
<div class="flex-card-vert" id="eaters-list">
<h3>Add people</h3>
<div class="add-people-container" id="for-user-{{current_user.name}}">
<div class="flex-card" style="margin: 0">
<img src="{{url_for('static', filename=current_user.name + '.png')}}" class="flex-thumb">
<span class="username">{{ current_user.name }}</span>
</div>
<div class="small-round-button" style="display: none;" onclick="remove_user('{{current_user.name}}')"><i class="fa fa-minus" aria-hidden="true"></i></div>
</div>
<div class="add-people-container" id="add-user">
<input type="text" id="search-user">
<div class="user-result-container"></div>
<div class="round-button" onclick="add_user()"><i class="fa fa-plus" aria-hidden="true"></i></div>
</div>
</div>
<div class="user-card">
<img src="{{url_for('static', filename=current_user.name + '.png')}}">
<div class="user-info">
<span>{{current_user.name}}</span>
<div class="rect-button" onclick="location.href='/logout';" style="background-color: #EE7500;">LOGOUT</div>
</div>
</div>
<div class="floating-round-button" onclick="plan_meal()" style="bottom: 20px; right: 20px;"><i class="fa fa-check" aria-hidden="true"></i></div>
<!-- Pick a date <input type="text" id="datepicker"><br>
Pick a time <input type="text" id="spinner-hour" style="width: 3em;">&nbsp;:&nbsp;<input type="text" id="spinner-minute" style="width: 3em;"> -->
</body>
</html>
+5 -5
View File
@@ -33,23 +33,23 @@
<h2>Cook</h2> <h2>Cook</h2>
<div class="flex-card"> <div class="flex-card">
{% if meal.kuk == "" %} {% if meal.kuk == "" %}
<img src="{{url_for('static', filename='question.png')}}"> <img src="{{url_for('static', filename='question.png')}}" class="flex-thumb">
<p>If nobody volunteers,<br><img class="flex-small-thumb" src="{{url_for('static', filename=meal.candidate + '.png')}}" title="{{meal.candidate}}" align="middle"> will cook.</p> <p>If nobody volunteers,<br><img class="flex-small-thumb" src="{{url_for('static', filename=meal.candidate + '.png')}}" title="{{meal.candidate}}" align="middle"> will cook.</p>
<div class="rect-button" onclick="location.href='/volunteer';" style="background-color: #EE7500;">VOLUNTEER</div> <div class="rect-button" onclick="location.href='/volunteer';" style="background-color: #EE7500;">VOLUNTEER</div>
{% else %} {% else %}
<img src="{{url_for('static', filename=meal.kuk + '.png')}}"> <img src="{{url_for('static', filename=meal.kuk + '.png')}}" class="flex-thumb">
<span class="username">{{ meal.kuk }}</span> <span class="username">{{ meal.kuk }}</span>
<div class="rect-button" style="background-color: #8faf38; cursor: default;">CONFIRMED</div> <div class="rect-button" style="background-color: #8faf38; cursor: default;">CONFIRMED</div>
{% endif %} {% endif %}
</div> </div>
<h2>Eaters</h2> <h2>Eaters</h2>
{% for eater in meal.eaters %} {% for eater in meal.eaters %}
<div class="flex-card"> <div class="flex-card">
<img src="{{url_for('static', filename=eater + '.png')}}"> <img src="{{url_for('static', filename=eater + '.png')}}" class="flex-thumb">
<span class="username">{{ eater }}</span> <span class="username">{{ eater }}</span>
</div> </div>
{% endfor %} {% endfor %}
{% if not current_user.name in eaters and current_user.name != meal.kuk %} {% if not current_user.name in meal.eaters and current_user.name != meal.kuk %}
<div class="flex-card" style="background: none; box-shadow: none"> <div class="flex-card" style="background: none; box-shadow: none">
<div class="round-button" onclick="location.href='/addme?meal={{meal.id}}';"><i class="fa fa-plus" aria-hidden="true"></i></div> <div class="round-button" onclick="location.href='/addme?meal={{meal.id}}';"><i class="fa fa-plus" aria-hidden="true"></i></div>
<span>Add me</span> <span>Add me</span>