def get_template_sender_form_dict(service_id, template): context = { 'email': { 'field_name': 'email_address' }, 'letter': { 'field_name': 'contact_block' }, 'sms': { 'field_name': 'sms_sender' } }[template['template_type']] sender_format = context['field_name'] service_senders = get_sender_details(service_id, template['template_type']) context['default_sender'] = next( (x['id'] for x in service_senders if x['is_default']), "Not set") if not service_senders: context['no_senders'] = True context['value_and_label'] = [(sender['id'], nl2br(sender[sender_format])) for sender in service_senders] context['value_and_label'].insert( 0, ('', 'Blank')) # Add blank option to start of list context['current_choice'] = template['service_letter_contact'] if template[ 'service_letter_contact'] else '' return context
def get_template_sender_form_dict(service_id, template): context = { "email": { "field_name": "email_address" }, "letter": { "field_name": "contact_block" }, "sms": { "field_name": "sms_sender" }, }[template["template_type"]] sender_format = context["field_name"] service_senders = get_sender_details(service_id, template["template_type"]) context["default_sender"] = next( (x["id"] for x in service_senders if x["is_default"]), "Not set") if not service_senders: context["no_senders"] = True context["value_and_label"] = [(sender["id"], Markup(nl2br(sender[sender_format]))) for sender in service_senders] context["value_and_label"].insert( 0, ("", "Blank")) # Add blank option to start of list context["current_choice"] = template["service_letter_contact"] if template[ "service_letter_contact"] else "" return context