mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-23 11:16:07 +02:00
Battle of the linter circa 2025
This commit is contained in:
parent
cc08b18bdd
commit
f4db3b2592
2 changed files with 14 additions and 9 deletions
|
@ -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.
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue