add letter_contact_block edit fields

no actual template functionality yet - just the ability for services
that have letters enabled to edit a 10 line block that will go on the
top right hand side of their letters with contact information
This commit is contained in:
Leo Hemsted
2017-03-02 15:56:28 +00:00
committed by Chris Hill-Scott
parent 393cb5b2da
commit 5c3588445e
9 changed files with 189 additions and 11 deletions

View File

@@ -486,10 +486,20 @@ class ServiceSmsSender(Form):
)
def validate_sms_sender(form, field):
if field.data and not re.match('^[a-zA-Z0-9\s]+$', field.data):
if field.data and not re.match(r'^[a-zA-Z0-9\s]+$', field.data):
raise ValidationError('Use letters and numbers only')
class ServiceLetterContactBlock(Form):
letter_contact_block = TextAreaField(
'How should users contact you?'
)
def validate_letter_contact_block(form, field):
if field.data.strip().count('\n') >= 10:
raise ValidationError('Can only have 10 lines')
class ServiceBrandingOrg(Form):
def __init__(self, organisations=[], *args, **kwargs):

View File

@@ -25,6 +25,7 @@ from app.main.forms import (
RequestToGoLiveForm,
ServiceReplyToEmailFrom,
ServiceSmsSender,
ServiceLetterContactBlock,
ServiceBrandingOrg
)
from app import user_api_client, current_service, organisations_client
@@ -236,6 +237,7 @@ def service_set_reply_to_email(service_id):
reply_to_email_address=form.email_address.data
)
return redirect(url_for('.service_settings', service_id=service_id))
return render_template(
'views/service-settings/set-reply-to-email.html',
form=form)
@@ -259,6 +261,27 @@ def service_set_sms_sender(service_id):
form=form)
@main.route("/services/<service_id>/service-settings/set-letter-contact-block", methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_settings', admin_override=True)
def service_set_letter_contact_block(service_id):
if not current_service['can_send_letters']:
abort(403)
form = ServiceLetterContactBlock(letter_contact_block=current_service['letter_contact_block'])
if form.validate_on_submit():
service_api_client.update_service(
current_service['id'],
letter_contact_block=form.letter_contact_block.data.replace('\r', '') or None
)
return redirect(url_for('.service_settings', service_id=service_id))
return render_template(
'views/service-settings/set-letter-contact-block.html',
form=form
)
@main.route("/services/<service_id>/service-settings/set-branding-and-org", methods=['GET', 'POST'])
@login_required
@user_has_permissions(admin_override=True)