This commit is contained in:
David Kennedy 2024-06-20 11:27:20 -04:00
parent 94aa2a0e19
commit 300e305c00
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
5 changed files with 20 additions and 48 deletions

View file

@ -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.domain_requests_json import get_domain_requests_json
from registrar.views.domains_json import get_domains_json from registrar.views.domains_json import get_domains_json
from registrar.views.utility import always_404 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 from api.views import available, get_current_federal, get_current_full
@ -59,11 +59,6 @@ for step, view in [
urlpatterns = [ urlpatterns = [
path("", views.index, name="home"), path("", views.index, name="home"),
path(
"organization/<int:portfolio_id>/",
index_organizations,
name="home-organization",
),
path( path(
"organization/<int:portfolio_id>/domains/", "organization/<int:portfolio_id>/domains/",
organization_domains, organization_domains,

View file

@ -130,8 +130,6 @@ class CheckOrganizationMiddleware:
def __init__(self, get_response): def __init__(self, get_response):
self.get_response = get_response self.get_response = get_response
self.home = reverse("home") self.home = reverse("home")
self.json1 = reverse("get_domains_json")
self.json2 = reverse("get_domain_requests_json")
def __call__(self, request): def __call__(self, request):
response = self.get_response(request) response = self.get_response(request)
@ -141,14 +139,10 @@ class CheckOrganizationMiddleware:
current_path = request.path current_path = request.path
logger.debug(f"Current path: {current_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") has_organization_feature_flag = flag_is_active(request, "organization_feature")
logger.debug(f"Flag is active: {has_organization_feature_flag}") logger.debug(f"Flag is active: {has_organization_feature_flag}")
if current_path == self.home:
if has_organization_feature_flag: if has_organization_feature_flag:
if request.user.is_authenticated: if request.user.is_authenticated:
user_portfolios = Portfolio.objects.filter(creator=request.user) user_portfolios = Portfolio.objects.filter(creator=request.user)

View file

@ -7,12 +7,15 @@
{{ portfolio.organization_name }} {{ portfolio.organization_name }}
</li> </li>
<li class="usa-sidenav__item"> <li class="usa-sidenav__item">
<a href="{% url 'organization-domains' portfolio.id %}" class="{% if current_path == 'domains' %}usa-current{% endif %}"> {% url 'organization-domains' portfolio.id as url %}
<a href="{{ url }}" {% if request.path == url %}class="usa-current"{% endif %}>
Domains Domains
</a> </a>
</li> </li>
<li class="usa-sidenav__item"> <li class="usa-sidenav__item">
<a href="{% url 'organization-domain-requests' portfolio.id %}" class="{% if current_path == 'domain-requests' %}usa-current{% endif %}"> {% url 'organization-domain-requests' portfolio.id as url %}
<a href="{{ url }}" {% if request.path == url %}class="usa-current"{% endif %}>
Domain requests Domain requests
</a> </a>
</li> </li>

View file

@ -3,26 +3,6 @@ from registrar.models.portfolio import Portfolio
from waffle.decorators import flag_is_active 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): def organization_domains(request, portfolio_id):
context = {} context = {}
@ -41,7 +21,7 @@ def organization_domains(request, portfolio_id):
print('organization domains view') print('organization domains view')
return render(request, "home_organizations.html", context) return render(request, "organizations.html", context)
def organization_domain_requests(request, portfolio_id): def organization_domain_requests(request, portfolio_id):
context = {} context = {}
@ -61,4 +41,4 @@ def organization_domain_requests(request, portfolio_id):
print('organization domain requests view') print('organization domain requests view')
return render(request, "home_organizations.html", context) return render(request, "organizations.html", context)