mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 10:29:23 +02:00
fix bug with registrar and basic redirect link stuff
This commit is contained in:
parent
ec7202b47c
commit
9bd67cfdbe
4 changed files with 36 additions and 7 deletions
|
@ -144,8 +144,15 @@ class CheckPortfolioMiddleware:
|
|||
if not request.user.is_authenticated:
|
||||
return None
|
||||
|
||||
# set the portfolio in the session if it is not set
|
||||
if "portfolio" not in request.session or request.session["portfolio"] is None:
|
||||
old_updated_at = None
|
||||
if request.session.get("portfolio"):
|
||||
old_updated_at = request.session.get("portfolio__updated_at")
|
||||
request.session["portfolio__updated_at"] = request.session.get("portfolio").updated_at
|
||||
|
||||
should_update_portfolio = (
|
||||
not request.session.get("portfolio") or old_updated_at != request.session.get("portfolio__updated_at")
|
||||
)
|
||||
if request.user.is_org_user(request) or should_update_portfolio:
|
||||
# if multiple portfolios are allowed for this user
|
||||
if flag_is_active(request, "multiple_portfolios"):
|
||||
# NOTE: we will want to change later to have a workflow for selecting
|
||||
|
@ -156,8 +163,8 @@ class CheckPortfolioMiddleware:
|
|||
else:
|
||||
request.session["portfolio"] = None
|
||||
|
||||
if request.session["portfolio"] is not None and current_path == self.home:
|
||||
if request.user.is_org_user(request):
|
||||
if request.session.get("portfolio"):
|
||||
if current_path == self.home:
|
||||
if request.user.has_domains_portfolio_permission(request.session["portfolio"]):
|
||||
portfolio_redirect = reverse("domains")
|
||||
else:
|
||||
|
|
|
@ -8,13 +8,26 @@
|
|||
{% block content %}
|
||||
<main id="main-content" class="grid-container">
|
||||
<div class="grid-col desktop:grid-offset-2 desktop:grid-col-8">
|
||||
<a href="{% url 'home' %}" class="breadcrumb__back">
|
||||
{% comment %}
|
||||
The back button should redirect to the domain request page if we are in the portfolio view.
|
||||
Otherwise, lets just redirect back to home.
|
||||
{% endcomment %}
|
||||
{% if portfolio %}
|
||||
{% url 'domain-requests' as url%}
|
||||
{% else %}
|
||||
{% url 'home' as url%}
|
||||
{% endif %}
|
||||
<a href="{{ url }}" class="breadcrumb__back">
|
||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
|
||||
<use xlink:href="{% static 'img/sprite.svg' %}#arrow_back"></use>
|
||||
</svg>
|
||||
|
||||
<p class="margin-left-05 margin-top-0 margin-bottom-0 line-height-sans-1">
|
||||
Back to manage your domains
|
||||
{% if portfolio %}
|
||||
Back to manage your domains requests
|
||||
{% else %}
|
||||
Back to manage your domains
|
||||
{% endif %}
|
||||
</p>
|
||||
</a>
|
||||
<h1>Domain request for {{ DomainRequest.requested_domain.name }}</h1>
|
||||
|
|
|
@ -152,7 +152,14 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
|||
except DomainRequest.DoesNotExist:
|
||||
logger.debug("DomainRequest id %s did not have a DomainRequest" % id)
|
||||
|
||||
self._domain_request = DomainRequest.objects.create(creator=self.request.user)
|
||||
# If a user is creating a request, we assume that perms are handled upstream
|
||||
if self.request.user.is_org_user(self.request):
|
||||
self._domain_request = DomainRequest.objects.create(
|
||||
creator=self.request.user,
|
||||
portfolio=self.request.session.get("portfolio"),
|
||||
)
|
||||
else:
|
||||
self._domain_request = DomainRequest.objects.create(creator=self.request.user)
|
||||
|
||||
self.storage["domain_request_id"] = self._domain_request.id
|
||||
return self._domain_request
|
||||
|
|
|
@ -47,6 +47,8 @@ def get_domain_requests_ids_from_request(request):
|
|||
"""
|
||||
portfolio = request.GET.get("portfolio")
|
||||
if portfolio:
|
||||
# Question:
|
||||
# Do we need to exclude started if the creator isn't the current request user
|
||||
domain_requests = DomainRequest.objects.filter(portfolio=portfolio).exclude(
|
||||
status=DomainRequest.DomainRequestStatus.APPROVED
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue