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)
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)
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)
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)
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()
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)
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)
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)
def view(id): authz.require(authz.logged_in()) card = obj_or_404(Card.by_id(id)) return jsonify(card)
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()
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)
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)
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()