Skip to content

Commit

Permalink
Moodle API via Cron
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoest committed Jan 10, 2025
1 parent 6281951 commit 03311d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions S1/waitinglists/management/commands/moodle_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.core.management.base import BaseCommand

import os
from dotenv import load_dotenv

from waitinglists.helpers import enrol_and_check_overrides

load_dotenv()


class Command(BaseCommand):
help = "Command running every minute to sign users up for moodle"

def handle(self, *args, **kwargs):
vids = os.listdir("/opt/s1/S1/db/moodle-signup")
if not vids:
return
vid = vids[0]
enrol_and_check_overrides(vid)
os.remove(f"/opt/s1/S1/db/moodle-signup/{vid}")
3 changes: 2 additions & 1 deletion cron_schedule
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0 0 * * * cd /opt/s1/S1 && python manage.py collect_signups
0 0 14 * * cd /opt/s1/S1 && python manage.py inform_renewal
0 0 14 * * cd /opt/s1/S1 && python manage.py inform_renewal
* * * * * cd /opt/s1/S1 && python manage.py moodle_api

0 comments on commit 03311d7

Please sign in to comment.