def show_add(resource_id): rep = DI.get_repository() resource = rep.read_resource(resource_id) tags = rep.read_tags(resource['network_id'], resource['lang_id'], resource['type_id']) return render_template('add.html', nav='submit', resource=resource, tags_id=tags[0]['id'])
def show_langs(network_id): rep = DI.get_repository() langs = rep.read_langs(network_id) network = rep.get_network_name_by_id(network_id) return render_template('list/langs.html', title='Main', nav='tags', langs=langs, network_id=network_id, network=network)
def show_networks(): rep = DI.get_repository() blk = DI.get_blockchain() upd = Updater(rep, blk) upd.check() networks = rep.read_networks() return render_template('list/networks.html', title='Main', nav='tags', networks=networks)
def show_types(network_id, lang_id): rep = DI.get_repository() types = rep.read_types(network_id, lang_id) network = rep.get_network_name_by_id(network_id) lang = rep.get_lang_name_by_id(lang_id) return render_template('list/types.html', title='Main', nav='tags', types=types, network_id=network_id, lang_id=lang_id, network=network, lang=lang)
def search(): rep = DI.get_repository() blk = DI.get_blockchain() upd = Updater(rep, blk) upd.check() resources = [] if request.form['type'] == 'url': resources = rep.search_resources_by_url(request.form['search']) elif request.form['type'] == 'description': resources = rep.search_resources_by_description(request.form['search']) # print(resources) return render_template('list/search.html', nav='search', title='Search', search=request.form['search'], type=request.form['type'], resources=resources)
def show_resources(network_id, lang_id, type_id, tags_id): rep = DI.get_repository() resources = rep.read_resources(network_id, lang_id, type_id, tags_id) network = rep.get_network_name_by_id(network_id) lang = rep.get_lang_name_by_id(lang_id) type = rep.get_type_name_by_id(type_id) tag = rep.get_tag_name_by_id(tags_id) return render_template('list/resources.html', title='Main', nav='tags', resources=resources, network_id=network_id, lang_id=lang_id, type_id=type_id, tags_id=tags_id, network=network, lang=lang, type=type, tag=tag)
def show_resource(network_id, lang_id, type_id, tags_id, resource_id): rep = DI.get_repository() network = rep.get_network_name_by_id(network_id) lang = rep.get_lang_name_by_id(lang_id) type = rep.get_type_name_by_id(type_id) tag = rep.get_tag_name_by_id(tags_id) tags = rep.read_tags(network_id, lang_id, type_id) resource = rep.read_resource(resource_id) descriptions = rep.read_descriptions(resource_id) return render_template('list/resource.html', title='Main', nav='tags', network_id=network_id, lang_id=lang_id, type_id=type_id, tags_id=tags_id, resource_id=resource_id, network=network, lang=lang, type=type, tag=tag, tags=tags, resource=resource, descriptions=descriptions)
def sync(): rep = DI.get_repository() blk = DI.get_blockchain() upd = Updater(rep, blk) upd.sync() return 'ok'