Skip to content

Commit

Permalink
This is a combination of 5 commits.
Browse files Browse the repository at this point in the history
 This is the 1st commit message:

adding content changes
  • Loading branch information
chris-pettinga authored and cencorroll committed Jan 7, 2025
1 parent 9b4ee34 commit 8a52d65
Show file tree
Hide file tree
Showing 44 changed files with 127 additions and 36 deletions.
14 changes: 14 additions & 0 deletions django_app/config/env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import subprocess

from dbt_copilot_python.database import database_url_from_env
from dbt_copilot_python.network import setup_allowed_hosts
Expand Down Expand Up @@ -79,6 +80,10 @@ class BaseSettings(PydanticBaseSettings):
csp_report_only: bool = True
csp_report_uri: str | None = None

# Information about the current environment
current_branch: str = Field(alias="GIT_BRANCH", default="unknown")
current_tag: str = Field(alias="GIT_TAG", default="")

@computed_field
@property
def redis_url(self) -> str:
Expand Down Expand Up @@ -113,6 +118,15 @@ class LocalSettings(BaseSettings):
profiling_enabled: bool = False
localstack_port: int = 14566

@computed_field
@property
def git_current_branch(self) -> str:
current_branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True)
if current_branch.returncode == 0:
return current_branch.stdout.decode("utf-8").replace("\n", "")
else:
return "unknown"


class TestSettings(LocalSettings):
headless: bool = False
Expand Down
5 changes: 5 additions & 0 deletions django_app/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"core.context_processors.is_debug_mode",
"core.context_processors.session_expiry_times",
"core.context_processors.sentry_configuration_options",
"core.context_processors.environment_information",
],
},
},
Expand Down Expand Up @@ -341,3 +342,7 @@
SESSION_LAST_ACTIVITY_KEY = "last_form_submission"

PROTOCOL = "https://"

# Information about the current environment
CURRENT_BRANCH = env.current_branch
CURRENT_TAG = env.current_tag
2 changes: 2 additions & 0 deletions django_app/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
# we need to override AWS_ENDPOINT_URL environment variable to use localstack
os.environ["AWS_ENDPOINT_URL"] = f"http://localhost:{env.localstack_port}"
PROTOCOL = "http://"

CURRENT_BRANCH = env.git_current_branch
9 changes: 9 additions & 0 deletions django_app/core/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ def sentry_configuration_options(request: HttpRequest) -> dict[str, str | float]
"SENTRY_ENABLE_TRACING": settings.SENTRY_ENABLE_TRACING,
"SENTRY_TRACES_SAMPLE_RATE": settings.SENTRY_TRACES_SAMPLE_RATE,
}


def environment_information(request: HttpRequest) -> dict[str, str]:
"""Add the current environment & branch to the context."""
return {
"current_environment": settings.ENVIRONMENT,
"current_branch": settings.CURRENT_BRANCH,
"current_tag": settings.CURRENT_TAG,
}
21 changes: 17 additions & 4 deletions django_app/core/templates/core/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,23 @@ <h2 class="govuk-cookie-banner__heading govuk-heading-m">
</script>

{% block skip_link %}
<a href="#main-content" class="govuk-skip-link">{% trans 'Skip to main content' %}</a>
<a href="#main-content" class="govuk-skip-link">Skip to main content</a>
{% endblock %}

{% if current_environment != "production" and is_debug_mode %}
<div class="govuk-phase-banner hide-on-print" data-testid="environment_banner" style="background-color: orange;">
<p class="govuk-phase-banner__content" style="margin: 0 auto;">
<span class="govuk-phase-banner__text">
Environment: <strong>{{ current_environment }}</strong><br>
Branch: <strong>{{ current_branch }}</strong><br>
{% if current_tag %}
Tag: <strong>{{ current_tag }}</strong>
{% endif %}
</span>
</p>
</div>
{% endif %}

