def update_app_categories_handler(request, conf, current_user):
toshi_id = request.form.get('toshi_id')
categories = request.form.get('categories', "")
if toshi_id is not None:
tags = [s.strip() for s in categories.split(",")]
async with conf.db.id.acquire() as con:
categories = await con.fetch("SELECT * FROM categories WHERE tag = ANY($1)", tags)
categories = [row['category_id'] for row in categories]
async with con.transaction():
await con.execute("DELETE FROM app_categories WHERE toshi_id = $1", toshi_id)
await con.executemany(
"INSERT INTO app_categories VALUES ($1, $2) ON CONFLICT DO NOTHING",
[(category_id, toshi_id) for category_id in categories])
if 'Referer' in request.headers:
return redirect(request.headers['Referer'])
return redirect("/{}/user/{}".format(conf.name, toshi_id))
return redirect("/{}/apps".format(conf.name))
评论列表
文章目录