Show intl providers separately on providers page

This commit is contained in:
Imdad Ahad
2017-04-25 11:10:59 +01:00
parent eb9214978e
commit 1788f10959
3 changed files with 122 additions and 48 deletions

View File

@@ -16,12 +16,20 @@ from app import provider_client
@user_has_permissions(admin_override=True)
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']
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['supports_international']:
intl_sms_providers.append(provider)
elif provider['notification_type'] == 'email':
domestic_email_providers.append(provider)
return render_template(
'views/providers/providers.html',
email_providers=email_providers,
sms_providers=sms_providers
email_providers=domestic_email_providers,
domestic_sms_providers=domestic_sms_providers,
intl_sms_providers=intl_sms_providers
)

View File

@@ -15,8 +15,8 @@ Providers
<h2 class="heading-medium">SMS</h2>
{% call(item, row_number) list_table(
sms_providers,
caption="SMS providers",
domestic_sms_providers,
caption="Domestic SMS providers",
caption_visible=False,
empty_message='No email providers',
field_headings=['Provider', 'Priority', 'Active', 'Last Updated', 'Updated By'],
@@ -78,6 +78,39 @@ Providers
{% endcall %}
<h1 class="heading-large">International SMS Providers</h1>
{% call(item, row_number) list_table(
intl_sms_providers,
caption="International SMS providers",
caption_visible=False,
empty_message='No email providers',
field_headings=['Provider', 'Priority', 'Active', 'Last Updated', 'Updated By'],
field_headings_visible=True
) %}
{{ link_field(item.display_name, url_for('main.view_provider', provider_id=item.id)) }}
{{ text_field(item.priority) }}
{{ text_field(item.active) }}
{% if item.updated_at %}
{{ text_field(item.updated_at|format_datetime_short) }}
{% else %}
{{ text_field('None') }}
{% endif %}
{% if item.created_by %}
{{ text_field(item.created_by.name) }}
{% else %}
{{ text_field('None') }}
{% endif %}
{{ link_field('change', url_for('main.edit_provider', provider_id=item.id)) }}
{% endcall %}
</div>
</div>