-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from dimagi/pkv/push-notification-messages
Push notification messages
- Loading branch information
Showing
7 changed files
with
241 additions
and
12 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...re_connect/opportunity/migrations/0026_create_send_inactive_notification_periodic_task.py
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,38 @@ | ||
# Generated by Django 4.2.5 on 2023-11-02 09:09 | ||
|
||
from django.db import migrations | ||
from django_celery_beat.models import PeriodicTask, CrontabSchedule | ||
|
||
|
||
def create_send_inactive_notification_periodic_task(apps, schema_editor): | ||
schedule, _ = CrontabSchedule.objects.get_or_create( | ||
minute="00", | ||
hour="7", | ||
day_of_week="*", | ||
day_of_month="*", | ||
month_of_year="*", | ||
) | ||
PeriodicTask.objects.update_or_create( | ||
crontab=schedule, | ||
name="send_inactive_notifications", | ||
task="commcare_connect.opportunity.task.send_notification_inactive_users", | ||
) | ||
|
||
|
||
def delete_send_inactive_notification_periodic_task(apps, schema_editor): | ||
PeriodicTask.objects.get( | ||
name="send_inactive_notifications", | ||
task="commcare_connect.opportunity.task.send_notification_inactive_users", | ||
).delete() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("opportunity", "0025_opportunity_short_description"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
create_send_inactive_notification_periodic_task, delete_send_inactive_notification_periodic_task | ||
) | ||
] |
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
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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import datetime | ||
|
||
from django.utils.timezone import now | ||
|
||
|
||
def is_date_before(date: datetime.datetime, days: int): | ||
before_date = now() - datetime.timedelta(days=days) | ||
return date.date() == before_date.date() |