def service_add_letter_contact(service_id): form = ServiceLetterContactBlockForm() first_contact_block = current_service.count_letter_contact_details == 0 from_template = request.args.get('from_template') if form.validate_on_submit(): new_letter_contact = service_api_client.add_letter_contact( current_service.id, contact_block=form.letter_contact_block.data.replace('\r', '') or None, is_default=first_contact_block if first_contact_block else form.is_default.data) if from_template: service_api_client.update_service_template_sender( service_id, from_template, new_letter_contact['data']['id'], ) return redirect( url_for('.view_template', service_id=service_id, template_id=from_template)) return redirect( url_for('.service_letter_contact_details', service_id=service_id)) return render_template( 'views/service-settings/letter-contact/add.html', form=form, first_contact_block=first_contact_block, back_link=(url_for('main.view_template', template_id=from_template, service_id=current_service.id) if from_template else url_for('.service_letter_contact_details', service_id=current_service.id)), )
def service_add_letter_contact(service_id): form = ServiceLetterContactBlockForm() letter_contact_blocks_count = len( service_api_client.get_letter_contacts(service_id)) first_contact_block = letter_contact_blocks_count == 0 if form.validate_on_submit(): service_api_client.add_letter_contact( current_service['id'], contact_block=form.letter_contact_block.data.replace('\r', '') or None, is_default=first_contact_block if first_contact_block else form.is_default.data) return redirect( url_for('.service_letter_contact_details', service_id=service_id)) return render_template('views/service-settings/letter-contact/add.html', form=form, first_contact_block=first_contact_block)
def service_add_letter_contact(service_id): form = ServiceLetterContactBlockForm() first_contact_block = current_service.count_letter_contact_details == 0 if form.validate_on_submit(): service_api_client.add_letter_contact( current_service.id, contact_block=form.letter_contact_block.data.replace('\r', '') or None, is_default=first_contact_block if first_contact_block else form.is_default.data) if request.args.get('from_template'): return redirect( url_for('.set_template_sender', service_id=service_id, template_id=request.args.get('from_template'))) return redirect( url_for('.service_letter_contact_details', service_id=service_id)) return render_template( 'views/service-settings/letter-contact/add.html', form=form, first_contact_block=first_contact_block, )