Пример #1
0
def run_data_migration(apps, schema_editor):
    Section = apps.get_model('questions', 'Section')
    Subsection = apps.get_model('questions', 'Subsection')
    QuestionSet = apps.get_model('questions', 'QuestionSet')
    Question = apps.get_model('questions', 'Question')

    for questionset in QuestionSet.objects.all():
        questionset.section = questionset.subsection.section
        questionset.title_en = questionset.subsection.title_en
        questionset.title_de = questionset.subsection.title_de
        questionset.order = questionset.order + 10 * questionset.subsection.order

        questionset.key = questionset.subsection.key + '-' + questionset.key
        questionset.path = '%s/%s/%s' % (questionset.section.catalog.key,
                                         questionset.section.key,
                                         questionset.key)
        questionset.uri = get_uri_prefix(
            questionset) + '/questions/' + questionset.path
        questionset.save()

        for question in questionset.questions.all():
            question.path = '%s/%s/%s/%s' % (
                question.questionset.section.catalog.key,
                question.questionset.section.key, question.questionset.key,
                question.key)
            question.uri = get_uri_prefix(
                question) + '/questions/' + question.path
            question.save()
Пример #2
0
    def save(self, *args, **kwargs):
        self.path = Question.build_path(self.key, self.questionset)
        self.uri = get_uri_prefix(self) + '/questions/' + self.path

        super(Question, self).save(*args, **kwargs)

        # invalidate the cache so that changes appear instantly
        caches['api'].clear()
Пример #3
0
    def save(self, *args, **kwargs):
        self.path = Section.build_path(self.key, self.catalog)
        self.uri = get_uri_prefix(self) + '/questions/' + self.path

        super(Section, self).save(*args, **kwargs)

        for questionsets in self.questionsets.all():
            questionsets.save()
Пример #4
0
    def save(self, *args, **kwargs):
        self.path = Attribute.build_path(self.key, self.parent)
        self.uri = get_uri_prefix(self) + '/domain/' + self.path

        super(Attribute, self).save(*args, **kwargs)

        # recursively save children
        for child in self.children.all():
            child.save()
Пример #5
0
    def save(self, *args, **kwargs):
        self.path = AttributeEntity.build_path(self.key, self.parent)
        self.uri = get_uri_prefix(self) + '/domain/' + self.path
        self.is_attribute = self.is_attribute or False

        # loop over parents to find parent collection
        self.parent_collection = None
        parent = self.parent
        while parent:
            # set parent_collection if it is not yet set and if parent is a collection
            if not self.parent_collection and parent.is_collection:
                self.parent_collection = parent
                break

            parent = parent.parent

        super(AttributeEntity, self).save(*args, **kwargs)

        # recursively save children
        for child in self.children.all():
            child.save()
Пример #6
0
    def save(self, *args, **kwargs):
        self.uri = get_uri_prefix(self) + '/questions/%s' % self.key
        super(Catalog, self).save(*args, **kwargs)

        for section in self.sections.all():
            section.save()
Пример #7
0
 def build_uri(self):
     return get_uri_prefix(self) + '/views/' + self.key
Пример #8
0
 def build_uri(self):
     return get_uri_prefix(self) + '/conditions/' + self.key
Пример #9
0
    def save(self, *args, **kwargs):
        self.uri = get_uri_prefix(self) + '/options/' + self.label
        super(OptionSet, self).save(*args, **kwargs)

        for option in self.options.all():
            option.save()
Пример #10
0
    def save(self, *args, **kwargs):
        self.path = Option.build_path(self.key, self.optionset)
        self.uri = get_uri_prefix(self) + '/options/' + self.path

        super(Option, self).save(*args, **kwargs)