예제 #1
0
 def _merge_item(self, original, copy):
     """ Delete original, clean up and publish copy."""
     original_slug = original.slug
     copy.copy_of = None
     copy.save()
     original.delete()
     copy.slug = original.slug
     copy.publish()
     return copy
예제 #2
0
def _build_sample_app(app):
    errors = app.validate_app()
    if not errors:
        comment = _("A sample CommCare application for you to explore")
        copy = app.make_build(comment=comment)
        copy.is_released = True
        copy.save(increment_version=False)
        return copy
    else:
        notify_exception(None, 'Validation errors building sample app', details=errors)
예제 #3
0
파일: event.py 프로젝트: UCF/unify-events
 def copy(self, *args, **kwargs):
     """
     Copies the event instance
     """
     copy = EventInstance(
         start=self.start,
         end=self.end,
         interval=self.interval,
         until=self.until,
         location=self.location,
         *args,
         **kwargs
     )
     copy.save()
     return copy
예제 #4
0
파일: event.py 프로젝트: UCF/unify-events
    def copy(self, state=None, *args, **kwargs):
        """
        Duplicates this Event creating another Event without a calendar set
        (unless in *args/**kwargs), and a link back to the original event created.

        This allows Events to be imported to other calendars and updates can be
        pushed back to the copied events.
        """

        # Ensures that the originating event is always set as the created_from
        created_from = self
        if self.created_from:
            created_from = self.created_from

        # Allow state to be specified to copy as Pending (Main Calendar)
        if state is None:
            state = self.state

        copy = Event(creator=self.creator,
                     created_from=created_from,
                     canceled=self.canceled,
                     state=state,
                     title=self.title,
                     description=self.description,
                     category=self.category,
                     created=self.created,
                     modified=self.modified,
                     contact_name=self.contact_name,
                     contact_email=self.contact_email,
                     contact_phone=self.contact_phone,
                     *args,
                     **kwargs)
        copy.save()
        copy.tags.set(*self.tags.all())
        copy.event_instances.add(*[i.copy(event=copy) for i in self.event_instances.filter(parent=None)])
        return copy