Exemplo n.º 1
0
        def post_save(self, obj):

            # fire our trigger schedule if necessary
            if obj.schedule.is_expired():
                from temba.schedules.tasks import check_schedule_task
                check_schedule_task.delay(obj.schedule.pk)

            return obj
Exemplo n.º 2
0
        def post_save(self, obj):

            # fire our trigger schedule if necessary
            if obj.schedule.is_expired():
                from temba.schedules.tasks import check_schedule_task
                check_schedule_task.delay(obj.schedule.pk)

            return obj
Exemplo n.º 3
0
        def form_valid(self, form):
            trigger = self.object
            trigger_type = trigger.trigger_type

            if trigger_type == Trigger.TYPE_SCHEDULE:
                schedule = trigger.schedule

                if form.starts_never():
                    schedule.reset()

                elif form.stopped():
                    schedule.reset()

                elif form.starts_now():
                    schedule.next_fire = timezone.now() - timedelta(days=1)
                    schedule.repeat_period = "O"
                    schedule.repeat_days = 0
                    schedule.status = "S"
                    schedule.save()

                else:
                    # Scheduled case
                    schedule.status = "S"
                    schedule.repeat_period = form.cleaned_data["repeat_period"]
                    start_time = form.get_start_time()
                    if start_time:
                        schedule.next_fire = start_time

                    # create our recurrence
                    if form.is_recurring():
                        days = None
                        if "repeat_days" in form.cleaned_data:
                            days = form.cleaned_data["repeat_days"]
                        schedule.repeat_days = days
                        schedule.repeat_hour_of_day = schedule.next_fire.hour
                        schedule.repeat_minute_of_hour = schedule.next_fire.minute
                        schedule.repeat_day_of_month = schedule.next_fire.day
                    schedule.save()

                recipients = self.form.cleaned_data["omnibox"]

                trigger.groups.clear()
                trigger.contacts.clear()

                for group in recipients["groups"]:
                    trigger.groups.add(group)

                for contact in recipients["contacts"]:
                    trigger.contacts.add(contact)

                # fire our trigger schedule if necessary
                if trigger.schedule.is_expired():
                    from temba.schedules.tasks import check_schedule_task

                    on_transaction_commit(
                        lambda: check_schedule_task.delay(trigger.schedule.pk))

            response = super().form_valid(form)
            response["REDIRECT"] = self.get_success_url()
            return response
Exemplo n.º 4
0
        def form_valid(self, form):
            trigger = self.object
            trigger_type = trigger.trigger_type

            if trigger_type == Trigger.TYPE_SCHEDULE:
                schedule = trigger.schedule

                if form.starts_never():
                    schedule.reset()

                elif form.stopped():
                    schedule.reset()

                elif form.starts_now():
                    schedule.next_fire = timezone.now() - timedelta(days=1)
                    schedule.repeat_period = "O"
                    schedule.repeat_days = 0
                    schedule.status = "S"
                    schedule.save()

                else:
                    # Scheduled case
                    schedule.status = "S"
                    schedule.repeat_period = form.cleaned_data["repeat_period"]
                    start_time = form.get_start_time()
                    if start_time:
                        schedule.next_fire = start_time

                    # create our recurrence
                    if form.is_recurring():
                        days = None
                        if "repeat_days" in form.cleaned_data:
                            days = form.cleaned_data["repeat_days"]
                        schedule.repeat_days = days
                        schedule.repeat_hour_of_day = schedule.next_fire.hour
                        schedule.repeat_minute_of_hour = schedule.next_fire.minute
                        schedule.repeat_day_of_month = schedule.next_fire.day
                    schedule.save()

                recipients = self.form.cleaned_data["omnibox"]

                trigger.groups.clear()
                trigger.contacts.clear()

                for group in recipients["groups"]:
                    trigger.groups.add(group)

                for contact in recipients["contacts"]:
                    trigger.contacts.add(contact)

                # fire our trigger schedule if necessary
                if trigger.schedule.is_expired():
                    from temba.schedules.tasks import check_schedule_task

                    on_transaction_commit(lambda: check_schedule_task.delay(trigger.schedule.pk))

            response = super().form_valid(form)
            response["REDIRECT"] = self.get_success_url()
            return response
Exemplo n.º 5
0
        def post_save(self, obj):

            # fire our trigger schedule if necessary
            if obj.schedule.is_expired():
                from temba.schedules.tasks import check_schedule_task
                on_transaction_commit(lambda: check_schedule_task.delay(obj.schedule.pk))

            return obj
