Exemple #1
0
def get_answers():
    answer = Answer()
    idq = request.args.get("idq")
    data = []

    res = answer.find_by_idq(idq)
    for item in res:
        a = {}
        idu = item.idu
        user = User()
        username = user.find_by_id(idu).username
        avatar_url = user.find_by_id(idu).avatar_url
        a['id'] = item.id
        a['username'] = username
        a['avatar_url'] = '../assets/avatar/'+avatar_url
        a['content'] = item.content
        a['upvote'] = item.upvote
        a['gmt_create'] = item.gmt_create

        data.append(a)
    return jsonify({'data': data})
Exemple #2
0
    def newupvote(self, ida, idu1, idu2):
        answer = Answer()
        question = Question()
        user = User()

        nickname = user.find_by_id(idu2).nickname

        idq = answer.find_by_id(id=ida).idq

        title = question.find_by_id(id=idq).title

        content = nickname + "点赞了" + "您关于问题" + "'" + title + "'" + "的回答。"
        read = "n"

        notification = Notification(idu=idu1, read=read, content=content)
        dbsession.add(notification)
        dbsession.commit()
        return 1