diff --git a/src/registrar/config/settings.py b/src/registrar/config/settings.py index 8438812c4..aa7d73c2f 100644 --- a/src/registrar/config/settings.py +++ b/src/registrar/config/settings.py @@ -189,6 +189,7 @@ MIDDLEWARE = [ # Used for waffle feature flags "waffle.middleware.WaffleMiddleware", "registrar.registrar_middleware.CheckUserProfileMiddleware", + "registrar.registrar_middleware.CheckOrganizationMiddleware", ] # application object used by Django’s built-in servers (e.g. `runserver`) diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index dc6c8acb5..72115f66a 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -25,6 +25,7 @@ from registrar.views.domain_request import Step from registrar.views.domain_requests_json import get_domain_requests_json from registrar.views.domains_json import get_domains_json from registrar.views.utility import always_404 +from registrar.views.index_organizations import index_organizations from api.views import available, get_current_federal, get_current_full @@ -58,6 +59,11 @@ for step, view in [ urlpatterns = [ path("", views.index, name="home"), + path( + "organization", + index_organizations, + name="home-organization", + ), path( "admin/logout/", RedirectView.as_view(pattern_name="logout", permanent=False), diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index 79e3b7a11..04ec9fa13 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -2,6 +2,7 @@ Contains middleware used in settings.py """ +import logging from urllib.parse import parse_qs from django.urls import reverse from django.http import HttpResponseRedirect @@ -10,6 +11,7 @@ from waffle.decorators import flag_is_active from registrar.models.utility.generic_helper import replace_url_queryparams +logger = logging.getLogger(__name__) class NoCacheMiddleware: """ @@ -119,3 +121,36 @@ class CheckUserProfileMiddleware: else: # Process the view as normal return None + +class CheckOrganizationMiddleware: + """ + """ + + def __init__(self, get_response): + self.get_response = get_response + self.home_organization = reverse("home-organization") + self.home = reverse("home") + self.json1 = reverse("get_domains_json") + self.json2 = reverse("get_domain_requests_json") + + def __call__(self, request): + response = self.get_response(request) + return response + + def process_view(self, request, view_func, view_args, view_kwargs): + current_path = request.path + logger.debug(f"Current path: {current_path}") + + # Avoid infinite loop by skipping the redirect check on the home-organization URL + if current_path == self.home_organization or current_path == self.json1 or current_path == self.json2: + logger.debug("Skipping middleware check for home-organization URL") + return None + + has_organization_feature_flag = flag_is_active(request, "organization_feature") + logger.debug(f"Flag is active: {has_organization_feature_flag}") + + if has_organization_feature_flag: + logger.debug(f"Redirecting to {self.home_organization}") + return HttpResponseRedirect(self.home_organization) + + return None diff --git a/src/registrar/templates/home.html b/src/registrar/templates/home.html index f93159f01..a5ed4c86c 100644 --- a/src/registrar/templates/home.html +++ b/src/registrar/templates/home.html @@ -9,189 +9,48 @@ {% if user.is_authenticated %} {# the entire logged in page goes here #} -
- {% block messages %} - {% include "includes/form_messages.html" %} - {% endblock %} -

Manage your domains

+{% block homepage_content %} - {% comment %} - IMPORTANT: - If this button is added on any other page, make sure to update the - relevant view to reset request.session["new_request"] = True - {% endcomment %} -

- - Start a new domain request - -

+
+ {% block messages %} + {% include "includes/form_messages.html" %} + {% endblock %} +

Manage your domains

-
-
-
-

Domains

-
-
-
- -
-
-
- - - -
- + {% comment %} + IMPORTANT: + If this button is added on any other page, make sure to update the + relevant view to reset request.session["new_request"] = True + {% endcomment %} +

+ + Start a new domain request + +

-
-
-
-

Domain requests

-
-
-
- -
-
-
- - - -
- + {% include "includes/domains_table.html" %} + {% include "includes/domain_requests_table.html" %} - {# Note: Reimplement this after MVP #} - + {# Note: Reimplement this after MVP #} + - - + + + +{% endblock %}
{% else %} {# not user.is_authenticated #} diff --git a/src/registrar/templates/home_organizations.html b/src/registrar/templates/home_organizations.html new file mode 100644 index 000000000..5edd3860a --- /dev/null +++ b/src/registrar/templates/home_organizations.html @@ -0,0 +1,55 @@ +{% extends 'home.html' %} + +{% load static %} + +{% block homepage_content %} + +
+
+
+ {% include "organization_sidebar.html" %} +
+
+ {% block messages %} + {% include "includes/form_messages.html" %} + {% endblock %} +

Manage your domains

+ + {% comment %} + IMPORTANT: + If this button is added on any other page, make sure to update the + relevant view to reset request.session["new_request"] = True + {% endcomment %} +

+ + Start a new domain request + +

+ + {% include "includes/domains_table.html" %} + {% include "includes/domain_requests_table.html" %} + + {# Note: Reimplement this after MVP #} + + + + + + +
+
+ +{% endblock %} diff --git a/src/registrar/templates/includes/domain_requests_table.html b/src/registrar/templates/includes/domain_requests_table.html new file mode 100644 index 000000000..377f49d02 --- /dev/null +++ b/src/registrar/templates/includes/domain_requests_table.html @@ -0,0 +1,69 @@ +{% load static %} + +
+
+
+

Domain requests

+
+
+
+ +
+
+
+ + + +
+ diff --git a/src/registrar/templates/includes/domains_table.html b/src/registrar/templates/includes/domains_table.html new file mode 100644 index 000000000..334dba3da --- /dev/null +++ b/src/registrar/templates/includes/domains_table.html @@ -0,0 +1,81 @@ +{% load static %} + +
+
+
+

Domains

+
+
+
+ +
+
+
+ + + +
+ diff --git a/src/registrar/templates/organization_sidebar.html b/src/registrar/templates/organization_sidebar.html new file mode 100644 index 000000000..ed664affd --- /dev/null +++ b/src/registrar/templates/organization_sidebar.html @@ -0,0 +1,18 @@ +{% load static url_helpers %} + +
+ +
diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py index c05bde21d..5e546e8e7 100644 --- a/src/registrar/views/index.py +++ b/src/registrar/views/index.py @@ -9,8 +9,11 @@ def index(request): if request.user.is_authenticated: # This is a django waffle flag which toggles features based off of the "flag" table context["has_profile_feature_flag"] = flag_is_active(request, "profile_feature") + context["has_organization_feature_flag"] = flag_is_active(request, "organization_feature") # This controls the creation of a new domain request in the wizard request.session["new_request"] = True + print('homepage view') + return render(request, "home.html", context) diff --git a/src/registrar/views/index_organizations.py b/src/registrar/views/index_organizations.py new file mode 100644 index 000000000..4ec15ad59 --- /dev/null +++ b/src/registrar/views/index_organizations.py @@ -0,0 +1,19 @@ +from django.shortcuts import render +from waffle.decorators import flag_is_active + + +def index_organizations(request): + """This page is available to anyone without logging in.""" + context = {} + + if request.user.is_authenticated: + # This is a django waffle flag which toggles features based off of the "flag" table + context["has_profile_feature_flag"] = flag_is_active(request, "profile_feature") + context["has_organization_feature_flag"] = flag_is_active(request, "organization_feature") + + # This controls the creation of a new domain request in the wizard + request.session["new_request"] = True + + print('homepage organizations view') + + return render(request, "home_organizations.html", context)