Skip to content
Snippets Groups Projects
Commit 9832af02 authored by Jonas Braathen's avatar Jonas Braathen
Browse files

Add support for running a one-off role end notification, for debugging

parent 88a03127
No related branches found
No related tags found
1 merge request!404Role end notifier insight
"""
Command for scheduling the django-q task for notifying sponsors of
Command for scheduling or running the task for notifying sponsors of
expiring roles.
Instead of having a task that gets scheduled, we could have had a
management command that was run as a cronjob. However, that would mean
another cronjob
"""
import logging
import logging.config
from django.conf import settings
from django.core.management.base import BaseCommand
from django.core.management.base import BaseCommand, CommandParser
from django.db import transaction
from django_q.tasks import schedule
from greg.tasks import notify_sponsors_roles_ending
logging.config.dictConfig(settings.LOGGING)
logger = logging.getLogger(__name__)
class Command(BaseCommand):
help = "Schedule notification of sponsors"
help = __doc__
def add_arguments(self, parser: CommandParser) -> None:
parser.add_argument(
"--schedule",
default=False,
action="store_true",
help="Add a scheduled task for running the role end notifier",
)
parser.add_argument(
"--run-once",
default=False,
action="store_true",
help="Run the import once",
)
def handle(self, *args, **options):
if options["schedule"]:
self.schedule()
return
if options["run_once"]:
notify_sponsors_roles_ending()
return
logger.info("Nothing done")
def schedule(self, *args, **options):
logger.info("Scheduling role end notifier task...")
schedule(
func="greg.tasks.notify_sponsors_roles_ending",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment