added crone jobs
This commit is contained in:
parent
9a17e14201
commit
cc8e07bc17
2 changed files with 27 additions and 23 deletions
|
@ -25,6 +25,7 @@ from models.Project import Project
|
|||
#Validation Utils Libs
|
||||
from SE_API.Validation_Utils import *
|
||||
from SE_API.Respones_Utils import *
|
||||
from Email_Utils import *
|
||||
|
||||
|
||||
task_routes = Blueprint("task_routes", __name__)
|
||||
|
@ -871,7 +872,7 @@ def sendTaskReminder():
|
|||
|
||||
tasks = Task.all()
|
||||
|
||||
#go over all the courses
|
||||
try:
|
||||
for t in tasks.run():
|
||||
if t.dueDate == datetime.date.today() + datetime.timedelta(days=1):
|
||||
course = Course.get_by_id(int(t.courseId))
|
||||
|
@ -879,22 +880,22 @@ def sendTaskReminder():
|
|||
for uId in course.membersId:
|
||||
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
|
||||
if tc.count() == 0:
|
||||
#SEND MAIL!! TODO
|
||||
user = User.get_by_id(int(uId))
|
||||
send_task_reminder(user.email, user.name, t.title, course.courseName)
|
||||
print ""
|
||||
|
||||
else:
|
||||
projects = Project.all().filter("courseId = ", course.key().id())
|
||||
for p in projects:
|
||||
for p in projects.run():
|
||||
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", p.key().id())
|
||||
if tc.count() == 0:
|
||||
#SEND MAIL!! TODO
|
||||
print ""
|
||||
for uId in p.membersId:
|
||||
user = User.get_by_id(int(uId))
|
||||
send_task_reminder(user.email, user.name, t.title, course.courseName)
|
||||
return accepted()
|
||||
|
||||
|
||||
|
||||
#go over all
|
||||
|
||||
return accepted("Task deleted")
|
||||
except:
|
||||
return bad_request()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,3 +2,6 @@ cron:
|
|||
- description: update project data
|
||||
url: /api/projects/updateProjectsInfo
|
||||
schedule: every 1 hours
|
||||
- description: send task notification mail
|
||||
url: /api/tasks/sendTaskReminder
|
||||
schedule: every day 03:00
|
Loading…
Reference in a new issue