Added Multiple SMS sender functionality

This commit is contained in:
chrisw
2017-10-24 15:37:44 +01:00
parent 8ec50971eb
commit 4e721c95ce
13 changed files with 638 additions and 229 deletions

View File

@@ -80,19 +80,16 @@
{% if 'sms' in current_service.permissions %}
{% call row() %}
{{ text_field('Text message sender') }}
{% if can_receive_inbound %}
{{ text_field(inbound_number) }}
{% else %}
{{ text_field(current_service.sms_sender) }}
{% endif %}
{% if (current_user.has_permissions([], admin_override=True) or not can_receive_inbound) and not can_receive_inbound %}
{{ edit_field('Change', url_for('.service_set_sms_sender', service_id=current_service.id, set_inbound_sms=False)) }}
{% else %}
{{ text_field('') }}
{% endif %}
{% call field(status='default' if default_sms_sender == "None" else '') %}
{{ default_sms_sender | string | nl2br | safe if default_sms_sender else 'None'}}
{% if sms_sender_count > 1 %}
<div class="hint">
{{ '…and %d more' | format(sms_sender_count - 1) }}
</div>
{% endif %}
{% endcall %}
{{ edit_field('Manage' if sms_sender_count else 'Change', url_for('.service_sms_senders', service_id=current_service.id)) }}
{% endcall %}
{% call row() %}
@@ -250,11 +247,7 @@
</li>
{% if 'sms' in current_service.permissions %}
<li class="bottom-gutter">
{% if can_receive_inbound %}
<a href="{{ url_for('.service_set_inbound_number', service_id=current_service.id, set_inbound_sms=False) }}" class="button">
Stop inbound sms
</a>
{% else %}
{% if not can_receive_inbound %}
<a href="{{ url_for('.service_set_inbound_number', service_id=current_service.id, set_inbound_sms=True) }}" class="button">
Allow inbound sms
</a>

View File

@@ -0,0 +1,35 @@
{% extends "withnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/page-footer.html" import page_footer %}
{% from "components/radios.html" import radios%}
{% block service_page_title %}
Set Inbound Number
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Set Inbound Number</h1>
{% if service_has_inbound_number %}
<p> This service already has an inbound number </p>
{{ page_footer(
back_link=url_for('.service_settings', service_id=current_service.id),
back_link_text='Back to settings'
) }}
{% elif no_available_numbers %}
<p> No available inbound numbers </p>
{{ page_footer(
back_link=url_for('.service_settings', service_id=current_service.id),
back_link_text='Back to settings'
) }}
{% else %}
<form method="post">
{{ radios(form.inbound_number) }}
{{ page_footer(
'Save',
back_link=url_for('.service_settings', service_id=current_service.id),
back_link_text='Back'
) }}
</form>
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,31 @@
{% extends "withnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/checkbox.html" import checkbox %}
{% from "components/page-footer.html" import page_footer %}
{% block service_page_title %}
Add text message sender
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">Add text message sender</h1>
<form method="post">
{{ textbox(
form.sms_sender,
width='1-4',
hint='Up to 11 characters, letters, numbers and spaces only'
) }}
{% if not first_sms_sender %}
<div class="form-group">
{{ checkbox(form.is_default) }}
</div>
{% endif %}
{{ page_footer(
'Save',
back_link=url_for('.service_sms_senders', service_id=current_service.id),
back_link_text='Back'
) }}
</form>
{% endblock %}

View File

@@ -0,0 +1,44 @@
{% extends "withnav_template.html" %}
{% from "components/textbox.html" import textbox %}
{% from "components/checkbox.html" import checkbox %}
{% from "components/page-footer.html" import page_footer %}
{% block service_page_title %}
Edit text message sender
{% endblock %}
{% block maincolumn_content %}
<h1 class="heading-large">
Edit text message sender
</h1>
<form method="post">
{% if is_inbound_number %}
<p>
<span class="bottom-gutter-1-3"> {{ form.sms_sender.data }} </span>
<span class="hint"> This phone number receives replies and cant be changed </span>
</p>
{% else %}
{{ textbox(
form.sms_sender,
width='1-4',
hint='Up to 11 characters, letters, numbers and spaces only'
) }}
{% endif %}
{% if form.is_default.data %}
<p class="form-group">
This is currently your text message sender for {{ current_service.name }}
</p>
{% else %}
<div class="form-group">
{{ checkbox(form.is_default) }}
</div>
{% endif %}
{{ page_footer(
'Save',
back_link=None if request.args.get('from_template') else url_for('.service_sms_senders', service_id=current_service.id),
back_link_text='Back'
) }}
</form>
{% endblock %}

View File

@@ -0,0 +1,49 @@
{% extends "withnav_template.html" %}
{% from "components/api-key.html" import api_key %}
{% from "components/page-footer.html" import page_footer %}
{% from "components/table.html" import row_group, row, text_field, edit_field, field, boolean_field, list_table %}
{% block service_page_title %}
Text message senders
{% endblock %}
{% block maincolumn_content %}
<div class="grid-row bottom-gutter">
<div class="column-two-thirds">
<h1 class="heading-large">
Text message senders
</h1>
</div>
<div class="column-one-third">
<a href="{{ url_for('.service_add_sms_sender', service_id=current_service.id) }}" class="button align-with-heading">Add text message sender</a>
</div>
</div>
<div class="user-list">
{% if not sms_senders %}
<div class="user-list-item">
<span class="hint">You havent added any sms senders yet</span>
</div>
{% endif %}
{% for item in sms_senders %}
<div class="user-list-item">
<h3>
<span class="heading-small">{{ item.sms_sender }}</span>
{% if item.hint %}
&ensp;
<span class="hint">
{{ item.hint }}
</span>
{% endif %}
</h3>
<ul class="tick-cross-list">
<li class="tick-cross-list-edit-link">
<a href="{{ url_for('.service_edit_sms_sender', service_id=current_service.id, sms_sender_id = item.id) }}">Change</a>
</li>
</ul>
{% if sms_senders|length > 1 %}
{{ api_key(item.id, thing="ID") }}
{% endif %}
</div>
{% endfor %}
</div>
{% endblock %}