コード例 #1
0
ファイル: newsletter.py プロジェクト: nickburlett/pennyblack
 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
コード例 #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
コード例 #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)
コード例 #4
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)
コード例 #5
0
ファイル: newsletter.py プロジェクト: mick-t/pennyblack
 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
コード例 #6
0
ファイル: newsletter.py プロジェクト: trb116/pythonanalyzer
 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
コード例 #7
0
ファイル: models.py プロジェクト: hgrimelid/feincms
        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()
コード例 #8
0
ファイル: models.py プロジェクト: brianmacdonald/feincms
    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
コード例 #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()
コード例 #10
0
ファイル: models.py プロジェクト: battyone/feincms
    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
コード例 #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)
コード例 #12
0
ファイル: newsletter.py プロジェクト: fiee/pennyblack
def copy_newsletters(modeladmin, request, queryset):
    for newsletter in queryset:
        duplicate = copy_model_instance(newsletter, exclude=('id',))
        duplicate.save()
        duplicate.copy_content_from(newsletter)