Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to include over limit works #448

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ class Command(BaseCommand):

def add_arguments(self, parser):
parser.add_argument(
"--opp", type=int, required=True, help="ID of the opportunity to run auto-approval logic on"
"--opp",
type=int,
required=True,
help="ID of the opportunity to run auto-approval logic on",
)
parser.add_argument(
"--include-over-limit", action="store_true", help="Also run auto-approval logic on over limit works"
)

def handle(self, *args, opp: int, **options):
include_over_limit = options.get("include_over_limit", False)
excluded = [CompletedWorkStatus.rejected]
if not include_over_limit:
excluded.append(CompletedWorkStatus.over_limit)
try:
opportunity = Opportunity.objects.get(id=opp)
access_objects = OpportunityAccess.objects.filter(
opportunity=opportunity, suspended=False, opportunity__auto_approve_payments=True
)
for access in access_objects:
completed_works = access.completedwork_set.exclude(
status__in=[CompletedWorkStatus.rejected, CompletedWorkStatus.over_limit]
)
completed_works = access.completedwork_set.exclude(status__in=excluded)
update_status(completed_works, access, False)

self.stdout.write(self.style.SUCCESS(f"Successfully processed opportunity with id {opp}"))
Expand Down
Loading