mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-12 09:58:50 -04:00
Select a branding with a link, not form
Selecting a branding just takes you to a new page, it doesn’t change any state. Links are generally the way you go from one page to another on the web.
This commit is contained in:
@@ -713,20 +713,6 @@ class ServicePreviewBranding(StripWhitespaceForm):
|
||||
branding_style = HiddenField('branding_style')
|
||||
|
||||
|
||||
class ServiceSelectEmailBranding(StripWhitespaceForm):
|
||||
|
||||
def __init__(self, email_brandings=[], *args, **kwargs):
|
||||
self.email_branding.choices = email_brandings
|
||||
super(ServiceSelectEmailBranding, self).__init__(*args, **kwargs)
|
||||
|
||||
email_branding = RadioField(
|
||||
'Email branding',
|
||||
validators=[
|
||||
DataRequired()
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class ServiceUpdateEmailBranding(StripWhitespaceForm):
|
||||
|
||||
name = StringField('Name of brand')
|
||||
|
||||
@@ -3,11 +3,7 @@ from flask_login import login_required
|
||||
|
||||
from app import email_branding_client
|
||||
from app.main import main
|
||||
from app.main.forms import (
|
||||
SearchTemplatesForm,
|
||||
ServiceSelectEmailBranding,
|
||||
ServiceUpdateEmailBranding,
|
||||
)
|
||||
from app.main.forms import SearchTemplatesForm, ServiceUpdateEmailBranding
|
||||
from app.main.s3_client import (
|
||||
TEMP_TAG,
|
||||
delete_temp_file,
|
||||
@@ -25,16 +21,9 @@ from app.utils import get_cdn_domain, user_is_platform_admin
|
||||
def email_branding():
|
||||
brandings = email_branding_client.get_all_email_branding(sort_key='name')
|
||||
|
||||
form = ServiceSelectEmailBranding()
|
||||
email_brandings = get_branding_as_value_and_label(brandings)
|
||||
form.email_branding.choices = email_brandings
|
||||
|
||||
if form.validate_on_submit():
|
||||
return redirect(url_for('.update_email_branding', branding_id=form.email_branding.data))
|
||||
|
||||
return render_template(
|
||||
'views/email-branding/select-branding.html',
|
||||
form=form,
|
||||
email_brandings=get_branding_as_value_and_label(brandings),
|
||||
search_form=SearchTemplatesForm(),
|
||||
show_search_box=len(brandings) > 9,
|
||||
)
|
||||
|
||||
@@ -17,16 +17,15 @@
|
||||
<a href="{{ url_for('.create_email_branding') }}" class="button align-with-heading">Add new brand</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid-row">
|
||||
<div class="column-three-quarters">
|
||||
<form method="post">
|
||||
{{ live_search(target_selector='.multiple-choice', show=show_search_box, form=search_form) }}
|
||||
{{ radios(form.email_branding) }}
|
||||
{{ page_footer(
|
||||
'Next'
|
||||
) }}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{{ live_search(target_selector='.message-name', show=show_search_box, form=search_form) }}
|
||||
<nav>
|
||||
{% for id, name in email_brandings %}
|
||||
<div class="message-name">
|
||||
<a href="{{ url_for('.update_email_branding', branding_id=id) }}">
|
||||
{{name}}
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -20,8 +20,9 @@ def test_email_branding_page_shows_full_branding_list(
|
||||
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
radio_labels = page.select('div.multiple-choice > label')
|
||||
brand_names = [element.get_text().strip() for idx, element in enumerate(radio_labels)]
|
||||
links = page.select('.message-name a')
|
||||
brand_names = [normalize_spaces(link.text) for link in links]
|
||||
hrefs = [link['href'] for link in links]
|
||||
|
||||
assert normalize_spaces(
|
||||
page.select_one('h1').text
|
||||
@@ -29,11 +30,16 @@ def test_email_branding_page_shows_full_branding_list(
|
||||
|
||||
assert page.select_one('.column-three-quarters a')['href'] == url_for('main.create_email_branding')
|
||||
|
||||
first_label = radio_labels[0]
|
||||
assert normalize_spaces(first_label.text) == 'org 1'
|
||||
assert brand_names == [
|
||||
'org 1', 'org 2', 'org 3', 'org 4', 'org 5'
|
||||
]
|
||||
assert hrefs == [
|
||||
url_for('.update_email_branding', branding_id=1),
|
||||
url_for('.update_email_branding', branding_id=2),
|
||||
url_for('.update_email_branding', branding_id=3),
|
||||
url_for('.update_email_branding', branding_id=4),
|
||||
url_for('.update_email_branding', branding_id=5),
|
||||
]
|
||||
|
||||
|
||||
def test_edit_email_branding_shows_the_correct_branding_info(
|
||||
|
||||
Reference in New Issue
Block a user