예제 #1
0
    def _merge_item(self, original, copy):
        """ Delete original, clean up and publish copy."""
        children = set(
            list(original.children.all()) + list(copy.children.all()))
        # Remove the postfix from the title, if it hasn't already been changed.
        if copy.title.endswith(DRAFT_POSTFIX):
            copy.title = copy.title[:-1 * len(DRAFT_POSTFIX)]

        # Copy values from copy to original, excepting any AutoField instances
        # and the slug field.
        for field in copy._meta.fields:
            if not issubclass(AutoField, field.__class__) and field.name not \
                in ['slug', 'status']:
                field_name = field.name
                setattr(original, field_name, getattr(copy, field_name))

        copy.delete()
        original.copy_of = None
        original.save()

        # Ensure that all children in both the original and the copy are made
        # children of the original.
        for child in children:
            child.move_to(original, position='last-child')

        return copy
예제 #2
0
    def _merge_item(self, original, copy):
        """ Delete original, clean up and publish copy."""
        children = set(list(original.children.all()) + list(copy.children.all()))
        # Remove the postfix from the title, if it hasn't already been changed.
        if copy.title.endswith(DRAFT_POSTFIX):
            copy.title = copy.title[:-1 * len(DRAFT_POSTFIX)]

        # Copy values from copy to original, excepting any AutoField instances
        # and the slug field.
        for field in copy._meta.fields:
            if not issubclass(AutoField, field.__class__) and field.name not \
                in ['slug', 'status']:
                field_name = field.name
                setattr(original, field_name, getattr(copy, field_name))

        copy.delete()
        original.copy_of = None
        original.save()

        # Ensure that all children in both the original and the copy are made
        # children of the original.
        for child in children:
            child.move_to(original, position='last-child')

        return copy
예제 #3
0
파일: event.py 프로젝트: UCF/unify-events
 def delete(self, *args, **kwargs):
     """
     Delete all the event subscriptions.
     """
     for copy in self.duplicated_to.all():
         copy.delete()
     super(Event, self).delete(*args, **kwargs)