Skip to content

Commit

Permalink
add filter on quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Aug 21, 2023
1 parent 4ff499b commit 213cb3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Send email for tender transactioned question to author

# Do not run if this env var is not set:
if [[ -z "$CRON_SEND_TENDER_AUTHOR_TRANSACTIONED_QUESTION_ENABLED" ]]; then
echo "CRON_SEND_TENDER_AUTHOR_TRANSACTIONED_QUESTION_ENABLED not set. Exiting..."
if [[ -z "$CRON_TENDER_SEND_AUTHOR_TRANSACTIONED_QUESTION_ENABLED" ]]; then
echo "CRON_TENDER_SEND_AUTHOR_TRANSACTIONED_QUESTION_ENABLED not set. Exiting..."
exit 0
fi

Expand All @@ -19,4 +19,4 @@ fi
# $APP_HOME is set by default by clever cloud.
cd $APP_HOME

django-admin send_author_transactioned_question_emails
django-admin send_author_transactioned_question_emails --kind QUOTE
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ class Command(BaseCommand):
Usage:
python manage.py send_author_transactioned_question_emails --dry-run
python manage.py send_author_transactioned_question_emails --all
python manage.py send_author_transactioned_question_emails --kind QUOTE
python manage.py send_author_transactioned_question_emails
"""

def add_arguments(self, parser):
parser.add_argument("--kind", type=str, dest="kind")
parser.add_argument("--dry-run", dest="dry_run", action="store_true", help="Dry run, no sends")
parser.add_argument(
"--all",
Expand All @@ -26,13 +29,15 @@ def add_arguments(self, parser):
help="Send to all tenders validated 30 days ago or more",
)

def handle(self, dry_run=False, is_all_tenders=False, **options):
def handle(self, kind=None, dry_run=False, is_all_tenders=False, **options):
self.stdout.write("-" * 80)
self.stdout.write("Script to send email feedback for tenders...")

self.stdout.write("-" * 80)
thirty_days_ago = datetime.today().date() - timedelta(days=30)
tenders_validated = Tender.objects.validated()
if kind:
tenders_validated = tenders_validated.filter(kind=kind)
if is_all_tenders:
# all tenders validated 30 days ago or more
tenders_for_feedbacks = tenders_validated.filter(validated_at__date__lte=thirty_days_ago)
Expand Down

0 comments on commit 213cb3a

Please sign in to comment.