Compare commits
75
Commits
8fc7a954ab
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
972461dab4 | ||
|
|
680be19b07 | ||
|
|
f20243b247 | ||
|
|
574e3114fa | ||
|
|
18d8d2ede9 | ||
|
|
259961da6e | ||
|
|
baeed56490 | ||
|
|
b1d8323c30 | ||
|
|
1061b7c08e | ||
|
|
77ecebc9c7 | ||
|
|
d0ff0ceb46 | ||
|
|
37ee3a1611 | ||
|
|
616840676f | ||
|
|
fcbc47b3ae | ||
|
|
b535de925c | ||
|
|
0829704105 | ||
|
|
25024433a4 | ||
|
|
fd94641203 | ||
|
|
fa7fcbb337 | ||
|
|
ba5e35993d | ||
|
|
64396c29d8 | ||
|
|
7cf3580844 | ||
|
|
e3bfe39695 | ||
|
|
1e6137370e | ||
|
|
1f5b4cedfd | ||
|
|
ce75733204 | ||
|
|
68ef11a2b0 | ||
|
|
423c8f227f | ||
|
|
d174707e21 | ||
|
|
36e16c511b | ||
|
|
95dc07d1e7 | ||
|
|
78a62e20b9 | ||
|
|
181214c5c6 | ||
|
|
5f7b38b839 | ||
|
|
7441ee742b | ||
|
|
8d596a55ab | ||
|
|
2d1afdc721 | ||
|
|
6df0ac3dfc | ||
|
|
50c03e582b | ||
|
|
3853c6aeb3 | ||
|
|
1e0668ad77 | ||
|
|
cdd6d2f1e3 | ||
|
|
faaf3828a1 | ||
|
|
6c691e1aae | ||
|
|
89c27077fd | ||
|
|
a0fa4a9d4d | ||
|
|
0b760577c6 | ||
|
|
22f997b15c | ||
|
|
c2c3b2b4cb | ||
|
|
8abd54e9d2 | ||
|
|
84f37a8780 | ||
|
|
a60ce39974 | ||
|
|
54787f68d5 | ||
|
|
ab292c7b2e | ||
|
|
63712eca1f | ||
|
|
b12a9b90e0 | ||
|
|
839942e9d7 | ||
|
|
af1b289710 | ||
|
|
59b6785121 | ||
|
|
049b0e66ba | ||
|
|
17428dffdf | ||
|
|
2cefc5e5fd | ||
|
|
d0cc5984eb | ||
|
|
caf35bb6cd | ||
|
|
566d03096a | ||
|
|
a24d793287 | ||
|
|
50c01cdf9d | ||
|
|
0f6b449bf0 | ||
|
|
35e577424a | ||
|
|
0cd0265599 | ||
|
|
056de43a91 | ||
|
|
f91baa7d93 | ||
|
|
e44d43af0e | ||
|
|
6c5b5e3432 | ||
|
|
ff15cb81c1 |
@@ -0,0 +1,3 @@
|
|||||||
|
bin/
|
||||||
|
lib/
|
||||||
|
*.pyc
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
import random
|
import random
|
||||||
import operator
|
import operator
|
||||||
import json
|
import json
|
||||||
from flask import Flask, Response, redirect, url_for, request, session, abort, render_template
|
|
||||||
from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user
|
|
||||||
from sqlalchemy.sql import select, text
|
|
||||||
import datetime
|
import datetime
|
||||||
|
from flask import Flask, Response, redirect, url_for, request, abort, render_template
|
||||||
|
from flask_login import LoginManager, UserMixin, login_required, login_user, logout_user, current_user
|
||||||
|
import sqlalchemy
|
||||||
|
from sqlalchemy.sql import select, text
|
||||||
|
from dateutil.parser import parse
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
#config
|
#config
|
||||||
@@ -17,26 +19,260 @@ app.config.update(
|
|||||||
db_engine = {}
|
db_engine = {}
|
||||||
db_metadata = {}
|
db_metadata = {}
|
||||||
meals = {}
|
meals = {}
|
||||||
|
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):
|
||||||
|
def __init__(self, name):
|
||||||
|
self.name = name
|
||||||
|
self.id = name
|
||||||
|
self.user_id = -1
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get(name):
|
||||||
|
if name not in users:
|
||||||
|
users[name] = User(name)
|
||||||
|
return users[name]
|
||||||
|
|
||||||
|
def connect(user, password, db, host='localhost', port=5432):
|
||||||
|
url = 'postgresql://{}:{}@{}:{}/{}'
|
||||||
|
url = url.format(user, password, host, port, db)
|
||||||
|
con = sqlalchemy.create_engine(url, client_encoding='utf8')
|
||||||
|
meta = sqlalchemy.MetaData(bind=con, reflect=True)
|
||||||
|
return con, meta
|
||||||
|
|
||||||
def getLeaderboard():
|
def getLeaderboard():
|
||||||
leaders = []
|
s = 'select u.username as name, u.score as score, max(m.meal_date) as last_meal from users as u left join meals as m on m.kuk = u.id where u.id > 0 group by u.id order by score, last_meal;'
|
||||||
leaders.append({'name':'marek', 'score':'34'})
|
r = db_engine.execute(text(s))
|
||||||
leaders.append({'name':'sven', 'score':'16'})
|
leaders=[]
|
||||||
return {}
|
for row in r:
|
||||||
|
leaders.append(dict(row))
|
||||||
|
r.close()
|
||||||
|
return leaders
|
||||||
|
|
||||||
def getUpcomingMeals():
|
def getUpcomingMeals():
|
||||||
|
# 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})
|
||||||
|
# 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})
|
||||||
|
# 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})
|
||||||
|
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))
|
||||||
meals = []
|
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})
|
leaderboard = getLeaderboard()
|
||||||
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})
|
for row in r:
|
||||||
return {}
|
meals.append(dict(row))
|
||||||
|
seconds_to_deadline = (meals[-1]['selection_deadline'] - datetime.datetime.now()).total_seconds()
|
||||||
|
if seconds_to_deadline < 0:
|
||||||
|
meals[-1]['friendly_selection_deadline'] = ''
|
||||||
|
elif seconds_to_deadline > 3600:
|
||||||
|
hours_td = round(seconds_to_deadline / 3600)
|
||||||
|
days_td = int(hours_td / 24)
|
||||||
|
hours_td = hours_td % 24
|
||||||
|
meals[-1]['friendly_selection_deadline'] = str(days_td) + ' days ' + str(hours_td) + ' hours'
|
||||||
|
else:
|
||||||
|
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_friendly_date'] = meals[-1]['meal_date'].strftime('%A %d %B')
|
||||||
|
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:
|
||||||
|
meals[-1]['needs_confirmation'] = True
|
||||||
|
else:
|
||||||
|
meals[-1]['needs_confirmation'] = False
|
||||||
|
leaderboard = applyTempMeal(leaderboard, meals[-1])
|
||||||
|
r.close()
|
||||||
|
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):
|
||||||
|
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)
|
||||||
|
meals = []
|
||||||
|
for row in r:
|
||||||
|
meals.append(dict(row))
|
||||||
|
r.close()
|
||||||
|
if len(meals) == 0:
|
||||||
|
return None
|
||||||
|
meal = meals[0]
|
||||||
|
seconds_to_deadline = (meal['selection_deadline'] - datetime.datetime.now()).total_seconds()
|
||||||
|
if seconds_to_deadline < 0:
|
||||||
|
meal['friendly_selection_deadline'] = ''
|
||||||
|
elif seconds_to_deadline > 3600:
|
||||||
|
hours_td = round(seconds_to_deadline / 3600)
|
||||||
|
days_td = int(hours_td / 24)
|
||||||
|
hours_td = hours_td % 24
|
||||||
|
meal['friendly_selection_deadline'] = str(days_td) + ' days ' + str(hours_td) + ' hours'
|
||||||
|
else:
|
||||||
|
meal['friendly_selection_deadline'] = str(round(seconds_to_deadline / 60)) + ' minutes'
|
||||||
|
meal['meal_time'] = meal['meal_date'].strftime('%H:%M')
|
||||||
|
meal['meal_friendly_date'] = meal['meal_date'].strftime('%A %d %B')
|
||||||
|
meal['candidate'] = 'davide'
|
||||||
|
if (meal['meal_date'] - datetime.datetime.now()).total_seconds() < 0:
|
||||||
|
meal['needs_confirmation'] = True
|
||||||
|
else:
|
||||||
|
meal['needs_confirmation'] = False
|
||||||
|
|
||||||
|
return meal
|
||||||
|
|
||||||
|
# adding to meal
|
||||||
|
@app.route("/addme")
|
||||||
|
@login_required
|
||||||
|
def addme():
|
||||||
|
meal_id = request.args.get('meal')
|
||||||
|
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)
|
||||||
|
results = []
|
||||||
|
for row in r:
|
||||||
|
results.append(dict(row))
|
||||||
|
if not results[0]['is_eater'] == 'True':
|
||||||
|
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) )
|
||||||
|
else:
|
||||||
|
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('index-new.html', leaderboard=getLeaderboard(), upcomingMeals=getUpcomingMeals(), current_user_name='Wille')
|
meals, _ = getUpcomingMeals()
|
||||||
|
return render_template('meal_list.html', leaderboard=getLeaderboard(), meals=meals)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
@app.route('/viewmeal')
|
||||||
with open('admin.json') as f:
|
def view_meal():
|
||||||
|
meal_id = request.args.get('meal')
|
||||||
|
meal = getMeal(meal_id)
|
||||||
|
if meal == None:
|
||||||
|
return abort(400)
|
||||||
|
print(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'])
|
||||||
|
def login():
|
||||||
|
if request.method == 'POST':
|
||||||
|
username = request.form['username']
|
||||||
|
password = request.form['password']
|
||||||
|
r = db_engine.execute(text('select id from users where username=:username and password=:password'), username=username, password=password)
|
||||||
|
result = []
|
||||||
|
for row in r:
|
||||||
|
result.append(dict(row))
|
||||||
|
r.close()
|
||||||
|
print(len(users))
|
||||||
|
if len(result) > 0:
|
||||||
|
u = User.get(username)
|
||||||
|
u.user_id = result[0]['id']
|
||||||
|
login_user(u)
|
||||||
|
return redirect(request.args.get('next') or url_for('index'))
|
||||||
|
return abort(401)
|
||||||
|
else:
|
||||||
|
return Response('''
|
||||||
|
<form action="" method="post">
|
||||||
|
<p><input type=text name=username>
|
||||||
|
<p><input type=password name=password>
|
||||||
|
<p><input type=submit value=Login>
|
||||||
|
</form>
|
||||||
|
''')
|
||||||
|
|
||||||
|
with open('admin.json') as f:
|
||||||
postgres_credentials = json.load(f)
|
postgres_credentials = json.load(f)
|
||||||
db_engine, db_metadata = connect(postgres_credentials['username'], postgres_credentials['password'], 'kuk_app')
|
db_engine, db_metadata = connect(postgres_credentials['username'], postgres_credentials['password'], 'kuk_app')
|
||||||
meals = sqlalchemy.Table('meals', db_metadata)
|
meals = sqlalchemy.Table('meals', db_metadata)
|
||||||
|
|
||||||
|
login_manager = LoginManager()
|
||||||
|
login_manager.init_app(app)
|
||||||
|
login_manager.login_view = "login"
|
||||||
|
|
||||||
|
# somewhere to logout
|
||||||
|
@app.route("/logout")
|
||||||
|
@login_required
|
||||||
|
def logout():
|
||||||
|
logout_user()
|
||||||
|
return Response('<p>Logged out</p>')
|
||||||
|
|
||||||
|
# handle login failed
|
||||||
|
@app.errorhandler(401)
|
||||||
|
def page_not_found(e):
|
||||||
|
return Response('<p>Login failed</p>')
|
||||||
|
|
||||||
|
# callback to reload the user object
|
||||||
|
@login_manager.user_loader
|
||||||
|
def load_user(userid):
|
||||||
|
return User.get(userid)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
app.run('0.0.0.0')
|
app.run('0.0.0.0')
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -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();
|
||||||
|
});
|
||||||
|
}
|
||||||
+165
-142
@@ -8,165 +8,92 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
margin-left: 3%;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
padding-left: 40pt;
|
margin-left: 3%;
|
||||||
}
|
|
||||||
|
|
||||||
.leaderboard {
|
|
||||||
width: 35%;
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
padding-top: 8pt;
|
|
||||||
height: auto;
|
|
||||||
background-color: rgba(0,0,0,0.8);
|
|
||||||
color: #d4d0cd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-pane {
|
.right-pane {
|
||||||
width: 65%;
|
width: 70%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 35%;
|
|
||||||
padding-top: 8pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lb-entry {
|
|
||||||
padding: 0;
|
|
||||||
height: 60pt;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lb-entry img {
|
|
||||||
height: 50pt;
|
|
||||||
width: auto;
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 25pt;
|
|
||||||
margin-top: -25pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lb-entry span.score {
|
|
||||||
position: absolute;
|
|
||||||
font-size: 16pt;
|
|
||||||
top: 50%;
|
|
||||||
margin-top: -8pt;
|
|
||||||
left: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lb-entry span.name {
|
|
||||||
position: absolute;
|
|
||||||
font-size: 16pt;
|
|
||||||
top: 50%;
|
|
||||||
margin-top: -8pt;
|
|
||||||
left: 30%;
|
left: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cook-entry {
|
.leaderboard {
|
||||||
padding: 0;
|
position: fixed;
|
||||||
/*height: 90pt;*/
|
width: 30%;
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cook-card {
|
|
||||||
background-color: #F1EDEA;
|
|
||||||
height: 100pt;
|
|
||||||
margin-left: 20pt;
|
|
||||||
-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);
|
|
||||||
}
|
|
||||||
|
|
||||||
.cook-card img {
|
|
||||||
height: 50pt;
|
|
||||||
width: auto;
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 40pt;
|
|
||||||
margin-top: -25pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
#cook-small-thumb {
|
|
||||||
height: 20pt;
|
|
||||||
width: auto;
|
|
||||||
position: relative;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0,0,0,0.8);
|
||||||
|
color: #d4d0cd;
|
||||||
|
overflow: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cook-card span {
|
.lb-entry {
|
||||||
position: absolute;
|
display: flex;
|
||||||
font-size: 16pt;
|
justify-content: space-around;
|
||||||
top: 50%;
|
|
||||||
margin-top: -8pt;
|
|
||||||
left: 120pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cook-card p {
|
.lb-entry img {
|
||||||
position: absolute;
|
height: 80px;
|
||||||
left: 140pt;
|
width: 80px;
|
||||||
margin: -16pt 0 0 0;
|
margin: 10px 0;
|
||||||
font-size: 11pt;
|
|
||||||
height: 24pt;
|
|
||||||
top: 50%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.eater-entry {
|
.lb-entry span {
|
||||||
padding: 0;
|
margin: auto 0;
|
||||||
position: relative;
|
font-size: 20px;
|
||||||
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.eater-card {
|
.flex-card {
|
||||||
|
margin: 8px auto;
|
||||||
|
display: flex;
|
||||||
|
width: fit-content;
|
||||||
|
min-width: 240px;
|
||||||
background-color: #F1EDEA;
|
background-color: #F1EDEA;
|
||||||
height: 70pt;
|
margin-left: 3%;
|
||||||
width: 200pt;
|
|
||||||
margin: 6pt 0 6pt 20pt;
|
|
||||||
-webkit-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
|
-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);
|
-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);
|
box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.eater-card img {
|
.flex-thumb {
|
||||||
height: 50pt;
|
height: 80px;
|
||||||
width: auto;
|
width: 80px;
|
||||||
position: absolute;
|
margin: 16px 20px;
|
||||||
top: 50%;
|
|
||||||
left: 40pt;
|
|
||||||
margin-top: -25pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.eater-card span {
|
.flex-small-thumb {
|
||||||
position: absolute;
|
height: 32px;
|
||||||
font-size: 16pt;
|
width: 32px;
|
||||||
top: 50%;
|
display: inline-block;
|
||||||
margin-top: -8pt;
|
margin: -6px 0 0 0;
|
||||||
left: 120pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.eater-entry span {
|
.flex-card span {
|
||||||
position: absolute;
|
margin: auto 20px;
|
||||||
font-size: 16pt;
|
font-size: 20px;
|
||||||
top: 50%;
|
|
||||||
margin-top: -8pt;
|
|
||||||
left: 120pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*.rect-button {
|
.flex-card .rect-button {
|
||||||
width: 100pt;
|
margin: auto 20px;
|
||||||
height: 26pt;
|
}
|
||||||
background-color: #EE7500;
|
|
||||||
position: absolute;
|
.flex-card .people {
|
||||||
color: white;
|
margin: auto 20px;
|
||||||
top: 50%;
|
}
|
||||||
right: 32pt;
|
|
||||||
margin-top: -13pt;
|
.flex-card p {
|
||||||
cursor: pointer;
|
font-size: 14px;
|
||||||
}*/
|
text-align: center;
|
||||||
|
line-height: 280%;
|
||||||
|
}
|
||||||
|
|
||||||
.rect-button span {
|
.rect-button span {
|
||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
@@ -179,27 +106,49 @@ h2 {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-button {
|
.round-button {
|
||||||
height: 50pt;
|
display: flex;
|
||||||
width: 50pt;
|
align-items: center;
|
||||||
position: absolute;
|
justify-content: center;
|
||||||
top: 50%;
|
|
||||||
left: 40pt;
|
|
||||||
margin-top: -25pt;
|
|
||||||
color: white;
|
color: white;
|
||||||
border-radius: 25pt;
|
|
||||||
background-color: #EE7500;
|
background-color: #EE7500;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
border-radius: 40px;
|
||||||
|
font-size: 42px;
|
||||||
|
margin: 16px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-button span {
|
.small-round-button {
|
||||||
font-size: 34pt;
|
display: flex;
|
||||||
position: absolute;
|
align-items: center;
|
||||||
top: 50%;
|
justify-content: center;
|
||||||
margin-top: -18pt;
|
color: white;
|
||||||
left: 0;
|
background-color: #FF0000;
|
||||||
width: 100%;
|
cursor: pointer;
|
||||||
text-align: center;
|
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 {
|
||||||
@@ -229,6 +178,7 @@ h2 {
|
|||||||
.user-card span {
|
.user-card span {
|
||||||
font-size: 16pt;
|
font-size: 16pt;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logout-button {
|
.logout-button {
|
||||||
@@ -243,6 +193,10 @@ h2 {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.username {
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
.rect-button {
|
.rect-button {
|
||||||
width: 90px;
|
width: 90px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
@@ -265,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;
|
||||||
|
}
|
||||||
@@ -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>
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Meal planned for {{meal_date}} - 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;
|
|
||||||
background-attachment: fixed;
|
|
||||||
}
|
|
||||||
</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="right-pane">
|
|
||||||
<h1 style="padding-left: 40pt">Next Meal</h1>
|
|
||||||
<h2>Cook</h2>
|
|
||||||
<div class="cook-entry">
|
|
||||||
<div class="cook-card">
|
|
||||||
<span>date: {{ date }}</span>
|
|
||||||
{% if cook.confirmed == "no" %}
|
|
||||||
<img src="{{url_for('static', filename='question.png')}}">
|
|
||||||
<p>If nobody volunteers,<br><br><img id="cook-small-thumb" src="{{url_for('static', filename=cook.name + '.png')}}"> will cook.</p>
|
|
||||||
<div class="rect-button" onclick="location.href='/volunteer';"><span>VOLUNTEER</span></div>
|
|
||||||
{% else %}
|
|
||||||
<img src="{{url_for('static', filename= cook.name + '.png')}}">
|
|
||||||
<span>{{ cook.name }}</span>
|
|
||||||
<div class="rect-button" style="background-color: #8faf38; cursor: default;"><span>CONFIRMED</span></div>
|
|
||||||
{% endif %}
|
|
||||||
</div></div>
|
|
||||||
<h2>Eaters</h2>
|
|
||||||
{% for eater in eaters %}
|
|
||||||
<div class="eater-entry">
|
|
||||||
<div class="eater-card">
|
|
||||||
<img src="{{url_for('static', filename=eater + '.png')}}">
|
|
||||||
<span>{{ eater }}</span>
|
|
||||||
</div></div>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% if not current_user.name in eaters %}
|
|
||||||
<div class="eater-entry" style="height: 60pt;">
|
|
||||||
<div class="add-button" onclick="location.href='/addme';"><span><i class="fa fa-plus" aria-hidden="true"></i></span></div>
|
|
||||||
<span>Add me</span>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="eater-entry" style="height: 60pt;">
|
|
||||||
<div class="add-button" onclick="location.href='/removeme';"><span><i class="fa fa-minus" aria-hidden="true"></i></span></div>
|
|
||||||
<span>Remove me</span>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</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>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Meal List - KUKAPP</title>
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
|
<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;
|
||||||
|
background-attachment: fixed;
|
||||||
|
}
|
||||||
|
</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="right-pane">
|
||||||
|
<div class="meal-list">
|
||||||
|
<h2>{{meals[0].meal_friendly_date}}</h2>
|
||||||
|
{% for meal in meals %}
|
||||||
|
{% if loop.index != 1 and (meal.meal_friendly_date != meals[loop.index - 2].meal_friendly_date) %}
|
||||||
|
<h2>{{meal.meal_friendly_date}}</h2>
|
||||||
|
{% endif %}
|
||||||
|
{% if meal.needs_confirmation %}
|
||||||
|
<div class="flex-card" onclick="location.href='/verify?meal={{meal.id}}';" style="cursor: pointer; width: 60%; justify-content: space-between;">
|
||||||
|
{% else %}
|
||||||
|
<div class="flex-card" onclick="location.href='/viewmeal?meal={{meal.id}}';" style="cursor: pointer; width: 60%; justify-content: space-between;">
|
||||||
|
{% endif %}
|
||||||
|
<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 {% endif %}{% if meal.kuk != "" %}<img class="flex-small-thumb" src="{{url_for('static', filename=meal.kuk + '.png')}}" title="{{meal.kuk}}" align="middle" style="margin: " /> {% 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: " /> {% 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"/> {% endfor %}{% if meal.needs_confirmation %}<b>?</b>{% endif %}</p>
|
||||||
|
{% if meal.needs_confirmation %}<span style="color: #EE7500;">Please verify.{% else %}<span>{% if meal.friendly_selection_deadline != '' %}Confirmed in {{meal.friendly_selection_deadline}}{% else %}Confirmed.{% endif %}{% endif %}</span>
|
||||||
|
</div>
|
||||||
|
{% endfor%}
|
||||||
|
<h2> </h2>
|
||||||
|
<div class="flex-card" style="background: none; box-shadow: none">
|
||||||
|
<div class="round-button" onclick="location.href='/mealplanner';"><i class="fa fa-calendar" aria-hidden="true"></i></div>
|
||||||
|
<span><b>Plan new meal</b></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="user-card">
|
||||||
|
{% if current_user.is_authenticated %}
|
||||||
|
<img src="{{url_for('static', filename=current_user.name + '.png')}}">
|
||||||
|
{% endif %}
|
||||||
|
<div class="user-info">
|
||||||
|
{% if current_user.is_authenticated %}
|
||||||
|
<span>{{current_user.name}}</span>
|
||||||
|
<div class="rect-button" onclick="location.href='/logout';" style="background-color: #EE7500;">LOGOUT</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="rect-button" onclick="location.href='/login';" style="background-color: #EE7500;">LOGIN</div>
|
||||||
|
{% endif %}
|
||||||
|
</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>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -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;"> : <input type="text" id="spinner-minute" style="width: 3em;"> -->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Meal planned for {{meal.meal_friendly_date}} - 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;
|
||||||
|
background-attachment: fixed;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="leaderboard">
|
||||||
|
<h1 style="text-align: center">Leaderboard</h1>
|
||||||
|
{% 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 class="right-pane">
|
||||||
|
<h1>When: {{meal.meal_friendly_date}}</h1>
|
||||||
|
<h2>Cook</h2>
|
||||||
|
<div class="flex-card">
|
||||||
|
{% if meal.kuk == "" %}
|
||||||
|
<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>
|
||||||
|
<div class="rect-button" onclick="location.href='/volunteer';" style="background-color: #EE7500;">VOLUNTEER</div>
|
||||||
|
{% else %}
|
||||||
|
<img src="{{url_for('static', filename=meal.kuk + '.png')}}" class="flex-thumb">
|
||||||
|
<span class="username">{{ meal.kuk }}</span>
|
||||||
|
<div class="rect-button" style="background-color: #8faf38; cursor: default;">CONFIRMED</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<h2>Eaters</h2>
|
||||||
|
{% for eater in meal.eaters %}
|
||||||
|
<div class="flex-card">
|
||||||
|
<img src="{{url_for('static', filename=eater + '.png')}}" class="flex-thumb">
|
||||||
|
<span class="username">{{ eater }}</span>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% 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="round-button" onclick="location.href='/addme?meal={{meal.id}}';"><i class="fa fa-plus" aria-hidden="true"></i></div>
|
||||||
|
<span>Add me</span>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="flex-card" style="background: none; box-shadow: none">
|
||||||
|
<div class="round-button" onclick="location.href='/removeme?meal={{meal.id}}';"><i class="fa fa-minus" aria-hidden="true"></i></div>
|
||||||
|
<span>Remove me</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<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>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -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"])
|
||||||
|
|||||||
Reference in New Issue
Block a user