Example #1
0
    def save(self):
        user = self.context["user"]
        contacts = self.validated_data["contacts"]
        action = self.validated_data["action"]
        group = self.validated_data.get("group")

        if action == self.ADD:
            group.update_contacts(user, contacts, add=True)
        elif action == self.REMOVE:
            group.update_contacts(user, contacts, add=False)
        elif action == self.INTERRUPT:
            mailroom.queue_interrupt(self.context["org"], contacts=contacts)
        elif action == self.ARCHIVE:
            Msg.archive_all_for_contacts(contacts)
        else:
            for contact in contacts:
                if action == self.BLOCK:
                    contact.block(user)
                elif action == self.UNBLOCK:
                    contact.unblock(user)
                elif action == self.DELETE:
                    contact.release(user)
Example #2
0
    def save(self):
        user = self.context['user']
        contacts = self.validated_data['contacts']
        action = self.validated_data['action']
        group = self.validated_data.get('group')

        if action == self.ADD:
            group.update_contacts(user, contacts, add=True)
        elif action == self.REMOVE:
            group.update_contacts(user, contacts, add=False)
        elif action == self.INTERRUPT:
            FlowRun.exit_all_for_contacts(contacts, FlowRun.EXIT_TYPE_INTERRUPTED)
        elif action == self.ARCHIVE:
            Msg.archive_all_for_contacts(contacts)
        else:
            for contact in contacts:
                if action == self.BLOCK:
                    contact.block(user)
                elif action == self.UNBLOCK:
                    contact.unblock(user)
                elif action == self.DELETE:
                    contact.release(user)
Example #3
0
    def save(self):
        user = self.context['user']
        contacts = self.validated_data['contacts']
        action = self.validated_data['action']
        group = self.validated_data.get('group')

        if action == self.ADD:
            group.update_contacts(user, contacts, add=True)
        elif action == self.REMOVE:
            group.update_contacts(user, contacts, add=False)
        elif action == self.INTERRUPT:
            FlowRun.exit_all_for_contacts(contacts, FlowRun.EXIT_TYPE_INTERRUPTED)
        elif action == self.ARCHIVE:
            Msg.archive_all_for_contacts(contacts)
        else:
            for contact in contacts:
                if action == self.BLOCK:
                    contact.block(user)
                elif action == self.UNBLOCK:
                    contact.unblock(user)
                elif action == self.DELETE:
                    contact.release(user)