Beispiel #1
0
    def deploy(self):
        """ Deploy Event based on the current EventApplication
            - change status to DEPLOYED
            - creates or copies event
            - add/remove organizers
            - send email about deployment
        """
        if self.status == DEPLOYED:  # we don't want to deploy twice
            return

        self.change_status_to(DEPLOYED)

        previous_event = (Event.objects.filter(
            city=self.city,
            country=self.get_country_display()).order_by("-date").first())

        if previous_event:
            event = copy_event(previous_event, self.date)
        else:
            event = self.create_event()

        # add main organizer of the Event
        main_organizer = event.add_organizer(
            self.main_organizer_email,
            self.main_organizer_first_name,
            self.main_organizer_last_name,
        )
        event.main_organizer = main_organizer
        event.save()

        # add all co-organizers
        for organizer in self.coorganizers.all():
            event.add_organizer(organizer.email, organizer.first_name,
                                organizer.last_name)
        return event
Beispiel #2
0
    def deploy(self):
        """ Deploy Event based on the current EventApplication
            - change status to DEPLOYED
            - creates or copies event
            - add/remove organizers
            - send email about deployment
        """
        if self.status == DEPLOYED:  # we don't want to deploy twice
            return

        self.change_status_to(DEPLOYED)

        event = None
        previous_event = (
            Event.objects
            .filter(city=self.city, country=self.get_country_display())
            .order_by("-date")
            .first()
        )

        if previous_event:
            event = copy_event(previous_event, self.date)
        else:
            event = self.create_event()

        # sort out Gmail accounts
        email, email_password = gmail_accounts.get_or_create_gmail(
            event_application=self,
            event=event
        )

        # add main organizer of the Event
        main_organizer = event.add_organizer(
            self.main_organizer_email,
            self.main_organizer_first_name,
            self.main_organizer_last_name,
        )
        event.main_organizer = main_organizer
        event.save()

        # add all co-organizers
        for organizer in self.coorganizers.all():
            event.add_organizer(
                organizer.email,
                organizer.first_name,
                organizer.last_name
            )

        # TODO: remove organizers, who are no longer in org team if cloned
        send_application_deployed_email(
            event_application=self,
            event=event,
            email_password=email_password
        )
Beispiel #3
0
    def deploy(self):
        """ Deploy Event based on the current EventApplication
            - change status to DEPLOYED
            - creates or copies event
            - add/remove organizers
            - send email about deployment
        """
        if self.status == DEPLOYED:  # we don't want to deploy twice
            return

        self.change_status_to(DEPLOYED)

        event = None
        previous_event = (Event.objects.filter(
            city=self.city,
            country=self.get_country_display()).order_by("-date").first())

        if previous_event:
            event = copy_event(previous_event, self.date)
        else:
            event = self.create_event()

        # sort out Gmail accounts
        email, email_password = gmail_accounts.get_or_create_gmail(
            event_application=self, event=event)

        # add main organizer of the Event
        main_organizer = event.add_organizer(
            self.main_organizer_email,
            self.main_organizer_first_name,
            self.main_organizer_last_name,
        )
        event.main_organizer = main_organizer
        event.save()

        # add all co-organizers
        for organizer in self.coorganizers.all():
            event.add_organizer(organizer.email, organizer.first_name,
                                organizer.last_name)

        # TODO: remove organizers, who are no longer in org team if cloned
        send_application_deployed_email(event_application=self,
                                        event=event,
                                        email_password=email_password)
def test_copy_event(past_event):
    previous_name = past_event.name
    previous_event_id = past_event.pk
    new_date = date(2021, 10, 20)

    new_event = copy_event(past_event, new_date)

    # we need to refetch the event as we changed id of the object
    # inside copy_event method
    past_event = Event.objects.get(pk=previous_event_id)

    assert past_event.name == "{} #1".format(previous_name)
    assert new_event.name == "{} #2".format(previous_name)
    assert past_event.date != new_event.date

    assert past_event.city == new_event.city
    assert past_event.country == new_event.country
    assert past_event.latlng == new_event.latlng
    assert past_event.main_organizer == new_event.main_organizer