def update_email_branding(branding_id, logo=None): email_branding = email_branding_client.get_email_branding( branding_id)["email_branding"] form = ServiceUpdateEmailBranding( name=email_branding["name"], text=email_branding["text"], colour=email_branding["colour"], brand_type=email_branding["brand_type"], ) logo = logo if logo else email_branding.get( "logo") if email_branding else None if form.validate_on_submit(): if form.file.data: upload_filename = upload_email_logo( form.file.data.filename, form.file.data, current_app.config["AWS_REGION"], user_id=session["user_id"], ) if logo and logo.startswith( TEMP_TAG.format(user_id=session["user_id"])): delete_email_temp_file(logo) return redirect( url_for( ".update_email_branding", branding_id=branding_id, logo=upload_filename, )) updated_logo_name = permanent_email_logo_name( logo, session["user_id"]) if logo else None email_branding_client.update_email_branding( branding_id=branding_id, logo=updated_logo_name, name=form.name.data, text=form.text.data, colour=form.colour.data, brand_type=form.brand_type.data, ) if logo: persist_logo(logo, updated_logo_name) delete_email_temp_files_created_by(session["user_id"]) return redirect(url_for(".email_branding", branding_id=branding_id)) return render_template( "views/email-branding/manage-branding.html", form=form, email_branding=email_branding, cdn_url=get_logo_cdn_domain(), logo=logo, )
def service_settings(service_id): letter_branding_organisations = email_branding_client.get_letter_email_branding( ) organisation = organisations_client.get_service_organisation( service_id).get('name', None) if current_service['email_branding']: email_branding = email_branding_client.get_email_branding( current_service['email_branding'])['email_branding'] else: email_branding = None inbound_number = inbound_number_client.get_inbound_sms_number_for_service( service_id) disp_inbound_number = inbound_number['data'].get('number', '') reply_to_email_addresses = service_api_client.get_reply_to_email_addresses( service_id) reply_to_email_address_count = len(reply_to_email_addresses) default_reply_to_email_address = next( (x['email_address'] for x in reply_to_email_addresses if x['is_default']), "Not set") letter_contact_details = service_api_client.get_letter_contacts(service_id) letter_contact_details_count = len(letter_contact_details) default_letter_contact_block = next( (Field(x['contact_block'], html='escape') for x in letter_contact_details if x['is_default']), "Not set") sms_senders = service_api_client.get_sms_senders(service_id) sms_sender_count = len(sms_senders) default_sms_sender = next((Field(x['sms_sender'], html='escape') for x in sms_senders if x['is_default']), "None") free_sms_fragment_limit = billing_api_client.get_free_sms_fragment_limit_for_year( service_id) data_retention = service_api_client.get_service_data_retention(service_id) return render_template( 'views/service-settings.html', email_branding=email_branding, letter_branding=letter_branding_organisations.get( current_service.get('dvla_organisation', '001')), can_receive_inbound=('inbound_sms' in current_service['permissions']), inbound_number=disp_inbound_number, default_reply_to_email_address=default_reply_to_email_address, reply_to_email_address_count=reply_to_email_address_count, default_letter_contact_block=default_letter_contact_block, letter_contact_details_count=letter_contact_details_count, default_sms_sender=default_sms_sender, sms_sender_count=sms_sender_count, free_sms_fragment_limit=free_sms_fragment_limit, prefix_sms=current_service['prefix_sms'], organisation=organisation, data_retention=data_retention, )
def update_email_branding(branding_id, logo=None): email_branding = email_branding_client.get_email_branding(branding_id)['email_branding'] form = ServiceUpdateEmailBranding() logo = logo if logo else email_branding.get('logo') if email_branding else None if form.validate_on_submit(): if form.file.data: upload_filename = upload_logo( form.file.data.filename, form.file.data, current_app.config['AWS_REGION'], user_id=session["user_id"] ) if logo and logo.startswith(TEMP_TAG.format(user_id=session['user_id'])): delete_temp_file(logo) return redirect(url_for('.update_email_branding', branding_id=branding_id, logo=upload_filename)) if logo: logo = persist_logo(logo, session["user_id"]) delete_temp_files_created_by(session["user_id"]) email_branding_client.update_email_branding( branding_id=branding_id, logo=logo, name=form.name.data, text=form.text.data, colour=form.colour.data ) return redirect(url_for('.email_branding', branding_id=branding_id)) form.name.data = email_branding['name'] form.text.data = email_branding['text'] form.colour.data = email_branding['colour'] return render_template( 'views/email-branding/manage-branding.html', form=form, email_branding=email_branding, cdn_url=get_cdn_domain(), logo=logo )
def organisation_settings(org_id): email_branding = 'GOV.UK' if current_organisation.email_branding_id: email_branding = email_branding_client.get_email_branding( current_organisation.email_branding_id)['email_branding']['name'] letter_branding = None if current_organisation.letter_branding_id: letter_branding = letter_branding_client.get_letter_branding( current_organisation.letter_branding_id)['name'] return render_template( 'views/organisations/organisation/settings/index.html', email_branding=email_branding, letter_branding=letter_branding, )
def organisation_settings(org_id): email_branding = ('French Government of Canada signature' if current_organisation.default_branding_is_french is True else 'English Government of Canada signature') if current_organisation.email_branding_id: email_branding = email_branding_client.get_email_branding( current_organisation.email_branding_id )['email_branding']['name'] letter_branding = None if current_organisation.letter_branding_id: letter_branding = letter_branding_client.get_letter_branding( current_organisation.letter_branding_id )['name'] return render_template( 'views/organisations/organisation/settings/index.html', email_branding=email_branding, letter_branding=letter_branding, )
def organisation_settings(org_id): email_branding = ( "French Government of Canada signature" if current_organisation.default_branding_is_french is True else "English Government of Canada signature" ) if current_organisation.email_branding_id: email_branding = email_branding_client.get_email_branding(current_organisation.email_branding_id)["email_branding"][ "name" ] letter_branding = None if current_organisation.letter_branding_id: letter_branding = letter_branding_client.get_letter_branding(current_organisation.letter_branding_id)["name"] return render_template( "views/organisations/organisation/settings/index.html", email_branding=email_branding, letter_branding=letter_branding, )
def email_template(): branding_type = 'govuk' branding_style = request.args.get('branding_style', None) if branding_style == FieldWithNoneOption.NONE_OPTION_VALUE: branding_style = None if branding_style is not None: email_branding = email_branding_client.get_email_branding( branding_style)['email_branding'] branding_type = email_branding['brand_type'] if branding_type == 'govuk': brand_text = None brand_colour = None brand_logo = None govuk_banner = True brand_banner = False brand_name = None else: colour = email_branding['colour'] brand_text = email_branding['text'] brand_colour = colour brand_logo = ('https://{}/{}'.format(get_logo_cdn_domain(), email_branding['logo']) if email_branding['logo'] else None) govuk_banner = branding_type in ['govuk', 'both'] brand_banner = branding_type == 'org_banner' brand_name = email_branding['name'] template = { 'template_type': 'email', 'subject': 'foo', 'content': ('Lorem Ipsum is simply dummy text of the printing and typesetting ' 'industry.\n\nLorem Ipsum has been the industry’s standard dummy ' 'text ever since the 1500s, when an unknown printer took a galley ' 'of type and scrambled it to make a type specimen book. ' '\n\n' '# History' '\n\n' 'It has ' 'survived not only' '\n\n' '* five centuries' '\n' '* but also the leap into electronic typesetting' '\n\n' 'It was ' 'popularised in the 1960s with the release of Letraset sheets ' 'containing Lorem Ipsum passages, and more recently with desktop ' 'publishing software like Aldus PageMaker including versions of ' 'Lorem Ipsum.' '\n\n' '^ It is a long established fact that a reader will be distracted ' 'by the readable content of a page when looking at its layout.' '\n\n' 'The point of using Lorem Ipsum is that it has a more-or-less ' 'normal distribution of letters, as opposed to using ‘Content ' 'here, content here’, making it look like readable English.' '\n\n\n' '1. One' '\n' '2. Two' '\n' '10. Three' '\n\n' 'This is an example of an email sent using GOV.UK Notify.' '\n\n' 'https://www.notifications.service.gov.uk') } if not bool(request.args): resp = make_response(str(HTMLEmailTemplate(template))) else: resp = make_response( str( HTMLEmailTemplate( template, govuk_banner=govuk_banner, brand_text=brand_text, brand_colour=brand_colour, brand_logo=brand_logo, brand_banner=brand_banner, brand_name=brand_name, ))) resp.headers['X-Frame-Options'] = 'SAMEORIGIN' return resp
def email_template(): branding_type = "fip_english" branding_style = request.args.get("branding_style", None) if ( branding_style == FieldWithLanguageOptions.ENGLISH_OPTION_VALUE or branding_style == FieldWithLanguageOptions.FRENCH_OPTION_VALUE ): if branding_style == FieldWithLanguageOptions.FRENCH_OPTION_VALUE: branding_type = "fip_french" branding_style = None if branding_style is not None: email_branding = email_branding_client.get_email_branding(branding_style)["email_branding"] branding_type = email_branding["brand_type"] if branding_type == "fip_english": brand_text = None brand_colour = None brand_logo = None fip_banner_english = True fip_banner_french = False logo_with_background_colour = False brand_name = None elif branding_type == "fip_french": brand_text = None brand_colour = None brand_logo = None fip_banner_english = False fip_banner_french = True logo_with_background_colour = False brand_name = None else: colour = email_branding["colour"] brand_text = email_branding["text"] brand_colour = colour brand_logo = "https://{}/{}".format(get_logo_cdn_domain(), email_branding["logo"]) if email_branding["logo"] else None fip_banner_english = branding_type in ["fip_english", "both_english"] fip_banner_french = branding_type in ["fip_french", "both_french"] logo_with_background_colour = branding_type == "custom_logo_with_background_colour" brand_name = email_branding["name"] template = { "subject": "foo", "content": ( "Lorem Ipsum is simply dummy text of the printing and typesetting " "industry.\n\nLorem Ipsum has been the industry’s standard dummy " "text ever since the 1500s, when an unknown printer took a galley " "of type and scrambled it to make a type specimen book. " "\n\n" "# History" "\n\n" "It has " "survived not only" "\n\n" "* five centuries" "\n" "* but also the leap into electronic typesetting" "\n\n" "It was " "popularised in the 1960s with the release of Letraset sheets " "containing Lorem Ipsum passages, and more recently with desktop " "publishing software like Aldus PageMaker including versions of " "Lorem Ipsum." "\n\n" "^ It is a long established fact that a reader will be distracted " "by the readable content of a page when looking at its layout." "\n\n" "The point of using Lorem Ipsum is that it has a more-or-less " "normal distribution of letters, as opposed to using ‘Content " "here, content here’, making it look like readable English." "\n\n\n" "1. One" "\n" "2. Two" "\n" "10. Three" "\n\n" "This is an example of an email sent using Notification." "\n\n" "https://www.notifications.service.gov.uk" ), } if not bool(request.args): resp = make_response(str(HTMLEmailTemplate(template))) else: resp = make_response( str( HTMLEmailTemplate( template, fip_banner_english=fip_banner_english, fip_banner_french=fip_banner_french, brand_text=brand_text, brand_colour=brand_colour, brand_logo=brand_logo, logo_with_background_colour=logo_with_background_colour, brand_name=brand_name, ) ) ) resp.headers["X-Frame-Options"] = "SAMEORIGIN" return resp