mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-16 06:24:12 +02:00
Fix the logic for in progress user within a portfolio
This commit is contained in:
parent
cd517ae885
commit
6bf34c8d3b
1 changed files with 9 additions and 7 deletions
|
@ -475,11 +475,13 @@ class User(AbstractUser):
|
||||||
|
|
||||||
def get_active_requests_count_in_portfolio(self, request):
|
def get_active_requests_count_in_portfolio(self, request):
|
||||||
"""Return count of active requests for the portfolio associated with the request."""
|
"""Return count of active requests for the portfolio associated with the request."""
|
||||||
portfolio_id = request.session.get(
|
# Get the portfolio from the session using the existing method
|
||||||
"portfolio_id"
|
|
||||||
) # Adjust based on how you store the portfolio ID in the session
|
portfolio = request.session.get("portfolio")
|
||||||
if not portfolio_id:
|
print(f"Portfolio from session: {portfolio}")
|
||||||
return 0 # No portfolio ID found
|
|
||||||
|
if not portfolio:
|
||||||
|
return 0 # No portfolio found
|
||||||
|
|
||||||
allowed_states = [
|
allowed_states = [
|
||||||
DomainRequest.DomainRequestStatus.SUBMITTED,
|
DomainRequest.DomainRequestStatus.SUBMITTED,
|
||||||
|
@ -487,9 +489,9 @@ class User(AbstractUser):
|
||||||
DomainRequest.DomainRequestStatus.ACTION_NEEDED,
|
DomainRequest.DomainRequestStatus.ACTION_NEEDED,
|
||||||
]
|
]
|
||||||
|
|
||||||
# Assuming you have a way to filter domain requests by portfolio
|
# Now filter based on the portfolio retrieved
|
||||||
active_requests_count = self.domain_requests_created.filter(
|
active_requests_count = self.domain_requests_created.filter(
|
||||||
status__in=allowed_states, portfolio__id=portfolio_id # Ensure this field exists on the DomainRequest model
|
status__in=allowed_states, portfolio=portfolio
|
||||||
).count()
|
).count()
|
||||||
|
|
||||||
return active_requests_count
|
return active_requests_count
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue