Beispiel #1
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)
Beispiel #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)
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)
Beispiel #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)
Beispiel #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)
Beispiel #6
0
def index():
    authz.require(authz.logged_in())
    cards = db.session.query(Card)
    if 'category' in request.args:
        cards = cards.filter(Card.category == request.args.get('category'))
    
    # TODO: find a better solution
    cards = cards.filter(Card.title != '')
    cards = cards.order_by(Card.created_at.desc())
    
    pager = Pager(cards)
    return jsonify(pager, index=True)
Beispiel #7
0
def index():
    authz.require(authz.logged_in())
    cards = db.session.query(Card)
    if 'category' in request.args:
        cards = cards.filter(Card.category == request.args.get('category'))

    # TODO: find a better solution
    cards = cards.filter(Card.title != '')
    cards = cards.order_by(Card.created_at.desc())

    pager = Pager(cards)
    return jsonify(pager, index=True)
Beispiel #8
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)
Beispiel #9
0
def view(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    return jsonify(card)
Beispiel #10
0
def create():
    authz.require(authz.logged_in())
    card = Card().save(request_data(), g.user)
    db.session.commit()
    extract.delay(card.id)
    return jsonify(card, status=201)
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)
Beispiel #12
0
def view(id):
    authz.require(authz.logged_in())
    card = obj_or_404(Card.by_id(id))
    return jsonify(card)
Beispiel #13
0
def ui():
    if not authz.logged_in():
        return redirect(url_for('login'))
    return render_template("app.html", templates=angular_templates())
Beispiel #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)
Beispiel #15
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)
Beispiel #16
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()
Beispiel #17
0
def search():
    authz.require(authz.logged_in())
    query = cards_query(request.args)
    pager = Pager(search_cards(query))
    return jsonify(pager, index=True)
Beispiel #18
0
def suggest():
    authz.require(authz.logged_in())
    options = Card.suggest(request.args.get('prefix'),
                           categories=request.args.getlist('category'))
    return jsonify({'options': options}, index=True)
Beispiel #19
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()
Beispiel #20
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()
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)
Beispiel #22
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)
Beispiel #23
0
def create():
    authz.require(authz.logged_in())
    card = Card().save(request_data(), g.user)
    db.session.commit()
    extract.delay(card.id)
    return jsonify(card, status=201)
Beispiel #24
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)
Beispiel #25
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()
Beispiel #26
0
def suggest():
    authz.require(authz.logged_in())
    options = Card.suggest(request.args.get("prefix"), categories=request.args.getlist("category"))
    return jsonify({"options": options}, index=True)
Beispiel #27
0
def search():
    authz.require(authz.logged_in())
    query = cards_query(request.args)
    pager = Pager(search_cards(query))
    return jsonify(pager, index=True)
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)
Beispiel #29
0
def categories():
    authz.require(authz.logged_in())
    return jsonify({'categories': Card.CATEGORIES}, index=True)
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()
Beispiel #31
0
def categories():
    authz.require(authz.logged_in())
    return jsonify({'categories': Card.CATEGORIES}, index=True)