def editTopic(id): data = json.loads(request.data) # Save layer data c = CatalogModel() c.updateTopic(id, data) return jsonify({'result': True})
def createTopic(): data = json.loads(request.data) # Save topic data c = CatalogModel() result = c.createTopic(data) return jsonify({'id': result['topic_id']})
def createLayer(): data = json.loads(request.data) # Save layer data c = CatalogModel() result = c.createLayer(data) return jsonify({'id': result['layer_id']})
def getLayer(id): c = CatalogModel() result = c.getLayerById(id) if result is None: abort(404) return jsonify({'result': result})
def getSection(id): c = CatalogModel() result = {} topic = c.getTopicById(id) result = topic children = c.getTopicChildren(id) result['children'] = children['children'] if result is None: abort(404) return jsonify({'result': result})
def getFullCatalog(): catalog = [] c = CatalogModel() categories = c.getCategories() for category in categories: category['topics'] = [] topics = c.getTopicsByCategory(category['id']) for topic in topics: layers = c.getLayersByTopic(topic['id']) topic['layers'] = layers category['topics'].append(topic) catalog.append(category) result = {'result': catalog} return jsonify(result)
def deleteTopic(id): c = CatalogModel() c.deleteTopic(id) return jsonify({'result': 'true'})