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
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
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 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
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()
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
def copy_newsletters(modeladmin, request, queryset): for newsletter in queryset: duplicate = copy_model_instance(newsletter, exclude=('id', )) duplicate.save() duplicate.copy_content_from(newsletter)
def copy_newsletters(modeladmin, request, queryset): for newsletter in queryset: duplicate = copy_model_instance(newsletter, exclude=('id',)) duplicate.save() duplicate.copy_content_from(newsletter)