The prolong command.
[wolnelektury.git] / src / club / management / commands / prolong.py
diff --git a/src/club/management/commands/prolong.py b/src/club/management/commands/prolong.py
new file mode 100644 (file)
index 0000000..9bc5e68
--- /dev/null
@@ -0,0 +1,12 @@
+from datetime import timedelta
+from django.core.management.base import BaseCommand, CommandError
+from django.utils.timezone import now
+from club.models import Schedule
+
+
+class Command(BaseCommand):
+    def handle(self, *args, **options):
+        for s in Schedule.objects.filter(is_cancelled=False, expires_at__lt=now() + timedelta(1)):
+            print(s, s.email, s.expires_at)
+            s.pay(None)
+