Merge pull request #140 from sagidayan/API_Dev

Api dev
This commit is contained in:
Sagi Dayan 2015-08-02 17:43:50 +03:00
commit b6f4fbc9e0
3 changed files with 39 additions and 3 deletions

View file

@ -377,10 +377,10 @@ def deleteProject(token,projectId):
#remove all users related to project
for uId in p.membersId:
user = User.get_by_id(uId)
user = User.get_by_id(int(uId))
if user is None:
return bad_request("trying to remove a user from project failed")
user.projects_id_list.remove(p.key().id())
user.projects_id_list.remove(str(p.key().id()))
db.put(user)

View file

@ -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__)
@ -866,6 +867,38 @@ def documentation():
return auto.html()
@task_routes.route('/api/tasks/sendTaskReminder', methods=['GET'])
def sendTaskReminder():
tasks = Task.all()
try:
for t in tasks.run():
if t.dueDate == datetime.date.today() + datetime.timedelta(days=1):
course = Course.get_by_id(int(t.courseId))
if t.isPersonal:
for uId in course.membersId:
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", int(uId))
if tc.count() == 0:
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.run():
tc = TaskComponent.all().filter("taskId = ", t.key().id()).filter("userId = ", p.key().id())
if tc.count() == 0:
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()
except:
return bad_request()

View file

@ -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