mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
Allow creation of an organisation without a logo
Now we have the org banner branding, not all organisations need a logo. So it shouldn’t be an error to not provide one. Depends on: - [ ] https://github.com/alphagov/notifications-api/pull/1265
This commit is contained in:
@@ -71,7 +71,9 @@ def manage_org(logo=None):
|
||||
return redirect(
|
||||
url_for('.manage_org', logo=upload_filename))
|
||||
|
||||
logo = persist_logo(logo, session["user_id"])
|
||||
if logo:
|
||||
logo = persist_logo(logo, session["user_id"])
|
||||
|
||||
delete_temp_files_created_by(session["user_id"])
|
||||
|
||||
if org:
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
secondary_link=False,
|
||||
secondary_link_text=None,
|
||||
delete_link=False,
|
||||
delete_link_text="delete",
|
||||
button_disabled=False
|
||||
delete_link_text="delete"
|
||||
) %}
|
||||
<div class="page-footer">
|
||||
{% if button_text %}
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
||||
<input type="submit" class="button{% if destructive %}-destructive{% endif %}" value="{{ button_text }}"{% if button_disabled %} disabled{% endif %}/>
|
||||
<input type="submit" class="button{% if destructive %}-destructive{% endif %}" value="{{ button_text }}" />
|
||||
{% endif %}
|
||||
{% if back_link %}
|
||||
<a class="page-footer-back-link" href="{{ back_link }}">{{ back_link_text }}</a>
|
||||
|
||||
@@ -26,14 +26,13 @@
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<div style='margin-top:15px;'>{{textbox(form.name)}}</div>
|
||||
<div>{{textbox(form.colour, width='1-4')}}
|
||||
<div>{{textbox(form.colour, width='1-4')}}
|
||||
<span id='colour_span' style="background: {{ organisation.colour }}; {% if not organisation.colour %}visibility:hidden; {% endif %}border:1px black solid; width: 3px; height: 25px;position:absolute;margin-top:138px;margin-left:135px;display:block;"></span>
|
||||
</div>
|
||||
{{ page_footer(
|
||||
'Save',
|
||||
back_link=url_for('.organisations', organisation_id=organisation.id if organisation else 'None'),
|
||||
back_link_text='Back to organisation selection',
|
||||
button_disabled=True if not logo else False
|
||||
) }}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -113,20 +113,11 @@ def test_manage_orgs_shows_correct_org_info(request_get_manage_org_with_org):
|
||||
|
||||
|
||||
def test_manage_orgs_does_not_show_data_for_new_org(request_get_manage_org_without_org):
|
||||
assert request_get_manage_org_without_org.select_one('div.page-footer input.button').has_attr('disabled')
|
||||
assert request_get_manage_org_without_org.select_one('#logo-img > img') is None
|
||||
assert request_get_manage_org_without_org.select_one('#name').attrs.get('value') == ''
|
||||
assert request_get_manage_org_without_org.select_one('#colour').attrs.get('value') == ''
|
||||
|
||||
|
||||
def test_save_is_enabled_when_logo_is_set(request_get_manage_org_with_org):
|
||||
assert request_get_manage_org_with_org.select_one('div.page-footer input.button').has_attr('disabled') is False
|
||||
|
||||
|
||||
def test_save_is_disabled_when_logo_is_not_set(request_get_manage_org_without_org):
|
||||
assert request_get_manage_org_without_org.select_one('div.page-footer input.button').has_attr('disabled')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def request_post_manage_org_redirect(logged_in_platform_admin_client, mocker, fake_uuid):
|
||||
with logged_in_platform_admin_client.session_transaction() as session:
|
||||
@@ -262,3 +253,29 @@ def test_create_new_organisation_when_organisation_saved(logged_in_platform_admi
|
||||
name=new_org['name'],
|
||||
colour=new_org['colour']
|
||||
)
|
||||
|
||||
|
||||
def test_create_new_organisation_without_logo(logged_in_platform_admin_client, mocker, fake_uuid):
|
||||
|
||||
new_org = {'logo': None, 'colour': 'red', 'name': 'new name'}
|
||||
|
||||
mocked_new_org = mocker.patch('app.organisations_client.create_organisation')
|
||||
mock_persist = mocker.patch('app.main.views.organisations.persist_logo')
|
||||
mocker.patch('app.main.views.organisations.delete_temp_files_created_by')
|
||||
|
||||
logged_in_platform_admin_client.post(
|
||||
url_for('.manage_org'),
|
||||
content_type='multipart/form-data',
|
||||
data={
|
||||
'colour': new_org['colour'],
|
||||
'name': new_org['name'],
|
||||
}
|
||||
)
|
||||
|
||||
assert mocked_new_org.called
|
||||
assert mocked_new_org.call_args == call(
|
||||
logo=new_org['logo'],
|
||||
name=new_org['name'],
|
||||
colour=new_org['colour']
|
||||
)
|
||||
assert mock_persist.call_args_list == []
|
||||
|
||||
Reference in New Issue
Block a user