def set_template_sender(service_id, template_id): template = current_service.get_template_with_user_permission_or_403( template_id, current_user) sender_details = get_template_sender_form_dict(service_id, template) no_senders = sender_details.get('no_senders', False) form = SetTemplateSenderForm( sender=sender_details['current_choice'], sender_choices=sender_details['value_and_label'], ) form.sender.param_extensions = {'items': []} for item_value, _item_label in sender_details['value_and_label']: if item_value == sender_details['default_sender']: extensions = {'hint': {'text': '(Default)'}} else: extensions = { } # if no extensions needed, send an empty dict to preserve order of items form.sender.param_extensions['items'].append(extensions) if form.validate_on_submit(): service_api_client.update_service_template_sender( service_id, template_id, form.sender.data if form.sender.data else None, ) return redirect( url_for('.view_template', service_id=service_id, template_id=template_id)) return render_template('views/templates/set-template-sender.html', form=form, template_id=template_id, no_senders=no_senders)
def set_template_sender(service_id, template_id): template = current_service.get_template_with_user_permission_or_403( template_id, current_user) sender_details = get_template_sender_form_dict(service_id, template) no_senders = sender_details.get('no_senders', False) form = SetTemplateSenderForm( sender=sender_details['current_choice'], sender_choices=sender_details['value_and_label'], ) option_hints = {sender_details['default_sender']: '(Default)'} if form.validate_on_submit(): service_api_client.update_service_template_sender( service_id, template_id, form.sender.data if form.sender.data else None, ) return redirect( url_for('.view_template', service_id=service_id, template_id=template_id)) return render_template('views/templates/set-template-sender.html', form=form, template_id=template_id, no_senders=no_senders, option_hints=option_hints)
def set_template_sender(service_id, template_id): template = current_service.get_template_with_user_permission_or_403( template_id, current_user) sender_details = get_template_sender_form_dict(service_id, template) no_senders = sender_details.get("no_senders", False) form = SetTemplateSenderForm( sender=sender_details["current_choice"], sender_choices=sender_details["value_and_label"], ) option_hints = {sender_details["default_sender"]: "(Default)"} if form.validate_on_submit(): service_api_client.update_service_template_sender( service_id, template_id, form.sender.data if form.sender.data else None, ) return redirect( url_for(".view_template", service_id=service_id, template_id=template_id)) return render_template( "views/templates/set-template-sender.html", form=form, template_id=template_id, no_senders=no_senders, option_hints=option_hints, )