Exemple #1
0
def get_plugin(slug):
    plugin = r.table('plugins').get(slug).run(r_conn())

    if plugin:
        return api_util.jsonify(db.plugins.to_json(plugin))
    else:
        return api_util.api_not_found('No plugin with slug %s' % slug)
Exemple #2
0
def get_plugin(slug):
    plugin = r.table('plugins').get(slug).run(r_conn())

    if plugin:
        return api_util.jsonify(db.plugins.to_json(plugin))
    else:
        return api_util.api_not_found('No plugin with slug %s' % slug)
Exemple #3
0
def update_plugin_tags(slug):
    data = json.loads(flask.request.data)
    plugin = r.table('plugins').get(slug).run(r_conn())

    if not plugin:
        return api_util.api_not_found('No plugin with slug %s' % slug)

    db.plugins.update_tags(plugin, data['tags'])
    return api_util.jsonify({'tags': plugin['tags']})
Exemple #4
0
def update_plugin_tags(slug):
    data = json.loads(flask.request.data)
    plugin = r.table('plugins').get(slug).run(r_conn())

    if not plugin:
        return api_util.api_not_found('No plugin with slug %s' % slug)

    db.plugins.update_tags(plugin, data['tags'])
    return api_util.jsonify({
        'tags': plugin['tags']
    })
Exemple #5
0
def update_plugin_category(slug, category):
    plugin = r.table('plugins').get(slug).run(r_conn())
    if not plugin:
        return api_util.api_not_found('No plugin with slug %s' % slug)

    if not category in [c['id'] for c in get_all_categories_cached()]:
        return api_util.api_bad_request('No such category %s' % category)

    # TODO(david): Also update search index (stale cache)
    plugin['category'] = category
    r.table('plugins').update(plugin).run(r_conn())
    return api_util.jsonify({'category': plugin['category']})
Exemple #6
0
def update_plugin_category(slug, category):
    plugin = r.table('plugins').get(slug).run(r_conn())
    if not plugin:
        return api_util.api_not_found('No plugin with slug %s' % slug)

    if not category in [c['id'] for c in get_all_categories_cached()]:
        return api_util.api_bad_request('No such category %s' % category)

    # TODO(david): Also update search index (stale cache)
    plugin['category'] = category
    r.table('plugins').update(plugin).run(r_conn())
    return api_util.jsonify({
        'category': plugin['category']
    })