Skip to content

feat(allocation): add --not-renewed-only flag to send_allowance_renewal_available_emails - #828

Open
matthew-li wants to merge 2 commits into
developfrom
feat/renewal-emails-not-renewed-only
Open

feat(allocation): add --not-renewed-only flag to send_allowance_renewal_available_emails#828
matthew-li wants to merge 2 commits into
developfrom
feat/renewal-emails-not-renewed-only

Conversation

@matthew-li

@matthew-li matthew-li commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a --not-renewed-only flag to the send_allowance_renewal_available_emails management command. When set, the command restricts emails to active projects that have not yet submitted a non-denied (Under Review, Approved, or Complete) renewal request for the upcoming allowance year.

Why

The command is typically run once at the start of the renewal window to announce that renewals are open. A mid-month reminder pass is useful, but should only target PIs who still haven't acted — not re-notify those who have already renewed. The new flag enables that use case.

Changes

  • send_allowance_renewal_available_emails: adds --not-renewed-only argparse flag; passes it through to AllowanceRenewalAvailableEmailSender.
  • AllowanceRenewalAvailableEmailSender: adds not_renewed_only=False constructor parameter; _get_eligible_projects() excludes projects that are the pre_project of any non-denied AllocationRenewalRequest for the next period when the flag is set. (Projects whose PI submitted a new project request instead of renewing are not excluded — that case is rare enough in practice to not warrant the added complexity.)
  • New tests (Django TestCase, BRC + LRC mixin pattern):
    • test_allowance_renewal_available_email_sender.py — unit-level tests for _get_eligible_projects() and run().
    • test_send_allowance_renewal_available_emails.py — command-level tests covering --dry_run, --not-renewed-only, wet-run confirmation, and cancellation.

Test plan

  • Run BRC command tests: python manage.py test coldfront.core.allocation.tests.test_commands.test_send_allowance_renewal_available_emails.TestSendAllowanceRenewalAvailableEmailsBRC
  • Run LRC command tests: python manage.py test coldfront.core.allocation.tests.test_commands.test_send_allowance_renewal_available_emails.TestSendAllowanceRenewalAvailableEmailsLRC
  • Run BRC sender tests: python manage.py test coldfront.core.project.tests.test_utils.test_renewal_utils.test_allowance_renewal_available_email_sender.TestAllowanceRenewalAvailableEmailSenderBRC
  • Run LRC sender tests: python manage.py test coldfront.core.project.tests.test_utils.test_renewal_utils.test_allowance_renewal_available_email_sender.TestAllowanceRenewalAvailableEmailSenderLRC

…al_available_emails

Add a --not-renewed-only option that restricts the recipient set to
active projects that have not yet submitted a non-denied renewal request
for the upcoming allowance year. Intended for mid-month reminder runs.
Also adds Django TestCase tests (BRC + LRC variants) for both the
AllowanceRenewalAvailableEmailSender class and the management command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@matthew-li
matthew-li changed the base branch from master to develop August 24, 2026 18:45
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  coldfront/core/allocation/management/commands
  send_allowance_renewal_available_emails.py
  coldfront/core/project/utils_
  renewal_utils.py 278, 757
Project Total  

This report was generated by python-coverage-comment-action

CI generates a BRC env file. LRCTestBase.setUpClass enables LRC only
long enough to run setup commands, then reverts. Without re-enabling
LRC for each test method, flag checks in setUp and in the management
command raise DoesNotExist / ImproperlyConfigured. Follow the existing
pattern of wrapping per-test state with enable_deployment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant