added login cookie, added change pwd screen
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, request
|
||||
from flask import Blueprint, render_template, redirect, url_for, request, make_response
|
||||
from flask_login import login_required, current_user
|
||||
from models import db
|
||||
from models import Item
|
||||
from sqlalchemy import desc, text
|
||||
import os
|
||||
from log import Log
|
||||
from auth import create_cookie
|
||||
|
||||
items_bp = Blueprint("items", __name__)
|
||||
|
||||
@@ -14,12 +15,14 @@ ICONPATH = "static/categories/" #without starting / and with ending /
|
||||
@items_bp.route("/items/<listid>")
|
||||
@login_required
|
||||
def items(listid):
|
||||
return render_template("items_show.html", user=current_user,
|
||||
resp = make_response(render_template("items_show.html", user=current_user,
|
||||
items=Item.query.filter_by(listofitems_id=listid, is_suggestion=False).order_by(text("is_checked, category, label")).all(),
|
||||
button_top_url1 = url_for("items.items_append", listid=listid),
|
||||
button_top_txt1 = "add",
|
||||
button_top_url2 = url_for("items.items_clean", listid=listid),
|
||||
button_top_txt2 = "clean")
|
||||
button_top_txt2 = "clean"))
|
||||
resp.set_cookie('username', create_cookie(current_user.id))
|
||||
return resp
|
||||
|
||||
# webservice for updating checked state of one item
|
||||
@items_bp.route("/item_update/<itemid>/<itemchecked>")
|
||||
@@ -124,12 +127,14 @@ def items_append(listid):
|
||||
if not i.startswith('.'):
|
||||
icon_names.append(os.path.splitext(i)[0])
|
||||
|
||||
return render_template("items_append.html", user=current_user,
|
||||
resp = make_response(render_template("items_append.html", user=current_user,
|
||||
listid=listid,
|
||||
items=Item.query.filter_by(listofitems_id=listid).order_by(Item.label).all(),
|
||||
icons = icon_names,
|
||||
iconpath = '/'+ICONPATH,
|
||||
logo_url=url_for("items.items", listid=listid))
|
||||
logo_url=url_for("items.items", listid=listid)))
|
||||
resp.set_cookie('username', create_cookie(current_user.id))
|
||||
return resp
|
||||
|
||||
# user adds items to list
|
||||
@items_bp.route("/items_multiappend/<listid>", methods=["GET", "POST"])
|
||||
@@ -188,9 +193,12 @@ def item_addone(itemid):
|
||||
if not i.unit:
|
||||
i.unit = 'x'
|
||||
db.session.commit()
|
||||
return render_template("items_append.html", user=current_user,
|
||||
|
||||
resp = make_response(render_template("items_append.html", user=current_user,
|
||||
items=Item.query.filter_by(listofitems_id=listid).order_by(Item.label).all(),
|
||||
logo_url=url_for("items.items", listid=listid))
|
||||
logo_url=url_for("items.items", listid=listid)))
|
||||
resp.set_cookie('username', create_cookie(current_user.id))
|
||||
return resp
|
||||
|
||||
# webservice for adding one item with a quantity/unit
|
||||
@items_bp.route("/item_addquantity/<itemid>/<quantity>")
|
||||
@@ -206,9 +214,12 @@ def item_addquantity(itemid, quantity):
|
||||
else:
|
||||
i.quantity += int(quantity)
|
||||
db.session.commit()
|
||||
return render_template("items_append.html", user=current_user,
|
||||
|
||||
resp = make_response(render_template("items_append.html", user=current_user,
|
||||
items=Item.query.filter_by(listofitems_id=listid).order_by(Item.label).all(),
|
||||
logo_url=url_for("items.items", listid=listid))
|
||||
logo_url=url_for("items.items", listid=listid)))
|
||||
resp.set_cookie('username', create_cookie(current_user.id))
|
||||
return resp
|
||||
|
||||
# webservice for updating category of one item
|
||||
@items_bp.route("/item_update_category/<itemid>/<category>")
|
||||
|
||||
Reference in New Issue
Block a user