Skip to content

Commit

Permalink
Merge pull request #42 from co-cddo/enable-access-to-admin-site
Browse files Browse the repository at this point in the history
Re-enable access to Django admin site
  • Loading branch information
jimnarey authored Mar 8, 2024
2 parents 3463a3f + aab0df4 commit 4e33cd3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions request_a_govuk_domain/request/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ def __init__(self, get_response):

def __call__(self, request):
response = self.get_response(request)
if request.path != reverse("start") and not self.is_valid_progress(request):
return redirect("start") # Redirect to start page if progress is invalid
return response
if self.is_valid_start_path(request.path):
return response
if self.is_valid_progress(request):
return response
return redirect("start") # Redirect to start page if progress is invalid

def is_valid_start_path(self, path: str):
if path == reverse("start"):
return True
if path.startswith("/admin"):
return True
return False

def is_valid_progress(self, request):
if request.session.get("registration_data") is None:
Expand Down

0 comments on commit 4e33cd3

Please sign in to comment.