Exemple #1
0
 def create_snapshot(self):
     """
     Makes a copy of itselve with all the content and returns the copy.
     """
     snapshot = copy_model_instance(self, exclude=('id',))
     snapshot.active = False
     snapshot.save()
     snapshot.copy_content_from(self)
     for attachment in self.attachments.all():
         attachment_copy = copy_model_instance(attachment, exclude=('id', 'newsletter'))
         attachment_copy.newsletter = snapshot
         attachment_copy.save()
     return snapshot
Exemple #2
0
 def create_snapshot(self):
     """
     Makes a copy of itselve with all the content and returns the copy.
     """
     snapshot = copy_model_instance(self, exclude=('id', ))
     snapshot.active = False
     snapshot.save()
     snapshot.copy_content_from(self)
     for attachment in self.attachments.all():
         attachment_copy = copy_model_instance(attachment,
                                               exclude=('id', 'newsletter'))
         attachment_copy.newsletter = snapshot
         attachment_copy.save()
     return snapshot
Exemple #3
0
    def handle(self, request, data):

        root_page = Page.objects.get(pk=data['page_id'])

        new_page = copy_model_instance(root_page, exclude=('id', 'parent'))

        if data.get("depth", 0):
            Page.copy_content_from(root_page)
    def handle(self, request, data):

        root_page = Page.objects.get(pk=data['page_id'])

        new_page = copy_model_instance(root_page,
                                       exclude=('id', 'parent'))

        if data.get("depth", 0):
            Page.copy_content_from(root_page)
Exemple #5
0
 def create_snapshot(self):
     """
     Makes a copy of itselve with all the content and returns the copy.
     """
     snapshot = copy_model_instance(self, exclude=('id',))
     snapshot.active = False
     snapshot.save()
     snapshot.copy_content_from(self)
     return snapshot
Exemple #6
0
 def create_snapshot(self):
     """
     Makes a copy of itselve with all the content and returns the copy.
     """
     snapshot = copy_model_instance(self, exclude=('id',))
     snapshot.active = False
     snapshot.save()
     snapshot.copy_content_from(self)
     return snapshot
Exemple #7
0
        def copy_content_from(self, obj):
            """
            Copy all content blocks over to another CMS base object. (Must be of the
            same type, but this is not enforced. It will crash if you try to copy content
            from another CMS base type.)
            """

            for cls in self._feincms_content_types:
                for content in cls.objects.filter(parent=obj):
                    new = copy_model_instance(content, exclude=('id', 'parent'))
                    new.parent = self
                    new.save()
Exemple #8
0
    def create_copy(self, page):
        """
        Creates an identical copy of a page except that the new one is
        inactive.
        """

        new = copy_model_instance(page, exclude=self.exclude_from_copy)
        new.active = False
        new.save()
        new.copy_content_from(page)

        return new
Exemple #9
0
        def copy_content_from(self, obj):
            """
            Copy all content blocks over to another CMS base object. (Must be of the
            same type, but this is not enforced. It will crash if you try to copy content
            from another CMS base type.)
            """

            for cls in self._feincms_content_types:
                for content in cls.objects.filter(parent=obj):
                    new = copy_model_instance(content, exclude=('id', 'parent'))
                    new.parent = self
                    new.save()
Exemple #10
0
    def create_copy(self, page):
        """
        Creates an identical copy of a page except that the new one is
        inactive.
        """

        new = copy_model_instance(page, exclude=self.exclude_from_copy)
        new.active = False
        new.save()
        new.copy_content_from(page)

        return new
Exemple #11
0
def copy_newsletters(modeladmin, request, queryset):
    for newsletter in queryset:
        duplicate = copy_model_instance(newsletter, exclude=('id', ))
        duplicate.save()
        duplicate.copy_content_from(newsletter)
Exemple #12
0
def copy_newsletters(modeladmin, request, queryset):
    for newsletter in queryset:
        duplicate = copy_model_instance(newsletter, exclude=('id',))
        duplicate.save()
        duplicate.copy_content_from(newsletter)