Ejemplo n.º 1
0
def get_plugin(slug):
    plugin = r.table('plugins').get(slug).run(r_conn())

    if plugin:
        return json.dumps(db.plugins.to_json(plugin))
    else:
        return util.api_not_found('No plugin with slug %s' % slug)
Ejemplo n.º 2
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 util.api_not_found('No plugin with slug %s' % slug)

    db.plugins.update_tags(plugin, data['tags'])
    return json.dumps({'tags': plugin['tags']})
Ejemplo n.º 3
0
def update_plugin_category(slug, category):
    plugin = r.table('plugins').get(slug).run(r_conn())
    if not plugin:
        return util.api_not_found('No plugin with slug %s' % slug)

    if not category in [c['id'] for c in get_all_categories_cached()]:
        return 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 json.dumps({'category': plugin['category']})