Skip to content
Snippets Groups Projects
Verified Commit c1887a02 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Add send_notification to tasks.py and fix usage

parent a7fc15ef
No related branches found
No related tags found
1 merge request!209Fix celery config
......@@ -14,8 +14,8 @@ from phonenumber_field.modelfields import PhoneNumberField
from polymorphic.models import PolymorphicModel
from .mixins import ExtensibleModel, PureDjangoModel
from .tasks import send_notification
from .util.core_helpers import now_tomorrow
from .util.notifications import send_notification
from .util.model_helpers import ICONS
from constance import config
......@@ -276,7 +276,8 @@ class Notification(ExtensibleModel):
return str(self.title)
def save(self, **kwargs):
send_notification(self)
if not self.sent:
send_notification(self.pk, resend=True)
self.sent = True
super().save(**kwargs)
......
from .util.core_helpers import celery_optional
from .util.notifications import send_notification as _send_notification
@celery_optional
def send_notification(notification: int, resend: bool = False) -> None:
_send_notification(notification, resend)
......@@ -68,7 +68,6 @@ _CHANNELS_MAP = {
}
@celery_optional
def send_notification(notification: Union[int, "Notification"], resend: bool = False) -> None:
""" Send a notification through enabled channels.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment