def collect_delete(id): m = Topic.get(id) u = current_user() collect_item = Collect.one(topic_id=m.id, user_id=u.id) Collect.delete(collect_item.id) c = 'n' return render_template("topic/detail.html", topic=m, u=u, c=c)
def add_like(): id = int(request.args.get('id')) u = current_user() t = Topic.one(id=id) user = User.one(id=t.user_id) form = {'topic_id': t.id, 'num': 1} l = Collect.one(topic_id=t.id, user_id=u.id) if l is None: Collect.new(form, u.id) send_like(u, user, id, '') else: Collect.delete(l.id) return redirect(url_for('.detail_like', id=t.id))