mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 16:24:08 -04:00
remove email branding
This commit is contained in:
@@ -18,7 +18,6 @@ from notifications_utils.clients.zendesk.zendesk_client import NotifySupportTick
|
||||
from app import (
|
||||
billing_api_client,
|
||||
current_service,
|
||||
email_branding_client,
|
||||
inbound_number_client,
|
||||
notification_api_client,
|
||||
organizations_client,
|
||||
@@ -35,16 +34,13 @@ from app.main import main
|
||||
from app.main.forms import (
|
||||
AdminBillingDetailsForm,
|
||||
AdminNotesForm,
|
||||
AdminPreviewBrandingForm,
|
||||
AdminServiceAddDataRetentionForm,
|
||||
AdminServiceEditDataRetentionForm,
|
||||
AdminServiceInboundNumberForm,
|
||||
AdminServiceMessageLimitForm,
|
||||
AdminServiceRateLimitForm,
|
||||
AdminServiceSMSAllowanceForm,
|
||||
AdminSetEmailBrandingForm,
|
||||
AdminSetOrganizationForm,
|
||||
ChooseEmailBrandingForm,
|
||||
EstimateUsageForm,
|
||||
RenameServiceForm,
|
||||
SearchByNameForm,
|
||||
@@ -55,10 +51,8 @@ from app.main.forms import (
|
||||
ServiceSmsSenderForm,
|
||||
ServiceSwitchChannelForm,
|
||||
SMSPrefixForm,
|
||||
SomethingElseBrandingForm,
|
||||
)
|
||||
from app.utils import DELIVERED_STATUSES, FAILURE_STATUSES, SENDING_STATUSES
|
||||
from app.utils.branding import get_email_choices as get_email_branding_choices
|
||||
from app.utils.time import parse_naive_dt
|
||||
from app.utils.user import (
|
||||
user_has_permissions,
|
||||
@@ -87,7 +81,6 @@ def service_settings(service_id):
|
||||
return render_template(
|
||||
"views/service-settings.html",
|
||||
service_permissions=PLATFORM_ADMIN_SERVICE_PERMISSIONS,
|
||||
email_branding_options=ChooseEmailBrandingForm(current_service),
|
||||
)
|
||||
|
||||
|
||||
@@ -876,57 +869,6 @@ def set_rate_limit(service_id):
|
||||
)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/set-email-branding",
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
@user_is_platform_admin
|
||||
def service_set_email_branding(service_id):
|
||||
email_branding = email_branding_client.get_all_email_branding()
|
||||
|
||||
form = AdminSetEmailBrandingForm(
|
||||
all_branding_options=get_branding_as_value_and_label(email_branding),
|
||||
current_branding=current_service.email_branding_id,
|
||||
)
|
||||
|
||||
if form.validate_on_submit():
|
||||
return redirect(
|
||||
url_for(
|
||||
".service_preview_email_branding",
|
||||
service_id=service_id,
|
||||
branding_style=form.branding_style.data,
|
||||
)
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"views/service-settings/set-email-branding.html",
|
||||
form=form,
|
||||
search_form=SearchByNameForm(),
|
||||
)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/preview-email-branding",
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
@user_is_platform_admin
|
||||
def service_preview_email_branding(service_id):
|
||||
branding_style = request.args.get("branding_style", None)
|
||||
|
||||
form = AdminPreviewBrandingForm(branding_style=branding_style)
|
||||
|
||||
if form.validate_on_submit():
|
||||
current_service.update(email_branding=form.branding_style.data)
|
||||
return redirect(url_for(".service_settings", service_id=service_id))
|
||||
|
||||
return render_template(
|
||||
"views/service-settings/preview-email-branding.html",
|
||||
form=form,
|
||||
service_id=service_id,
|
||||
action=url_for("main.service_preview_email_branding", service_id=service_id),
|
||||
)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/link-service-to-organization",
|
||||
methods=["GET", "POST"],
|
||||
@@ -957,145 +899,6 @@ def link_service_to_organization(service_id):
|
||||
)
|
||||
|
||||
|
||||
def create_email_branding_zendesk_ticket(form_option_selected, detail=None):
|
||||
form = ChooseEmailBrandingForm(current_service)
|
||||
|
||||
ticket_message = render_template(
|
||||
"support-tickets/branding-request.txt",
|
||||
current_branding=current_service.email_branding_name,
|
||||
branding_requested=dict(form.options.choices)[form_option_selected],
|
||||
detail=detail,
|
||||
)
|
||||
ticket = NotifySupportTicket(
|
||||
subject=f"Email branding request - {current_service.name}",
|
||||
message=ticket_message,
|
||||
ticket_type=NotifySupportTicket.TYPE_QUESTION,
|
||||
user_name=current_user.name,
|
||||
user_email=current_user.email_address,
|
||||
org_id=current_service.organization_id,
|
||||
org_type=current_service.organization_type,
|
||||
service_id=current_service.id,
|
||||
)
|
||||
zendesk_client.send_ticket_to_zendesk(ticket)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/email-branding",
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
@user_has_permissions("manage_service")
|
||||
def email_branding_request(service_id):
|
||||
form = ChooseEmailBrandingForm(current_service)
|
||||
branding_name = current_service.email_branding_name
|
||||
if form.validate_on_submit():
|
||||
return redirect(
|
||||
url_for(
|
||||
f".email_branding_{form.options.data}",
|
||||
service_id=current_service.id,
|
||||
)
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"views/service-settings/branding/email-branding-options.html",
|
||||
form=form,
|
||||
branding_name=branding_name,
|
||||
)
|
||||
|
||||
|
||||
def check_email_branding_allowed_for_service(branding):
|
||||
allowed_branding_for_service = dict(get_email_branding_choices(current_service))
|
||||
|
||||
if branding not in allowed_branding_for_service:
|
||||
abort(404)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/email-branding/govuk",
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
@user_has_permissions("manage_service")
|
||||
def email_branding_govuk(service_id):
|
||||
check_email_branding_allowed_for_service("govuk")
|
||||
|
||||
if request.method == "POST":
|
||||
current_service.update(email_branding=None)
|
||||
|
||||
flash("You’ve updated your email branding", "default")
|
||||
return redirect(url_for(".service_settings", service_id=current_service.id))
|
||||
|
||||
return render_template("views/service-settings/branding/email-branding-govuk.html")
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/email-branding/govuk-and-org",
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
@user_has_permissions("manage_service")
|
||||
def email_branding_govuk_and_org(service_id):
|
||||
check_email_branding_allowed_for_service("govuk_and_org")
|
||||
|
||||
if request.method == "POST":
|
||||
create_email_branding_zendesk_ticket("govuk_and_org")
|
||||
|
||||
flash(
|
||||
"Thanks for your branding request. We’ll get back to you within one working day.",
|
||||
"default",
|
||||
)
|
||||
return redirect(url_for(".service_settings", service_id=current_service.id))
|
||||
|
||||
return render_template(
|
||||
"views/service-settings/branding/email-branding-govuk-org.html"
|
||||
)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/email-branding/organization",
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
@user_has_permissions("manage_service")
|
||||
def email_branding_organization(service_id):
|
||||
check_email_branding_allowed_for_service("organization")
|
||||
|
||||
if request.method == "POST":
|
||||
create_email_branding_zendesk_ticket("organization")
|
||||
|
||||
flash(
|
||||
"Thanks for your branding request. We’ll get back to you within one working day.",
|
||||
"default",
|
||||
)
|
||||
return redirect(url_for(".service_settings", service_id=current_service.id))
|
||||
|
||||
return render_template(
|
||||
"views/service-settings/branding/email-branding-organization.html"
|
||||
)
|
||||
|
||||
|
||||
@main.route(
|
||||
"/services/<uuid:service_id>/service-settings/email-branding/something-else",
|
||||
methods=["GET", "POST"],
|
||||
)
|
||||
@user_has_permissions("manage_service")
|
||||
def email_branding_something_else(service_id):
|
||||
form = SomethingElseBrandingForm()
|
||||
|
||||
if form.validate_on_submit():
|
||||
create_email_branding_zendesk_ticket(
|
||||
"something_else", detail=form.something_else.data
|
||||
)
|
||||
|
||||
flash(
|
||||
"Thanks for your branding request. We’ll get back to you within one working day.",
|
||||
"default",
|
||||
)
|
||||
return redirect(url_for(".service_settings", service_id=current_service.id))
|
||||
|
||||
return render_template(
|
||||
"views/service-settings/branding/email-branding-something-else.html",
|
||||
form=form,
|
||||
branding_options=ChooseEmailBrandingForm(current_service),
|
||||
)
|
||||
|
||||
|
||||
@main.route("/services/<uuid:service_id>/data-retention", methods=["GET"])
|
||||
@user_is_platform_admin
|
||||
def data_retention(service_id):
|
||||
@@ -1184,10 +987,6 @@ def edit_service_billing_details(service_id):
|
||||
)
|
||||
|
||||
|
||||
def get_branding_as_value_and_label(email_branding):
|
||||
return [(branding["id"], branding["name"]) for branding in email_branding]
|
||||
|
||||
|
||||
def convert_dictionary_to_wtforms_choices_format(dictionary, value, label):
|
||||
return [(item[value], item[label]) for item in dictionary]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user