-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a maintenance message on the header if the environment variable `MAINTENANCE_HEADER_MSG` is true. GN-1012
- Loading branch information
Showing
9 changed files
with
139 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
sites/nau/src/backend/nau/maintenance/context_processors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Jira Service desk widget context processor | ||
""" | ||
from django.conf import settings | ||
|
||
|
||
def maintenance_header_message_setting(request): | ||
""" | ||
Maintenance header message | ||
""" | ||
context = {} | ||
if hasattr(settings, "MAINTENANCE_HEADER_MSG"): | ||
context["MAINTENANCE_HEADER_MSG"] = getattr(settings, "MAINTENANCE_HEADER_MSG") | ||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
End-to-end tests for the course detail view | ||
""" | ||
from django.test.utils import override_settings | ||
|
||
from cms.test_utils.testcases import CMSTestCase | ||
from richie.apps.courses.factories import CourseFactory | ||
|
||
|
||
class JiraServiceDeskWidgetBaseTemplateRenderingCMSTestCase(CMSTestCase): | ||
""" | ||
Test case that verifies if the maintenance message is being displayed and the search on header | ||
if not visible. | ||
""" | ||
|
||
@override_settings(MAINTENANCE_HEADER_MSG=True) | ||
def test_template_base_maintenance_is_true(self): | ||
""" | ||
Test if the maintenance message is visible on header if MAINTENANCE_HEADER_MSG is true. | ||
""" | ||
course = CourseFactory() | ||
page = course.extended_object | ||
page.publish("en") | ||
|
||
url = course.extended_object.get_absolute_url() | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
self.assertContains(response, "topbar__maintenance") | ||
self.assertNotContains(response, "topbar__search") | ||
|
||
def test_template_base_maintenance_is_absent(self): | ||
""" | ||
Test if the maintenance message is not visible if the `MAINTENANCE_HEADER_MSG` not defined | ||
and the top bar search is visible. | ||
""" | ||
course = CourseFactory() | ||
page = course.extended_object | ||
page.publish("en") | ||
|
||
url = course.extended_object.get_absolute_url() | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
self.assertNotContains(response, "topbar__maintenance") | ||
self.assertContains(response, "topbar__search") | ||
|
||
@override_settings(MAINTENANCE_HEADER_MSG=False) | ||
def test_template_base_maintenance_is_false(self): | ||
""" | ||
Test if the maintenance message is not visible if the `MAINTENANCE_HEADER_MSG` is False | ||
and the top bar search is visible. | ||
""" | ||
course = CourseFactory() | ||
page = course.extended_object | ||
page.publish("en") | ||
|
||
url = course.extended_object.get_absolute_url() | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
|
||
self.assertNotContains(response, "topbar__maintenance") | ||
self.assertContains(response, "topbar__search") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters