mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-20 09:46:06 +02:00
cleanup
This commit is contained in:
parent
94aa2a0e19
commit
300e305c00
5 changed files with 20 additions and 48 deletions
|
@ -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/<int:portfolio_id>/",
|
||||
index_organizations,
|
||||
name="home-organization",
|
||||
),
|
||||
path(
|
||||
"organization/<int:portfolio_id>/domains/",
|
||||
organization_domains,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -7,12 +7,15 @@
|
|||
{{ portfolio.organization_name }}
|
||||
</li>
|
||||
<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
|
||||
</a>
|
||||
|
||||
</li>
|
||||
<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
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
Start a new domain request
|
||||
</a>
|
||||
</p>
|
||||
-->
|
||||
-->
|
||||
{% if content == 'domains' %}
|
||||
{% include "includes/domains_table.html" with portfolio=portfolio %}
|
||||
{% elif content == 'domain-requests' %}
|
|
@ -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)
|
||||
return render(request, "organizations.html", context)
|
Loading…
Add table
Add a link
Reference in a new issue