diff --git a/securedrop/journalist_app/admin.py b/securedrop/journalist_app/admin.py index 7cd3981756..0b32e4af40 100644 --- a/securedrop/journalist_app/admin.py +++ b/securedrop/journalist_app/admin.py @@ -59,6 +59,7 @@ def update_submission_preferences(): form = SubmissionPreferencesForm() if form.validate_on_submit(): # The UI prompt ("prevent") is the opposite of the setting ("allow"): + flash(gettext("Preferences saved."), "submission-preferences-success") value = not bool(request.form.get('prevent_document_uploads')) InstanceConfig.set('allow_document_uploads', value) return redirect(url_for('admin.manage_config')) diff --git a/securedrop/journalist_templates/config.html b/securedrop/journalist_templates/config.html index 219aea289a..96b6563b33 100644 --- a/securedrop/journalist_templates/config.html +++ b/securedrop/journalist_templates/config.html @@ -54,6 +54,7 @@

{{ gettext('Submission Preferences') }}

+ {% include 'submission_preferences_saved_flash.html' %} {% endblock %} diff --git a/securedrop/journalist_templates/logo_upload_flashed.html b/securedrop/journalist_templates/logo_upload_flashed.html index d72f785977..00dab9eb53 100644 --- a/securedrop/journalist_templates/logo_upload_flashed.html +++ b/securedrop/journalist_templates/logo_upload_flashed.html @@ -1,4 +1,4 @@ -{# these are flashed messages for the logo upload file verifiaction #} +{# these are flashed messages for the logo upload file verification #} {% with messages = get_flashed_messages(with_categories=True, category_filter=["logo-success", "logo-error"]) %} {% for category, message in messages %} {% set category_status = category[5:] %} diff --git a/securedrop/journalist_templates/submission_preferences_saved_flash.html b/securedrop/journalist_templates/submission_preferences_saved_flash.html new file mode 100644 index 0000000000..d88d393af5 --- /dev/null +++ b/securedrop/journalist_templates/submission_preferences_saved_flash.html @@ -0,0 +1,11 @@ +{% with messages = get_flashed_messages(with_categories=True, category_filter=["submission-preferences-success"]) %} + {% for category, message in messages %} +{# Get the end of the of the category message which + contains the category status.(success/error)#} + {% set category_status = category[23:] %} +
+ + {{ message }} +
+ {% endfor %} +{% endwith %} diff --git a/securedrop/tests/functional/journalist_navigation_steps.py b/securedrop/tests/functional/journalist_navigation_steps.py index 77a94420bb..3a7f3d6f04 100644 --- a/securedrop/tests/functional/journalist_navigation_steps.py +++ b/securedrop/tests/functional/journalist_navigation_steps.py @@ -287,11 +287,21 @@ def _admin_disallows_document_uploads(self): self.safe_click_by_id("prevent_document_uploads") self.safe_click_by_id("submit-submission-preferences") + def preferences_saved(): + flash_msg = self.driver.find_element_by_css_selector(".flash") + assert "Preferences saved." in flash_msg.text + self.wait_for(preferences_saved, timeout=self.timeout * 6) + def _admin_allows_document_uploads(self): if self.driver.find_element_by_id("prevent_document_uploads").is_selected(): self.safe_click_by_id("prevent_document_uploads") self.safe_click_by_id("submit-submission-preferences") + def preferences_saved(): + flash_msg = self.driver.find_element_by_css_selector(".flash") + assert "Preferences saved." in flash_msg.text + self.wait_for(preferences_saved, timeout=self.timeout * 6) + def _add_user(self, username, first_name="", last_name="", is_admin=False, hotp=None): self.safe_send_keys_by_css_selector('input[name="username"]', username) diff --git a/securedrop/tests/test_journalist.py b/securedrop/tests/test_journalist.py index c8ce5de30f..23b935b0cc 100644 --- a/securedrop/tests/test_journalist.py +++ b/securedrop/tests/test_journalist.py @@ -1297,6 +1297,11 @@ def test_prevent_document_uploads(journalist_app, test_admin): data=form.data, follow_redirects=True) assert InstanceConfig.get_current().allow_document_uploads is False + with InstrumentedApp(journalist_app) as ins: + app.post(url_for('admin.update_submission_preferences'), + data=form.data, + follow_redirects=True) + ins.assert_message_flashed('Preferences saved.', 'submission-preferences-success') def test_no_prevent_document_uploads(journalist_app, test_admin): @@ -1306,6 +1311,10 @@ def test_no_prevent_document_uploads(journalist_app, test_admin): app.post(url_for('admin.update_submission_preferences'), follow_redirects=True) assert InstanceConfig.get_current().allow_document_uploads is True + with InstrumentedApp(journalist_app) as ins: + app.post(url_for('admin.update_submission_preferences'), + follow_redirects=True) + ins.assert_message_flashed('Preferences saved.', 'submission-preferences-success') def test_logo_upload_with_valid_image_succeeds(journalist_app, test_admin):