Use "get_email_choices" directly in branding view

This commit is contained in:
Ben Thorner
2022-03-23 15:22:54 +00:00
parent b4b1c91fb9
commit 332c240b01
2 changed files with 5 additions and 6 deletions

View File

@@ -2200,13 +2200,10 @@ class ChooseEmailBrandingForm(ChooseBrandingForm):
def __init__(self, service):
super().__init__()
self.options.choices = tuple(self.get_available_choices(service))
@classmethod
def get_available_choices(cls, service):
return (
self.options.choices = tuple(
list(branding.get_email_choices(service)) +
[cls.FALLBACK_OPTION]
[self.FALLBACK_OPTION]
)

View File

@@ -70,6 +70,7 @@ from app.main.forms import (
)
from app.utils import DELIVERED_STATUSES, FAILURE_STATUSES, SENDING_STATUSES
from app.utils.branding import NHS_EMAIL_BRANDING_ID
from app.utils.branding import get_email_choices as get_email_branding_choices
from app.utils.user import (
user_has_permissions,
user_is_gov_user,
@@ -1178,8 +1179,9 @@ def email_branding_request(service_id):
def check_email_branding_allowed_for_service(branding):
allowed_branding_for_service = dict(
ChooseEmailBrandingForm.get_available_choices(current_service)
get_email_branding_choices(current_service)
)
if branding not in allowed_branding_for_service:
abort(404)