From f4db3b2592d2808a2c6c67b801199e9383c5206d Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Fri, 7 Mar 2025 11:31:45 -0700 Subject: [PATCH] Battle of the linter circa 2025 --- src/registrar/decorators.py | 21 ++++++++++++++------- src/registrar/tests/test_resource_access.py | 2 -- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/registrar/decorators.py b/src/registrar/decorators.py index 93d0c0fe1..36d23e4a2 100644 --- a/src/registrar/decorators.py +++ b/src/registrar/decorators.py @@ -233,50 +233,57 @@ def _is_domain_manager(user, **kwargs): def _domain_exists_under_portfolio(portfolio, domain_pk): - """Checks to see if the given domain exists under the provided portfolio. Returns True if the pk is None. + """Checks to see if the given domain exists under the provided portfolio. HELPFUL REMINDER: Watch for typos! Verify that the kwarg key exists before using this function. + Returns True if the pk is None. Otherwise, returns a bool if said object exists. """ # The view expects this, and the page will throw an error without this if it needs it. # Thus, if it is none, we are not checking on a specific record and therefore there is nothing to check. if not domain_pk: logger.info( - "_domain_exists_under_portfolio => Could not find domain_pk. This is a non-issue if called from the right context." + "_domain_exists_under_portfolio => Could not find domain_pk. " + "This is a non-issue if called from the right context." ) return True return Domain.objects.filter(domain_info__portfolio=portfolio, id=domain_pk).exists() def _domain_request_exists_under_portfolio(portfolio, domain_request_pk): - """Checks to see if the given domain request exists under the provided portfolio. Returns True if the pk is None. + """Checks to see if the given domain request exists under the provided portfolio. HELPFUL REMINDER: Watch for typos! Verify that the kwarg key exists before using this function. + Returns True if the pk is None. Otherwise, returns a bool if said object exists. """ # The view expects this, and the page will throw an error without this if it needs it. # Thus, if it is none, we are not checking on a specific record and therefore there is nothing to check. if not domain_request_pk: logger.info( - "_domain_request_exists_under_portfolio => Could not find domain_request_pk. This is a non-issue if called from the right context." + "_domain_request_exists_under_portfolio => Could not find domain_request_pk. " + "This is a non-issue if called from the right context." ) return True return DomainRequest.objects.filter(portfolio=portfolio, id=domain_request_pk).exists() def _member_exists_under_portfolio(portfolio, member_pk): - """Checks to see if the given UserPortfolioPermission exists under the provided portfolio. Returns True if the pk is None. + """Checks to see if the given UserPortfolioPermission exists under the provided portfolio. HELPFUL REMINDER: Watch for typos! Verify that the kwarg key exists before using this function. + Returns True if the pk is None. Otherwise, returns a bool if said object exists. """ # The view expects this, and the page will throw an error without this if it needs it. # Thus, if it is none, we are not checking on a specific record and therefore there is nothing to check. if not member_pk: logger.info( - "_member_exists_under_portfolio => Could not find member_pk. This is a non-issue if called from the right context." + "_member_exists_under_portfolio => Could not find member_pk. " + "This is a non-issue if called from the right context." ) return True return UserPortfolioPermission.objects.filter(portfolio=portfolio, id=member_pk).exists() def _member_invitation_exists_under_portfolio(portfolio, invitedmember_pk): - """Checks to see if the given PortfolioInvitation exists under the provided portfolio. Returns True if the pk is None. + """Checks to see if the given PortfolioInvitation exists under the provided portfolio. HELPFUL REMINDER: Watch for typos! Verify that the kwarg key exists before using this function. + Returns True if the pk is None. Otherwise, returns a bool if said object exists. """ # The view expects this, and the page will throw an error without this if it needs it. # Thus, if it is none, we are not checking on a specific record and therefore there is nothing to check. diff --git a/src/registrar/tests/test_resource_access.py b/src/registrar/tests/test_resource_access.py index 6e8d168e2..cf8f1c933 100644 --- a/src/registrar/tests/test_resource_access.py +++ b/src/registrar/tests/test_resource_access.py @@ -8,12 +8,10 @@ from registrar.tests.common import ( completed_domain_request, ) from registrar.models import ( - Domain, DomainRequest, Portfolio, UserPortfolioPermission, PortfolioInvitation, - User, ) from registrar.models.utility.portfolio_helper import ( UserPortfolioRoleChoices,