-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make sure reviews are always planned Closes #39
- Loading branch information
Showing
5 changed files
with
53 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
from contextlib import suppress | ||
|
||
from django.apps import AppConfig | ||
from django.db import IntegrityError | ||
|
||
|
||
class ProfilesConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "leerming.profiles" | ||
|
||
def ready(self): | ||
from django_q.tasks import schedule | ||
from django.utils import timezone | ||
|
||
with timezone.override("UTC"): | ||
tomorrow = timezone.now().replace(hour=1, minute=0) | ||
|
||
with suppress(IntegrityError): | ||
schedule( | ||
"leerming.profiles.tasks.register_users_to_reviews", | ||
name="register_users_to_reviews", | ||
schedule_type="D", | ||
next_run=tomorrow, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from .models import Profile | ||
|
||
|
||
def register_users_to_reviews(): | ||
"""Make sure all users are registered to a review.""" | ||
|
||
for profile in Profile.objects.all(): | ||
profile.register_for_next_review() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters