Пример #1
0
def check_input():
    r = Response()
    
    if request.form['Digits'] == config.master_pin:
        r.verbs.extend(grant_access())
    else:
        try:
            contact = models.Contact.objects.get(pin=request.form['Digits'])
        except models.Contact.DoesNotExist:
            contact = None
        
        if not contact or contact.blacklisted:
            r.say('Invalid pin code. Goodbye.')
        else:
            r.verbs.extend(grant_access(contact))
    
    return r
Пример #2
0
def answer_call():
    r = Response()
    
    if request.form['From'] != config.intercom:
        r.reject(reason='rejected')
    
    if not config.auth:
        r.verbs.extend(grant_access())
    else:
        with r.gather(action=url_for('.check_input'), numDigits=4, timeout=4) as g:
            g.say('Please enter a pin or hold.')
        
        try:
            contact = models.Contact.objects.get(pk=config.forward)
            r.dial(contact.phone_number)
        except models.Contact.DoesNotExist:
            pass
        
        r.say('Goodbye.')
    
    return r