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
|
#Validation Utils Libs
|
||||||
from SE_API.Validation_Utils import *
|
from SE_API.Validation_Utils import *
|
||||||
from SE_API.Respones_Utils import *
|
from SE_API.Respones_Utils import *
|
||||||
|
from Email_Utils import *
|
||||||
|
|
||||||
|
|
||||||
task_routes = Blueprint("task_routes", __name__)
|
task_routes = Blueprint("task_routes", __name__)
|
||||||
|
@ -871,30 +872,30 @@ def sendTaskReminder():
|
||||||
|
|
||||||
tasks = Task.all()
|
tasks = Task.all()
|
||||||
|
|
||||||
#go over all the courses
|
try:
|
||||||
for t in tasks.run():
|
for t in tasks.run():
|
||||||
if t.dueDate == datetime.date.today() + datetime.timedelta(days=1):
|
if t.dueDate == datetime.date.today() + datetime.timedelta(days=1):
|
||||||
course = Course.get_by_id(int(t.courseId))
|
course = Course.get_by_id(int(t.courseId))
|
||||||
if t.isPersonal:
|
if t.isPersonal:
|
||||||
for uId in course.membersId:
|
for uId in course.membersId:
|
||||||
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
|
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
|
||||||
if tc.count() == 0:
|
if tc.count() == 0:
|
||||||
#SEND MAIL!! TODO
|
user = User.get_by_id(int(uId))
|
||||||
print ""
|
send_task_reminder(user.email, user.name, t.title, course.courseName)
|
||||||
|
print ""
|
||||||
|
|
||||||
else:
|
else:
|
||||||
projects = Project.all().filter("courseId = ", course.key().id())
|
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())
|
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", p.key().id())
|
||||||
if tc.count() == 0:
|
if tc.count() == 0:
|
||||||
#SEND MAIL!! TODO
|
for uId in p.membersId:
|
||||||
print ""
|
user = User.get_by_id(int(uId))
|
||||||
|
send_task_reminder(user.email, user.name, t.title, course.courseName)
|
||||||
|
return accepted()
|
||||||
|
|
||||||
|
except:
|
||||||
|
return bad_request()
|
||||||
#go over all
|
|
||||||
|
|
||||||
return accepted("Task deleted")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
cron:
|
cron:
|
||||||
- description: update project data
|
- description: update project data
|
||||||
url: /api/projects/updateProjectsInfo
|
url: /api/projects/updateProjectsInfo
|
||||||
schedule: every 1 hours
|
schedule: every 1 hours
|
||||||
|
- description: send task notification mail
|
||||||
|
url: /api/tasks/sendTaskReminder
|
||||||
|
schedule: every day 03:00
|
Loading…
Reference in a new issue