mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-05 17:28:31 +02:00
additional views added
This commit is contained in:
parent
f2c3c320e9
commit
bd2ad797cf
6 changed files with 91 additions and 31 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.index_organizations import index_organizations
|
||||
from registrar.views.organizations import index_organizations, organization_domains, organization_domain_requests
|
||||
from api.views import available, get_current_federal, get_current_full
|
||||
|
||||
|
||||
|
@ -64,6 +64,16 @@ urlpatterns = [
|
|||
index_organizations,
|
||||
name="home-organization",
|
||||
),
|
||||
path(
|
||||
"organization/<int:portfolio_id>/domains/",
|
||||
organization_domains,
|
||||
name="organization-domains",
|
||||
),
|
||||
path(
|
||||
"organization/<int:portfolio_id>/domain_requests/",
|
||||
organization_domain_requests,
|
||||
name="organization-domain-requests",
|
||||
),
|
||||
path(
|
||||
"admin/logout/",
|
||||
RedirectView.as_view(pattern_name="logout", permanent=False),
|
||||
|
|
|
@ -142,8 +142,8 @@ class CheckOrganizationMiddleware:
|
|||
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'):
|
||||
logger.debug("Skipping middleware check for home-organization and 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")
|
||||
|
@ -154,7 +154,7 @@ class CheckOrganizationMiddleware:
|
|||
user_portfolios = Portfolio.objects.filter(creator=request.user)
|
||||
if user_portfolios.exists():
|
||||
first_portfolio = user_portfolios.first()
|
||||
home_organization_with_portfolio = reverse("home-organization", kwargs={'portfolio_id': first_portfolio.id})
|
||||
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}")
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="tablet:grid-col-12">
|
||||
<div class="grid-row grid-gap">
|
||||
<div class="tablet:grid-col-3">
|
||||
{% include "organization_sidebar.html" %}
|
||||
{% include "organization_sidebar.html" with portfolio=portfolio current_path=content %}
|
||||
</div>
|
||||
<div class="tablet:grid-col-9">
|
||||
{% block messages %}
|
||||
|
@ -26,9 +26,11 @@
|
|||
Start a new domain request
|
||||
</a>
|
||||
</p>
|
||||
|
||||
{% include "includes/domains_table.html" %}
|
||||
{% include "includes/domain_requests_table.html" %}
|
||||
{% if content == 'domains' %}
|
||||
{% include "includes/domains_table.html" with portfolio=portfolio %}
|
||||
{% elif content == 'domain-requests' %}
|
||||
{% include "includes/domain_requests_table.html" with portfolio=portfolio %}
|
||||
{% endif %}
|
||||
|
||||
{# Note: Reimplement this after MVP #}
|
||||
<!--
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
<nav aria-label="">
|
||||
<ul class="usa-sidenav">
|
||||
<li class="usa-sidenav__item">
|
||||
<a href="#">
|
||||
link 1
|
||||
{{ portfolio.organization_name }}
|
||||
</li>
|
||||
<li class="usa-sidenav__item">
|
||||
<a href="{% url 'organization-domains' portfolio.id %}" class="{% if current_path == 'domains' %}usa-current{% endif %}">
|
||||
Domains
|
||||
</a>
|
||||
</li>
|
||||
<li class="usa-sidenav__item">
|
||||
<a href="#">
|
||||
link 2
|
||||
<a href="{% url 'organization-domain-requests' portfolio.id %}" class="{% if current_path == 'domain-requests' %}usa-current{% endif %}">
|
||||
Domain requests
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
from django.shortcuts import render
|
||||
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")
|
||||
|
||||
# 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)
|
64
src/registrar/views/organizations.py
Normal file
64
src/registrar/views/organizations.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
from django.shortcuts import get_object_or_404, render
|
||||
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 = {}
|
||||
|
||||
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
|
||||
context["content"] = "domains"
|
||||
|
||||
# This controls the creation of a new domain request in the wizard
|
||||
request.session["new_request"] = True
|
||||
|
||||
print('organization domains view')
|
||||
|
||||
return render(request, "home_organizations.html", context)
|
||||
|
||||
def organization_domain_requests(request, portfolio_id):
|
||||
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
|
||||
context["content"] = "domain-requests"
|
||||
|
||||
# This controls the creation of a new domain request in the wizard
|
||||
request.session["new_request"] = True
|
||||
|
||||
print('organization domain requests view')
|
||||
|
||||
return render(request, "home_organizations.html", context)
|
Loading…
Add table
Add a link
Reference in a new issue