Exemplo n.º 1
0
def admin_replies_list():

    offset = request.args.get("offset", 0)
    limit = 50

    # get all users EXCEPT the logged in user
    flags_subq = db.session.query(Flag, func.count("*").label("flag_count")).group_by(Flag.reply_id).subquery()
    replies = db.session.query(Reply, flags_subq.c.flag_count).order_by(flags_subq.c.flag_count.desc())
    items = replies.limit(limit).offset(offset).all()
    items = [i[0].serialize() for i in items]
    for i in items:
        i["body"] = strip_html(i["body"])

    ret = jsonify({"activities": items})

    ret.headers.add("Last-Modified", datetime.now())
    ret.headers.add("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0")
    ret.headers.add("Pragma", "no-cache")

    return ret
Exemplo n.º 2
0
def admin_questions_list(status=None):

    offset = request.args.get("offset", 0)
    limit = 50

    # get all users EXCEPT the logged in user
    curr_status = Status.query.filter_by(name=status).first_or_404()
    query = Question.query.filter_by(status=curr_status)

    items = query.limit(limit).offset(offset).all()
    items = [i.serialize() for i in items]
    for i in items:
        i["question"] = strip_html(i["question"])

    ret = jsonify({"activities": items})

    ret.headers.add("Last-Modified", datetime.now())
    ret.headers.add("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0")
    ret.headers.add("Pragma", "no-cache")

    return ret