示例#1
0
def index(card_id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(card_id))
    references = db.session.query(Reference)
    references = references.filter(Reference.card == card)
    pager = Pager(references, card_id=card_id)
    return jsonify(pager, index=True)
示例#2
0
def update(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    card.save(request_data(), g.user)
    db.session.commit()
    extract.delay(card.id)
    return jsonify(card)
示例#3
0
def update(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    card.save(request_data(), g.user)
    db.session.commit()
    extract.delay(card.id)
    return jsonify(card)
示例#4
0
def index(parent_id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(parent_id))
    links = db.session.query(Link)
    links = links.filter(Link.parent == card)
    links = links.order_by(Link.offset.asc())
    pager = Pager(links, parent_id=parent_id)
    return jsonify(pager, index=True)
示例#5
0
def index(parent_id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(parent_id))
    links = db.session.query(Link)
    links = links.filter(Link.parent == card)
    links = links.order_by(Link.offset.asc())
    pager = Pager(links, parent_id=parent_id)
    return jsonify(pager, index=True)
示例#6
0
def refresh(parent_id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(parent_id))
    link = aliased(Link)
    links = db.session.query(link.id)
    links = links.filter(link.parent == card)
    response = {'status': 'ok'}

    try:
        since = request.args.get('since')
        if since is not None:
            since = dateutil.parser.parse(since)

            child = aliased(Card)
            links = links.join(child, link.child)
            links = links.filter(or_(link.updated_at > since,
                                     child.updated_at > since))
    except (AttributeError, ValueError), e:
        response['status'] = 'ok'
        response['error'] = unicode(e)
示例#7
0
def delete(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    db.session.delete(link)
    db.session.commit()
    raise Gone()
示例#8
0
def update(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    link.save(request_data(), link.parent, g.user)
    db.session.commit()
    return jsonify(link)
示例#9
0
def view(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    return jsonify(link)
示例#10
0
def update(card_id, id):
    authz.require(authz.logged_in())
    reference = obj_or_404(Reference.by_id(id, card_id=card_id))
    reference.save(request_data(), reference.card, g.user)
    db.session.commit()
    return jsonify(reference)
示例#11
0
def view(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    return jsonify(card)
示例#12
0
def delete(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    db.session.delete(link)
    db.session.commit()
    raise Gone()
示例#13
0
def update(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    link.save(request_data(), link.parent, g.user)
    db.session.commit()
    return jsonify(link)
示例#14
0
def view(parent_id, id):
    authz.require(authz.logged_in())
    link = obj_or_404(Link.by_id(id, parent_id=parent_id))
    return jsonify(link)
示例#15
0
def delete(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    db.session.delete(card)
    db.session.commit()
    raise Gone()
示例#16
0
def create(card_id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(card_id))
    reference = Reference().save(request_data(), card, g.user)
    db.session.commit()
    return jsonify(reference, status=201)
示例#17
0
def view(card_id, id):
    authz.require(authz.logged_in())
    reference = obj_or_404(Reference.by_id(id, card_id=card_id))
    return jsonify(reference)
示例#18
0
def delete(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    db.session.delete(card)
    db.session.commit()
    raise Gone()
示例#19
0
def delete(card_id, id):
    authz.require(authz.logged_in())
    reference = obj_or_404(Reference.by_id(id, card_id=card_id))
    db.session.delete(reference)
    db.session.commit()
    raise Gone()
示例#20
0
def view(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    return jsonify(card)