예제 #1
0
    def copy(self, uri_prefix, key, parent=None):
        attribute = copy_model(self, uri_prefix=uri_prefix, key=key, parent=parent or self.parent)

        # recursively copy children
        for child in self.children.all():
            child.copy(uri_prefix, child.key, parent=attribute)

        return attribute
예제 #2
0
    def copy(self, uri_prefix, key):
        condition = copy_model(self,
                               uri_prefix=uri_prefix,
                               key=key,
                               source=self.source,
                               target_option=self.target_option)

        return condition
예제 #3
0
    def copy(self, uri_prefix, key, catalog=None):
        section = copy_model(self, uri_prefix=uri_prefix, key=key, catalog=catalog or self.catalog)

        # copy children
        for questionset in self.questionsets.filter(questionset=None):
            questionset.copy(uri_prefix, questionset.key, section=section)

        return section
예제 #4
0
파일: models.py 프로젝트: johlton/rdmo
    def copy(self, uri_prefix, key):
        view = copy_model(self, uri_prefix=uri_prefix, key=key)

        # copy m2m fields
        view.catalogs.set(self.catalogs.all())
        view.sites.set(self.sites.all())
        view.groups.set(self.groups.all())

        return view
예제 #5
0
파일: models.py 프로젝트: sdellachiesa/rdmo
    def copy(self, uri_prefix, key):
        task = copy_model(self, uri_prefix=uri_prefix, key=key, start_attribute=self.start_attribute, end_attribute=self.end_attribute)

        # add m2m fields
        task.catalogs.set(self.catalogs.all())
        task.sites.set(self.sites.all())
        task.groups.set(self.groups.all())
        task.conditions.set(self.conditions.all())

        return task
예제 #6
0
파일: models.py 프로젝트: cbittner/rdmo
    def copy(self, uri_prefix, key):
        optionset = copy_model(self, uri_prefix=uri_prefix, key=key)

        # copy m2m fields
        optionset.conditions.set(self.conditions.all())

        # copy children
        for option in self.options.all():
            option.copy(uri_prefix, option.key, optionset=optionset)

        return optionset
예제 #7
0
파일: models.py 프로젝트: cbittner/rdmo
    def copy(self, uri_prefix, key, questionset=None):
        question = copy_model(self,
                              uri_prefix=uri_prefix,
                              key=key,
                              questionset=questionset or self.questionset,
                              attribute=self.attribute)

        # copy m2m fields
        question.optionsets.set(self.optionsets.all())
        question.conditions.set(self.conditions.all())

        return question
예제 #8
0
    def copy(self, uri_prefix, key, parent=None, rebuild=True):
        assert parent not in self.get_descendants(include_self=True)

        # copy the attribute
        attribute = copy_model(self, uri_prefix=uri_prefix, key=key, parent=parent or self.parent)

        # recursively copy children
        for child in self.children.all():
            child.copy(uri_prefix, child.key, parent=attribute, rebuild=False)

        # rebuild the mptt tree, but only for the initially copied attribute
        if rebuild:
            Attribute.objects.rebuild()

        return attribute
예제 #9
0
파일: models.py 프로젝트: cbittner/rdmo
    def copy(self, uri_prefix, key, section=None):
        questionset = copy_model(self,
                                 uri_prefix=uri_prefix,
                                 key=key,
                                 section=section or self.section,
                                 attribute=self.attribute)

        # copy m2m fields
        questionset.conditions.set(self.conditions.all())

        # copy children
        for question in self.questions.all():
            question.copy(uri_prefix, question.key, questionset=questionset)

        return questionset
예제 #10
0
파일: models.py 프로젝트: cbittner/rdmo
    def copy(self, uri_prefix, key):
        # create a new title
        kwargs = {}
        for field in get_language_fields('title'):
            kwargs[field] = getattr(self, field) + '*'

        # copy instance
        catalog = copy_model(self, uri_prefix=uri_prefix, key=key, **kwargs)

        # copy m2m fields
        catalog.sites.set(self.sites.all())
        catalog.groups.set(self.groups.all())

        # copy children
        for section in self.sections.all():
            section.copy(uri_prefix, section.key, catalog=catalog)

        return catalog
예제 #11
0
    def copy(self, uri_prefix, key, section=None, questionset=False):
        questionset = copy_model(self,
                                 uri_prefix=uri_prefix,
                                 key=key,
                                 section=section or self.section,
                                 questionset=self.questionset
                                 if questionset is False else questionset,
                                 attribute=self.attribute)

        # copy m2m fields
        questionset.conditions.set(self.conditions.all())

        # copy children
        for child_questionset in self.questionsets.all():
            child_questionset.copy(uri_prefix,
                                   child_questionset.key,
                                   section=section,
                                   questionset=questionset)
        for child_question in self.questions.all():
            child_question.copy(uri_prefix,
                                child_question.key,
                                questionset=questionset)

        return questionset
예제 #12
0
파일: models.py 프로젝트: cbittner/rdmo
 def copy(self, uri_prefix, key, optionset=None):
     return copy_model(self,
                       uri_prefix=uri_prefix,
                       key=key,
                       optionset=optionset or self.optionset)