mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 11:28:25 -04:00
Merge pull request #1503 from alphagov/logoless-organisations
Allow creation of an organisation without a logo
This commit is contained in:
@@ -71,7 +71,9 @@ def manage_org(logo=None):
|
|||||||
return redirect(
|
return redirect(
|
||||||
url_for('.manage_org', logo=upload_filename))
|
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"])
|
delete_temp_files_created_by(session["user_id"])
|
||||||
|
|
||||||
if org:
|
if org:
|
||||||
|
|||||||
@@ -6,13 +6,12 @@
|
|||||||
secondary_link=False,
|
secondary_link=False,
|
||||||
secondary_link_text=None,
|
secondary_link_text=None,
|
||||||
delete_link=False,
|
delete_link=False,
|
||||||
delete_link_text="delete",
|
delete_link_text="delete"
|
||||||
button_disabled=False
|
|
||||||
) %}
|
) %}
|
||||||
<div class="page-footer">
|
<div class="page-footer">
|
||||||
{% if button_text %}
|
{% if button_text %}
|
||||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
|
<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 %}
|
{% endif %}
|
||||||
{% if back_link %}
|
{% if back_link %}
|
||||||
<a class="page-footer-back-link" href="{{ back_link }}">{{ back_link_text }}</a>
|
<a class="page-footer-back-link" href="{{ back_link }}">{{ back_link_text }}</a>
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
'Save',
|
'Save',
|
||||||
back_link=url_for('.organisations', organisation_id=organisation.id if organisation else 'None'),
|
back_link=url_for('.organisations', organisation_id=organisation.id if organisation else 'None'),
|
||||||
back_link_text='Back to organisation selection',
|
back_link_text='Back to organisation selection',
|
||||||
button_disabled=True if not logo else False
|
|
||||||
) }}
|
) }}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</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):
|
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('#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('#name').attrs.get('value') == ''
|
||||||
assert request_get_manage_org_without_org.select_one('#colour').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
|
@pytest.fixture
|
||||||
def request_post_manage_org_redirect(logged_in_platform_admin_client, mocker, fake_uuid):
|
def request_post_manage_org_redirect(logged_in_platform_admin_client, mocker, fake_uuid):
|
||||||
with logged_in_platform_admin_client.session_transaction() as session:
|
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'],
|
name=new_org['name'],
|
||||||
colour=new_org['colour']
|
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