diff --git a/src/registrar/config/urls.py b/src/registrar/config/urls.py index b693a9b65..3e0d44c4c 100644 --- a/src/registrar/config/urls.py +++ b/src/registrar/config/urls.py @@ -25,7 +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.organizations import index_organizations, organization_domains, organization_domain_requests +from registrar.views.organizations import organization_domains, organization_domain_requests from api.views import available, get_current_federal, get_current_full @@ -59,11 +59,6 @@ for step, view in [ urlpatterns = [ path("", views.index, name="home"), - path( - "organization//", - index_organizations, - name="home-organization", - ), path( "organization//domains/", organization_domains, diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index 86817f63d..30137ee63 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -130,8 +130,6 @@ class CheckOrganizationMiddleware: def __init__(self, get_response): self.get_response = get_response 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) @@ -141,22 +139,18 @@ class CheckOrganizationMiddleware: current_path = request.path logger.debug(f"Current path: {current_path}") - # Avoid infinite loop by skipping the redirect check on the home-organization URL and other JSON URLs - if current_path in [self.json1, self.json2] or current_path.startswith('/admin') or current_path.startswith('/organization'): - logger.debug("Skipping middleware check for admin, organization and JSON URLs") - 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: - if request.user.is_authenticated: - user_portfolios = Portfolio.objects.filter(creator=request.user) - if user_portfolios.exists(): - first_portfolio = user_portfolios.first() - home_organization_with_portfolio = reverse("organization-domains", kwargs={'portfolio_id': first_portfolio.id}) - - if current_path != home_organization_with_portfolio: - logger.debug(f"User has portfolios, redirecting to {home_organization_with_portfolio}") - return HttpResponseRedirect(home_organization_with_portfolio) + if current_path == self.home: + if has_organization_feature_flag: + if request.user.is_authenticated: + user_portfolios = Portfolio.objects.filter(creator=request.user) + if user_portfolios.exists(): + first_portfolio = user_portfolios.first() + home_organization_with_portfolio = reverse("organization-domains", kwargs={'portfolio_id': first_portfolio.id}) + + if current_path != home_organization_with_portfolio: + logger.debug(f"User has portfolios, redirecting to {home_organization_with_portfolio}") + return HttpResponseRedirect(home_organization_with_portfolio) return None diff --git a/src/registrar/templates/organization_sidebar.html b/src/registrar/templates/organization_sidebar.html index 35d9d5e95..4f2779816 100644 --- a/src/registrar/templates/organization_sidebar.html +++ b/src/registrar/templates/organization_sidebar.html @@ -7,12 +7,15 @@ {{ portfolio.organization_name }}
  • - + {% url 'organization-domains' portfolio.id as url %} + Domains +
  • - + {% url 'organization-domain-requests' portfolio.id as url %} + Domain requests
  • diff --git a/src/registrar/templates/home_organizations.html b/src/registrar/templates/organizations.html similarity index 99% rename from src/registrar/templates/home_organizations.html rename to src/registrar/templates/organizations.html index ba97ca292..b354fb1bf 100644 --- a/src/registrar/templates/home_organizations.html +++ b/src/registrar/templates/organizations.html @@ -30,7 +30,7 @@ Start a new domain request

    - --> + --> {% if content == 'domains' %} {% include "includes/domains_table.html" with portfolio=portfolio %} {% elif content == 'domain-requests' %} diff --git a/src/registrar/views/organizations.py b/src/registrar/views/organizations.py index 4a736e1f1..8f0578859 100644 --- a/src/registrar/views/organizations.py +++ b/src/registrar/views/organizations.py @@ -3,26 +3,6 @@ from registrar.models.portfolio import Portfolio from waffle.decorators import flag_is_active -def index_organizations(request, portfolio_id): - """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") - - # Retrieve the portfolio object based on the provided portfolio_id - portfolio = get_object_or_404(Portfolio, id=portfolio_id) - context["portfolio"] = portfolio - - # 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) - def organization_domains(request, portfolio_id): context = {} @@ -41,7 +21,7 @@ def organization_domains(request, portfolio_id): print('organization domains view') - return render(request, "home_organizations.html", context) + return render(request, "organizations.html", context) def organization_domain_requests(request, portfolio_id): context = {} @@ -61,4 +41,4 @@ def organization_domain_requests(request, portfolio_id): print('organization domain requests view') - return render(request, "home_organizations.html", context) \ No newline at end of file + return render(request, "organizations.html", context) \ No newline at end of file