Make it possible to convert prices automatically
This commit is contained in:
24
games/management/commands/schedule_update_task.py
Normal file
24
games/management/commands/schedule_update_task.py
Normal file
@ -0,0 +1,24 @@
|
||||
from datetime import timedelta
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.timezone import now
|
||||
from django_q.models import Schedule
|
||||
from django_q.tasks import schedule
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Manually schedule the next update_converted_prices task"
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
if not Schedule.objects.filter(name="Update converted prices").exists():
|
||||
schedule(
|
||||
"games.tasks.update_converted_prices",
|
||||
name="Update converted prices",
|
||||
schedule_type="D",
|
||||
next_run=now() + timedelta(days=1),
|
||||
)
|
||||
self.stdout.write(
|
||||
self.style.SUCCESS("Scheduled the update_converted_prices task.")
|
||||
)
|
||||
else:
|
||||
self.stdout.write(self.style.WARNING("Task is already scheduled."))
|
Reference in New Issue
Block a user