Esempio n. 1
0
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)
Esempio n. 2
0
def detail(id):
    m = Topic.get(id)
    u = current_user()
    c = 'n'  # 未收藏
    if Collect.one(topic_id=m.id, user_id=u.id) is not None:
        c = 'c'
    return render_template("topic/detail.html", topic=m, u=u, c=c)
Esempio n. 3
0
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))
Esempio n. 4
0
def detail_like(id):
    m = Topic.get(id)
    u = current_user()
    l = Collect.one(topic_id=m.id, user_id=u.id)
    return render_template("topic/like.html", topic=m, user=u, l=l)