Esempio n. 1
0
def editTopic(id):
	data = json.loads(request.data)
	# Save layer data
	c = CatalogModel()
	c.updateTopic(id, data)

	return jsonify({'result': True})
Esempio n. 2
0
def createTopic():
	data = json.loads(request.data)
	# Save topic data
	c = CatalogModel()
	result = c.createTopic(data)

	return jsonify({'id': result['topic_id']})
Esempio n. 3
0
def createLayer():
	data = json.loads(request.data)
	# Save layer data
	c = CatalogModel()
	result = c.createLayer(data)

	return jsonify({'id': result['layer_id']})
Esempio n. 4
0
def getLayer(id):
	c = CatalogModel()
	result = c.getLayerById(id)
	if result is None:
		abort(404)

	return jsonify({'result': result})
Esempio n. 5
0
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})
Esempio n. 6
0
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)
Esempio n. 7
0
def deleteTopic(id):
	c = CatalogModel()
	c.deleteTopic(id)

	return jsonify({'result': 'true'})