示例#1
0
    def get(self, request, client_call, pks):
        pks = pks.split(",")
        try:
            shelter = Shelter.objects.get(pk=pks[0])
        except Shelter.DoesNotExist:
            pks = ",".join(pks[1:])
            if pks:
                return redirect(reverse("phone:start_shelter_call", kwargs={"pks": pks, "client_call": client_call}))

        site = Site.objects.get_current()
        client.calls.create(
            to=shelter.phone_number,
            from_=settings.TWILIO_CALLER_ID,
            url=urljoin(
                "http://" + site.domain,
                reverse("phone:verify_shelter_availability", kwargs={"client_call": client_call, "pk": pks[0]}),
            ),
            method="GET",
            status_callback="http://%s/phone/shelter_call_callback/%s/%s/"
            % (site.domain, client_call, ",".join(pks[1:])),
            status_method="GET",
        )

        r = Response()
        r.say("We are contacting %s. Please hold." % shelter.name)
        r.enqueue(name="waiting_for_shelter", wait_url="http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
        return r
示例#2
0
    def setUp(self):
        r = Response()
        r.enqueue("TestEnqueueAttribute", action="act", method='GET',
                  waitUrl='wait', waitUrlMethod='POST')
        xml = r.toxml()

        #parse twiml XML string with Element Tree and inspect
        #structure
        tree = ET.fromstring(xml)
        self.conf = tree.find("./Enqueue")
示例#3
0
    def get(self, request, client_call, pks):
        pks = pks.split(',')
        try:
            shelter = Shelter.objects.get(pk=pks[0])
        except Shelter.DoesNotExist:
            pks = ','.join(pks[1:])
            if pks:
                return redirect(reverse(
                    'phone:start_shelter_call',
                    kwargs={
                        'pks': pks,
                        'client_call': client_call
                    }
                ))

        site = Site.objects.get_current()
        client.calls.create(
            to=shelter.phone_number,
            from_=settings.TWILIO_CALLER_ID,
            url=urljoin(
                'http://' + site.domain,
                reverse(
                    'phone:verify_shelter_availability',
                    kwargs={
                        'client_call': client_call,
                        'pk': pks[0]
                    }
                )
            ),
            method='GET',
            status_callback='http://%s/phone/shelter_call_callback/%s/%s/' % (
                site.domain,
                client_call, ','.join(pks[1:])
            ),
            status_method='GET',
        )

        r = Response()
        r.say('We are contacting %s. Please hold.' % shelter.name)
        r.enqueue(
            name='waiting_for_shelter',
            wait_url='http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'
        )
        return r
    def setUp(self):
        r = Response()
        with r.enqueue(None, workflowSid="Workflow1") as e:
            e.task('{"selected_language":"en"}', priority="10", timeout="50")

        xml = r.toxml()

        # parse twiml XML string with Element Tree and inspect
        # structure
        tree = ET.fromstring(xml)
        self.enqueue = tree.find("./Enqueue")
        self.task = self.enqueue.find(".//Task")
示例#5
0
    def setUp(self):
        r = Response()
        with r.enqueue(None, workflowSid="Workflow1") as e:
            e.task('{"selected_language":"en"}', priority="10", timeout="50")

        xml = r.toxml()

        # parse twiml XML string with Element Tree and inspect
        # structure
        tree = ET.fromstring(xml)
        self.enqueue = tree.find("./Enqueue")
        self.task = self.enqueue.find(".//Task")