Exemplo n.º 6
0
        def post_save(self, obj):

            # fire our trigger schedule if necessary
            if obj.schedule.is_expired():
                from temba.schedules.tasks import check_schedule_task

                on_transaction_commit(lambda: check_schedule_task.delay(obj.schedule.pk))

            return obj
Exemplo n.º 7
0
        def form_valid(self, form):
            trigger = self.object
            trigger_type = trigger.trigger_type

            if trigger_type == Trigger.TYPE_MISSED_CALL or trigger_type == Trigger.TYPE_CATCH_ALL:
                trigger.flow = form.cleaned_data['flow']
                trigger.save()

            if trigger_type == Trigger.TYPE_SCHEDULE:
                schedule = trigger.schedule

                if form.starts_never():
                    schedule.reset()

                elif form.stopped():
                    schedule.reset()

                elif form.starts_now():
                    schedule.next_fire = timezone.now() - timedelta(days=1)
                    schedule.repeat_period = 'O'
                    schedule.repeat_days = 0
                    schedule.status = 'S'
                    schedule.save()

                else:
                    # Scheduled case
                    schedule.status = 'S'
                    schedule.repeat_period = form.cleaned_data['repeat_period']
                    start_time = form.get_start_time()
                    if start_time:
                        schedule.next_fire = start_time

                    # create our recurrence
                    if form.is_recurring():
                        days = None
                        if 'repeat_days' in form.cleaned_data:
                            days = form.cleaned_data['repeat_days']
                        schedule.repeat_days = days
                        schedule.repeat_hour_of_day = schedule.next_fire.hour
                        schedule.repeat_minute_of_hour = schedule.next_fire.minute
                        schedule.repeat_day_of_month = schedule.next_fire.day
                    schedule.save()

                recipients = self.form.cleaned_data['omnibox']

                trigger.groups.clear()
                trigger.contacts.clear()

                for group in recipients['groups']:
                    trigger.groups.add(group)

                for contact in recipients['contacts']:
                    trigger.contacts.add(contact)

                # fire our trigger schedule if necessary
                if trigger.schedule.is_expired():
                    from temba.schedules.tasks import check_schedule_task
                    check_schedule_task.delay(trigger.schedule.pk)

            response = super(TriggerCRUDL.Update, self).form_valid(form)
            response['REDIRECT'] = self.get_success_url()
            return response
Exemplo n.º 8
0
        def form_valid(self, form):
            trigger = self.object
            trigger_type = trigger.trigger_type

            if trigger_type == Trigger.TYPE_MISSED_CALL or trigger_type == Trigger.TYPE_CATCH_ALL:
                trigger.flow = form.cleaned_data['flow']
                trigger.save()

            if trigger_type == Trigger.TYPE_SCHEDULE:
                schedule = trigger.schedule

                if form.starts_never():
                    schedule.reset()

                elif form.stopped():
                    schedule.reset()

                elif form.starts_now():
                    schedule.next_fire = timezone.now() - timedelta(days=1)
                    schedule.repeat_period = 'O'
                    schedule.repeat_days = 0
                    schedule.status = 'S'
                    schedule.save()

                else:
                    # Scheduled case
                    schedule.status = 'S'
                    schedule.repeat_period = form.cleaned_data['repeat_period']
                    start_time = form.get_start_time()
                    if start_time:
                        schedule.next_fire = start_time

                    # create our recurrence
                    if form.is_recurring():
                        days = None
                        if 'repeat_days' in form.cleaned_data:
                            days = form.cleaned_data['repeat_days']
                        schedule.repeat_days = days
                        schedule.repeat_hour_of_day = schedule.next_fire.hour
                        schedule.repeat_minute_of_hour = schedule.next_fire.minute
                        schedule.repeat_day_of_month = schedule.next_fire.day
                    schedule.save()

                recipients = self.form.cleaned_data['omnibox']

                trigger.groups.clear()
                trigger.contacts.clear()

                for group in recipients['groups']:
                    trigger.groups.add(group)

                for contact in recipients['contacts']:
                    trigger.contacts.add(contact)

                # fire our trigger schedule if necessary
                if trigger.schedule.is_expired():
                    from temba.schedules.tasks import check_schedule_task
                    check_schedule_task.delay(trigger.schedule.pk)

            response = super(TriggerCRUDL.Update, self).form_valid(form)
            response['REDIRECT'] = self.get_success_url()
            return response