def configure(request):
    if (not request.user.is_authenticated):
        return HttpResponseRedirect(reverse('account:login'))
    config = None
    configs = TwilioConfig.objects.filter(user=request.user)
    if configs:
        config = TwilioConfig.objects.filter(user=request.user)[0]
    if (request.method == 'POST'):
        sid = request.POST['sid']
        token = request.POST['token']
        configs = TwilioConfig.objects.filter(user=request.user)
        if configs:
            configs.update(sid=sid, token=token)
            config = configs[0]
        else:
            config = TwilioConfig(sid=sid, token=token, user=request.user)
            config.save()
        return updateNumbers(request)
    context = {'config': config}
    return render(request, 'configure.html', context)
def configure(request):
    if (not request.user.is_authenticated):
        return HttpResponseRedirect(reverse('account:login'))
    config = None
    configs = TwilioConfig.objects.filter(user=request.user)
    if configs:
        config = TwilioConfig.objects.filter(user=request.user)[0]
    if (request.method == 'POST'):
        sid = request.POST['sid']
        token = request.POST['token']
        configs = TwilioConfig.objects.filter(user=request.user)
        if configs:
            configs.update(sid=sid, token=token)
            config = configs[0]
        else:
            config = TwilioConfig(sid=sid, token=token, user=request.user)
            config.save()
        return updateNumbers(request)
    context = {'config': config}
    return render(request, 'configure.html', context)