def edit_sms_provider_ratio():

    providers = sorted([
        provider
        for provider in provider_client.get_all_providers()['provider_details']
        if provider['notification_type'] == 'sms'
    ], key=itemgetter('identifier'), reverse=True)

    form = ProviderRatioForm(ratio=providers[0]['priority'])

    if len(providers) < 2:
        abort(400)

    primary_provider, secondary_provider = providers[0:2]

    if form.validate_on_submit():
        provider_client.update_provider(primary_provider['id'], form.percentage_left)
        provider_client.update_provider(secondary_provider['id'], form.percentage_right)
        return redirect(url_for('.edit_sms_provider_ratio'))

    return render_template(
        'views/providers/edit-sms-provider-ratio.html',
        versions=_chunk_versions_by_day(_get_versions_since_switchover(primary_provider['id'])),
        form=form,
        primary_provider=providers[0]['display_name'],
        secondary_provider=providers[1]['display_name'],
    )
Esempio n. 2
0
def view_providers():
    providers = provider_client.get_all_providers()['provider_details']
    email_providers = [
        email for email in providers if email['notification_type'] == 'email'
    ]
    sms_providers = [
        sms for sms in providers if sms['notification_type'] == 'sms'
    ]
    return render_template('views/providers.html',
                           email_providers=email_providers,
                           sms_providers=sms_providers)
Esempio n. 3
0
def view_providers():
    providers = provider_client.get_all_providers()['provider_details']
    domestic_email_providers, domestic_sms_providers, intl_sms_providers = [], [], []
    for provider in providers:
        if provider['notification_type'] == 'sms':
            domestic_sms_providers.append(provider)
            if provider.get('supports_international', None):
                intl_sms_providers.append(provider)
        elif provider['notification_type'] == 'email':
            domestic_email_providers.append(provider)

    return render_template('views/providers/providers.html',
                           email_providers=domestic_email_providers,
                           domestic_sms_providers=domestic_sms_providers,
                           intl_sms_providers=intl_sms_providers)
Esempio n. 4
0
def view_providers():
    providers = provider_client.get_all_providers()["provider_details"]
    domestic_email_providers, domestic_sms_providers, intl_sms_providers = [], [], []
    for provider in providers:
        if provider["notification_type"] == "sms":
            domestic_sms_providers.append(provider)
            if provider.get("supports_international", None):
                intl_sms_providers.append(provider)
        elif provider["notification_type"] == "email":
            domestic_email_providers.append(provider)

    add_monthly_traffic(domestic_sms_providers)

    return render_template(
        "views/providers/providers.html",
        email_providers=domestic_email_providers,
        domestic_sms_providers=domestic_sms_providers,
        intl_sms_providers=intl_sms_providers,
    )
Esempio n. 5
0
def view_providers():
    providers = provider_client.get_all_providers()['provider_details']
    email_providers = [email for email in providers if email['notification_type'] == 'email']
    sms_providers = [sms for sms in providers if sms['notification_type'] == 'sms']
    return render_template('views/providers.html', email_providers=email_providers, sms_providers=sms_providers)