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)
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']})
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']})