def destroy(self): context = {'user': t.c.user} params = t.request.params subtopic_id = t.request.params['id'] subtopic = Subtopic.find(subtopic_id) old_name = subtopic['name'] Subtopic.destroy(context, subtopic_id) # Update indexes of following subtopics destroyed_index = subtopic['index'] for subtopic in Subtopic.all(): if subtopic['index'] > destroyed_index: new_subtopic_index = AlphabeticIndex.previous_letter( subtopic['index']) Subtopic.update_subtopic_index(subtopic, new_subtopic_index) reindex_packages_with_changed_topic(old_name) t.redirect_to( controller='ckanext.topics.controllers.topic:TopicController', action='index')
def index(self): topics = Topic.all() subtopics = Subtopic.all() for topic in topics: topic['subtopics'] = [] for subtopic in subtopics: if (topic['id'] == subtopic['topic_id']): topic['subtopics'].append(subtopic) extra_vars = {'topics': topics} return t.render('topic/index.html', extra_vars=extra_vars)
def custom_subtopics(): return Subtopic.all()