By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 celery_tasks.py

View raw Download
text/x-script.python • 442 B
Python script, ASCII text executable
        
            
1
import time
2
from celery import shared_task
3
from app import db
4
from models import *
5
6
7
@shared_task(ignore_result=False)
8
def send_notification(notification_id, users, level):
9
notification = db.session.get(Notification, notification_id)
10
11
for user in users:
12
db.session.add(UserNotification(db.session.get(User, user), notification, level))
13
db.session.commit()
14
15
return 0 # notification sent successfully
16