Esempio n. 1
0
    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')
Esempio n. 2
0
    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)
Esempio n. 3
0
def custom_subtopics():
    return Subtopic.all()