Exemple #1
0
def feed_create():
    """List all examples"""
    form = FeedCreate(request.form)
    if not form.validate():
        return jsonify(status='error', message='The passed arguments failed validation')

    existing_feeds = Feed.for_user_and_url(user=g.user, feed_url=form.data['feed_url'])
    if existing_feeds.count():
        feed = existing_feeds.get()
    else:
        feed = Feed.create_feed_from_form(g.user, form).get_result()

    return jsonify(status='ok', data=feed.to_json())
Exemple #2
0
def feed_create():
    """List all examples"""
    form = FeedCreate(request.form)
    if not form.validate():
        return jsonify(status='error', message='The passed arguments failed validation')

    if Feed.for_user(user=g.user).count():
        return jsonify(status='error', message='This user has already created a feed')

    exsisting_feeds = Feed.for_user_and_url(user=g.user, feed_url=form.data['feed_url'])
    try:
        feed = exsisting_feeds.iter().next()
    except StopIteration:
        feed = Feed.create_feed_from_form(g.user, form)

    return jsonify(status='ok', data=feed.to_json())