Skip to content

Commit

Permalink
Merge branch 'master' into paas-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
osimuka authored Nov 15, 2024
2 parents 1804b08 + e9adfe3 commit dada0c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions trade_remedies_caseworker/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

urlpatterns = [
path("", CasesView.as_view(), name="cases"),
path("health/", core_views.HealthCheckView.as_view(), name="healthcheck"),
path("healthcheck/", core_views.PingdomHealthCheckView.as_view(), name="pingdom_healthcheck"),
path("accounts/login/", login_views.LoginView.as_view(), name="login"),
path("accounts/logout/", login_views.logout_view, name="logout"),
Expand Down
12 changes: 12 additions & 0 deletions trade_remedies_caseworker/core/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
import io
import json
import os

import openpyxl
from django.contrib import messages
Expand All @@ -24,6 +25,8 @@
SECURITY_GROUP_TRA_ADMINISTRATOR,
)

health_check_token = os.environ.get("HEALTH_CHECK_TOKEN")


class SystemView(LoginRequiredMixin, GroupRequiredMixin, TemplateView):
groups_required = (SECURITY_GROUP_TRA_ADMINISTRATOR,)
Expand All @@ -34,6 +37,15 @@ def get(self, request, *args, **kwargs):
return render(request, self.template_name, context=context)


class HealthCheckView(View, TradeRemediesAPIClientMixin):
def get(self, request):
response = self.trusted_client.health_check()
if all([response[k] == "OK" for k in response]):
return HttpResponse("OK")
else:
return HttpResponse(f"ERROR: {response}")


class BaseCaseView(LoginRequiredMixin, GroupRequiredMixin, TemplateView):
groups_required = SECURITY_GROUPS_TRA
template_name = None
Expand Down

0 comments on commit dada0c4

Please sign in to comment.