From 9bd67cfdbe2cf7c2034355a1fe18873019edade4 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:38:16 -0600 Subject: [PATCH 1/4] fix bug with registrar and basic redirect link stuff --- src/registrar/registrar_middleware.py | 15 +++++++++++---- .../templates/domain_request_status.html | 17 +++++++++++++++-- src/registrar/views/domain_request.py | 9 ++++++++- src/registrar/views/domain_requests_json.py | 2 ++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index 4b590db1e..3ce6fde5d 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -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: diff --git a/src/registrar/templates/domain_request_status.html b/src/registrar/templates/domain_request_status.html index 183a8be81..40722c41e 100644 --- a/src/registrar/templates/domain_request_status.html +++ b/src/registrar/templates/domain_request_status.html @@ -8,13 +8,26 @@ {% block content %}
- + {% 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 %} +

- Back to manage your domains + {% if portfolio %} + Back to manage your domains requests + {% else %} + Back to manage your domains + {% endif %}

Domain request for {{ DomainRequest.requested_domain.name }}

diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index b691549cd..fbadeb51e 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -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 diff --git a/src/registrar/views/domain_requests_json.py b/src/registrar/views/domain_requests_json.py index 6eefe02fc..85e46b261 100644 --- a/src/registrar/views/domain_requests_json.py +++ b/src/registrar/views/domain_requests_json.py @@ -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 ) From d802b9a614faef2f42edc61162b22c5e0ab81833 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 5 Sep 2024 15:01:37 -0400 Subject: [PATCH 2/4] Add created by column --- src/registrar/assets/js/get-gov.js | 16 +++++++++++++--- .../includes/domain_requests_table.html | 3 +++ src/registrar/views/domain_requests_json.py | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 33e6ed384..fd4b3f941 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -1611,6 +1611,16 @@ document.addEventListener('DOMContentLoaded', function() { // Even if the request is not deletable, we may need these empty strings for the td if the deletable column is displayed let modalTrigger = ''; + let markupCreatorRow = ''; + + if (portfolioValue) { + markupCreatorRow = ` + + ${request.creator ? request.creator : ''} + + ` + } + // If the request is deletable, create modal body and insert it. This is true for both requests and portfolio requests pages if (request.is_deletable) { let modalHeading = ''; @@ -1634,7 +1644,7 @@ document.addEventListener('DOMContentLoaded', function() { role="button" id="button-toggle-delete-domain-alert-${request.id}" href="#toggle-delete-domain-alert-${request.id}" - class="usa-button--unstyled text-no-underline late-loading-modal-trigger" + class="usa-button usa-button--unstyled text-no-underline late-loading-modal-trigger" aria-controls="toggle-delete-domain-alert-${request.id}" data-open-modal > @@ -1707,7 +1717,7 @@ document.addEventListener('DOMContentLoaded', function() {
" @@ -418,6 +422,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): You’ll only be able to withdraw your request.", "review_form_is_complete": True, "user": self.request.user, + "requested_domain__name": requested_domain_name, } else: # form is not complete modal_button = '' @@ -433,6 +438,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): Return to the request and visit the steps that are marked as "incomplete."', "review_form_is_complete": False, "user": self.request.user, + "requested_domain__name": requested_domain_name, } return context_stuff @@ -512,7 +518,10 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): # if user opted to save progress and return, # return them to the home page if button == "save_and_return": - return HttpResponseRedirect(reverse("home")) + if request.user.is_org_user(request): + return HttpResponseRedirect(reverse("domain-requests")) + else: + return HttpResponseRedirect(reverse("home")) # otherwise, proceed as normal return self.goto_next_step() @@ -781,7 +790,10 @@ class DomainRequestWithdrawn(DomainRequestPermissionWithdrawView): domain_request = DomainRequest.objects.get(id=self.kwargs["pk"]) domain_request.withdraw() domain_request.save() - return HttpResponseRedirect(reverse("home")) + if self.request.user.is_org_user(self.request): + return HttpResponseRedirect(reverse("domain-requests")) + else: + return HttpResponseRedirect(reverse("home")) class DomainRequestDeleteView(DomainRequestPermissionDeleteView): From 9ea0f312fca798eb5cd92154af1c4f4fb51214b3 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Thu, 5 Sep 2024 15:36:08 -0400 Subject: [PATCH 4/4] CSS tweaks --- src/registrar/assets/js/get-gov.js | 6 +++--- src/registrar/assets/sass/_theme/_base.scss | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index fd4b3f941..734e7918d 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -1616,7 +1616,7 @@ document.addEventListener('DOMContentLoaded', function() { if (portfolioValue) { markupCreatorRow = ` - ${request.creator ? request.creator : ''} + ${request.creator ? request.creator : ''} ` } @@ -1644,7 +1644,7 @@ document.addEventListener('DOMContentLoaded', function() { role="button" id="button-toggle-delete-domain-alert-${request.id}" href="#toggle-delete-domain-alert-${request.id}" - class="usa-button usa-button--unstyled text-no-underline late-loading-modal-trigger" + class="usa-button text-secondary usa-button--unstyled text-no-underline late-loading-modal-trigger" aria-controls="toggle-delete-domain-alert-${request.id}" data-open-modal > @@ -1732,7 +1732,7 @@ document.addEventListener('DOMContentLoaded', function() { role="button" id="button-toggle-delete-domain-alert-${request.id}" href="#toggle-delete-domain-alert-${request.id}" - class="usa-button--unstyled text-no-underline late-loading-modal-trigger" + class="usa-button text-secondary usa-button--unstyled text-no-underline late-loading-modal-trigger" aria-controls="toggle-delete-domain-alert-${request.id}" data-open-modal > diff --git a/src/registrar/assets/sass/_theme/_base.scss b/src/registrar/assets/sass/_theme/_base.scss index 7df783604..4ea9d2054 100644 --- a/src/registrar/assets/sass/_theme/_base.scss +++ b/src/registrar/assets/sass/_theme/_base.scss @@ -204,3 +204,7 @@ abbr[title] { .left-auto { left: auto!important; } + +.break-word { + word-break: break-word; +}