<header class="govuk-header" role="banner" data-module="govuk-header">
<div class="govuk-header__container govuk-width-container">
<div class="govuk-header__logo">
Expand Down Expand Up @@ -203,9 +217,8 @@ <h2 class="govuk-cookie-banner__heading govuk-heading-m">
{# don't show the feedback text whilst on a feedback page #}
{% if request.resolver_match.app_name != "feedback" %}
– Help us improve it and
<a class="govuk-link" target="_blank"
href="{% url 'feedback:collect_full_feedback' %}?url={% get_feedback_url request %}">
give your feedback (opens in a new tab).
<a class="govuk-link" target="_blank " data-testid="collect_feedback_link"
href="{% url 'feedback:collect_full_feedback' %}?url={% get_feedback_url request %}">give your feedback (opens in a new tab).
</a>
{% endif %}
</span>
Expand Down
2 changes: 1 addition & 1 deletion django_app/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
path("view/", include("view_a_suspected_breach.urls")),
path("cookies-policy", CookiesConsentView.as_view(), name="cookies_consent"),
path("hide_cookies", HideCookiesView.as_view(), name="hide_cookies"),
path("feedback/", include("feedback.urls")),
path("give-feedback/", include("feedback.urls")),
path("healthcheck/", include("healthcheck.urls")),
path("privacy-notice", PrivacyNoticeView.as_view(), name="privacy_notice"),
path("reset_session/", ResetSessionView.as_view(), name="reset_session"),
Expand Down
8 changes: 4 additions & 4 deletions django_app/feedback/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@


class RatingChoices(models.IntegerChoices):
VERY_DISSATISFIED = 1, "Very dissatisfied"
DISSATISFIED = 2, "Dissatisfied"
NEUTRAL = 3, "Neutral"
SATISFIED = 4, "Satisfied"
VERY_SATISFIED = 5, "Very satisfied"
SATISFIED = 4, "Satisfied"
NEUTRAL = 3, "Neutral"
DISSATISFIED = 2, "Dissatisfied"
VERY_DISSATISFIED = 1, "Very dissatisfied"


class DidYouExperienceAnyIssues(models.TextChoices):
Expand Down
2 changes: 1 addition & 1 deletion django_app/feedback/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

urlpatterns = [
path("", views.ProvideFullFeedbackView.as_view(), name="collect_full_feedback"),
path("done", views.FeedbackDoneView.as_view(), name="feedback_done"),
path("feedback-sent/", views.FeedbackDoneView.as_view(), name="feedback_done"),
]
2 changes: 1 addition & 1 deletion django_app/sanctions_regimes
6 changes: 3 additions & 3 deletions tests/test_frontend/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@

SANCTIONS = [sanction["name"] for sanction in active_regimes]

FILES = [os.path.join(os.path.dirname(__file__), "testfiles/testfile.pdf")]
MISSING_FILE_TYPE = [os.path.join(os.path.dirname(__file__), "testfiles/missing_filetype")]
MALWARE_FILE_TYPE = [os.path.join(os.path.dirname(__file__), "testfiles/mock_malware_file.txt")]
FILES = [os.path.join(os.path.dirname(__file__), "test_report_a_suspected_breach/testfiles/testfile.pdf")]
MISSING_FILE_TYPE = [os.path.join(os.path.dirname(__file__), "test_report_a_suspected_breach/testfiles/missing_filetype")]
MALWARE_FILE_TYPE = [os.path.join(os.path.dirname(__file__), "test_report_a_suspected_breach/testfiles/mock_malware_file.txt")]

END_USERS = {
"end_user1": {
Expand Down
File renamed without changes.
31 changes: 31 additions & 0 deletions tests/test_frontend/test_core/test_environment_banner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django.test import override_settings
from playwright.sync_api import expect

from tests.test_frontend.conftest import PlaywrightTestBase


class TestEnvironmentBanner(PlaywrightTestBase):
"""Tests the non-production banner appears"""

@override_settings(ENVIRONMENT="production", DEBUG=False)
def test_banner_does_not_appear_on_production(self):
self.page.goto(self.base_url)
expect(self.page.get_by_test_id("environment_banner")).to_be_hidden()

@override_settings(ENVIRONMENT="production", DEBUG=True)
def test_banner_does_not_appear_debug_true(self):
self.page.goto(self.base_url)
expect(self.page.get_by_test_id("environment_banner")).to_be_hidden()

@override_settings(ENVIRONMENT="local", DEBUG=True)
def test_banner_appears(self):
self.page.goto(self.base_url)
expect(self.page.get_by_test_id("environment_banner")).to_be_visible()
expect(self.page.get_by_text("Environment: local")).to_be_visible()

@override_settings(ENVIRONMENT="local", DEBUG=True, CURRENT_BRANCH="test-branch", CURRENT_TAG="v1.0.0")
def test_banner_content(self):
self.page.goto(self.base_url)
expect(self.page.get_by_text("Environment: local")).to_be_visible()
expect(self.page.get_by_text("Branch: test-branch")).to_be_visible()
expect(self.page.get_by_text("Tag: v1.0.0")).to_be_visible()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest, data
from tests.test_frontend import conftest, data


class TestAboutThePersonOrBusinessUKAddress(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestCheckCompanyDetails(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestAreYouReportingABusinessOnCompaniesHouse(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWhereIsTheAddressOfTheBusinessOrPerson(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest, data
from tests.test_frontend import conftest, data


class TestWhatWereTheGoods(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWhenDidYouFirstSuspect(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWhichSanctionsRegimes(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestTellUsAboutTheSuspectedBreach(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from playwright.sync_api import expect

from .. import conftest, data
from tests.test_frontend import conftest, data


class TestUploadDocuments(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.urls import reverse
from playwright.sync_api import expect

from .. import conftest, data
from tests.test_frontend import conftest, data

breach_details_owner = {
"reporter_relationship": "I'm an owner",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest, data
from tests.test_frontend import conftest, data


class TestAboutTheSupplierUKMadeAvailableAddress(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWereThereAnyOtherAddressesInTheSupplyChain(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWhereWereTheGoodsMadeAvailableFrom(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWhereWereTheGoodsMadeAvailableTo(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWhereWereTheGoodsSuppliedFrom(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestWhereWereTheGoodsSuppliedTo(conftest.PlaywrightTestBase):
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestEmail(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestNameAndBusinessYouWorkFor(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest


class TestReporterProfessionalRelationship(conftest.PlaywrightTestBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest

CORRECT_CODE_DETAILS = {"email": "[email protected]", "verify_code": "012345"}
EMPTY_CODE_DETAILS = {"email": "[email protected]", "verify_code": ""}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from playwright.sync_api import expect

from .. import conftest
from tests.test_frontend import conftest

INCORRECT_CODE_DETAILS = {"email": "[email protected]", "verify_code": "987654"}
EMPTY_CODE_DETAILS = {"email": "[email protected]", "verify_code": ""}
Expand Down
File renamed without changes.
Loading

0 comments on commit 8a52d65

Please sign in to comment.