diff --git a/SE_API/API.py b/SE_API/API.py
index 387ba41..136e6b0 100644
--- a/SE_API/API.py
+++ b/SE_API/API.py
@@ -29,6 +29,7 @@ from SE_API.UserRoutes import user_routes
from SE_API.CampusRoutes import campus_routes
from SE_API.CourseRoutes import course_routes
from SE_API.ProjectRoutes import project_routes
+from SE_API.TaskRoutes import task_routes
@@ -49,6 +50,7 @@ app.register_blueprint(user_routes)
app.register_blueprint(campus_routes)
app.register_blueprint(course_routes)
app.register_blueprint(project_routes)
+app.register_blueprint(task_routes)
auto = Autodoc(app)
diff --git a/SE_API/CampusRoutes.py b/SE_API/CampusRoutes.py
index c52fe9c..ebfa72a 100644
--- a/SE_API/CampusRoutes.py
+++ b/SE_API/CampusRoutes.py
@@ -48,7 +48,7 @@ def create_campus(token):
Response
- 201 - Created
+ 200 - OK
403 - Invalid Token/Forbidden
"""
@@ -66,7 +66,7 @@ def create_campus(token):
#check if name already exists
try:
query = Campus.all()
- query.filter("title = ", payload['title'])
+ query.filter("title =", payload['title'])
for c in query.run(limit=1):
return forbidden("Campus with same name already exists")
except Exception as e:
@@ -86,7 +86,6 @@ def create_campus(token):
-
@campus_routes.route('/api/campuses/getAll/', methods=['GET'])
@auto.doc()
def get_campuses(token):
@@ -109,7 +108,8 @@ def get_campuses(token):
'title': 'JCE',
'email_ending': '@post.jce.ac.il',
'master_user_id': 123453433341, (User that created the campus)
- 'avatar_url': 'http://some.domain.com/imagefile.jpg'
+ 'avatar_url': 'http://some.domain.com/imagefile.jpg',
+ 'id' : 1234567890
},
....
{
@@ -124,7 +124,11 @@ def get_campuses(token):
query = Campus.all()
for c in query.run():
arr.append(dict(json.loads(c.to_JSON())))
+ print "ARR:"
print arr
+ for c in arr:
+ print"c:"
+ print c
if len(arr) != 0:
return Response(response=json.dumps(arr),
status=200,
@@ -138,6 +142,55 @@ def get_campuses(token):
+@campus_routes.route('/api/campuses/deleteCampus//', methods=['DELETE'])
+@auto.doc()
+def deleteCampus(token,campusid):
+ """
+ This Call will delete a specific campus
+
+ Route Parameters
+ - seToken: 'seToken'
+ - campusid: 'campusid'
+
+
+ Payload
+ - NONE
+
+
+ Response
+
+ 202 - Deleted campus
+
+ ....
+ {
+ ...
+ }req
+
+ ]
+ 400 - no such campus
+
+ 403 - Invalid token or not a lecturer or lecturer is not owner of campus!
+ """
+
+ if not is_lecturer(token): #todo: change to lecturer id
+ return forbidden("Invalid token or not a lecturer!")
+
+ user = get_user_by_token(token)
+ camp = Campus.get_by_id(int(campusid))
+
+ if camp is None:
+ return bad_request("no such campus")
+
+
+ if camp.master_user_id == user.key().id():
+ db.delete(camp)
+ db.save
+ return accepted("campus deleted")
+
+ return forbidden("lecturer is not owner of campus")
+
+
+
@campus_routes.route('/api/campuses/help')
def documentation():
return auto.html()
diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py
index 51a54a4..b7af470 100644
--- a/SE_API/CourseRoutes.py
+++ b/SE_API/CourseRoutes.py
@@ -7,6 +7,8 @@ from GithubAPI.GithubAPI import GitHubAPI_Keys
from google.appengine.ext import db
import requests
import datetime
+from operator import itemgetter
+
from flask import Flask, request, render_template, redirect, abort, Response
@@ -16,6 +18,8 @@ from flask.ext.autodoc import Autodoc
# DB Models
from models.Course import Course
+from models.Campus import Campus
+from models.Message import Message
#Validation Utils Libs
from SE_API.Validation_Utils import *
@@ -27,6 +31,10 @@ course_routes = Blueprint("course_routes", __name__)
auto = Autodoc()
+
+#----------------------------------------------------------
+# POST
+#----------------------------------------------------------
@course_routes.route('/api/courses/create/', methods=['POST'])
@auto.doc()
def create_course(token):
@@ -92,8 +100,6 @@ def create_course(token):
print e
return bad_request()
-
-
db.put(course)
db.save
return Response(response=course.to_JSON(),
@@ -102,6 +108,63 @@ def create_course(token):
+
+@course_routes.route('/api/courses/createMessage/', methods=['POST'])
+@auto.doc()
+def createMessage(token):
+ """
+ This call will create a new Message in the DB
+
+ Route Parameters
+ - seToken: 'seToken'
+
+
+ Payload
+ - JSON Object, Example:
+ {
+ 'courseName': 'Advance Math',
+ 'message': 'The lecture today is canceled'
+ }
+
+
+ Response
+
+ 201 - Created
+
+ 400 - Bad Request
+
+ 403 - Invalid token or not a lecturer
+ """
+ if not request.data:
+ return bad_request("no data")
+ if not is_lecturer(token): #todo: change to lecturer id
+ return forbidden("Invalid token or not a lecturer!")
+
+ user = get_user_by_token(token)
+
+ #try to parse payload
+ try:
+ payload = json.loads(request.data)
+ except Exception as e:
+ return bad_request("here")
+
+ try:
+ msg = Message(courseName=payload['courseName'], message=payload['message'], msgDate=datetime.datetime.now())
+ except Exception as e:
+ print e
+ return bad_request("there")
+
+ db.save(msg)
+ db.save
+ return created()
+
+
+
+#----------------------------------------------------------
+# GET
+#----------------------------------------------------------
+
+
@course_routes.route('/api/courses/getCourseByCampusName/', methods=["GET"])
@auto.doc()
def getCourseByCampusName(name):
@@ -126,13 +189,15 @@ def getCourseByCampusName(name):
'startDate': '2015-14-3'
'endDate': '2015-29-6'
'taskFlag': 'False'
+ 'id' : 1234567890
+
}
"""
arr = []
query = Course.all()
- query.filter("campusName = ", name)
+ query.filter("campusName=", name)
for c in query.run():
arr.append(dict(json.loads(c.to_JSON())))
@@ -146,6 +211,184 @@ def getCourseByCampusName(name):
status=200,
mimetype="application/json")
+@course_routes.route('/api/courses/getMessagesByCourseName/', methods=["GET"])
+@auto.doc()
+def getMessagesByCourseName(name):
+ """
+ >This Call will return an array of all courses in a given campus
+
+ Route Parameters
+ - name: 'campus name'
+
+
+ Payload
+ - NONE
+
+
+ Response
+
+ 200 - JSON Example:
+
+ {
+ 'courseName': 'Advance Math',
+ 'campusName': 'JCE',
+ 'startDate': '2015-14-3'
+ 'endDate': '2015-29-6'
+ 'taskFlag': false,
+ 'id' : 1234567890
+
+ }
+
+
+ """
+ arr = []
+ query = Message.all()
+ query.filter("courseName = ", name)
+
+ for m in query.run():
+ msgDic = dict(json.loads(m.to_JSON()))
+ #add a key 'forSortDate' for sorting dates
+ msgTime = datetime.datetime(msgDic['date']['year'], msgDic['date']['month'], msgDic['date']['day'], msgDic['date']['hour'], msgDic['date']['minute'])
+ msgDic['forSortDate'] = msgTime
+ arr.append(msgDic)
+
+ arr = sorted(arr, key=itemgetter('forSortDate'), reverse=False)
+ for i in arr:
+ del i['forSortDate']
+ print arr
+
+ if len(arr) != 0:
+ return Response(response=json.dumps(arr),
+ status=200,
+ mimetype="application/json")
+ else:
+ return Response(response=[],
+ status=200,
+ mimetype="application/json")
+
+#----------------------------------------------------------
+# PUT
+#----------------------------------------------------------
+
+
+
+
+#----------------------------------------------------------
+# DELETE
+#----------------------------------------------------------
+
+
+
+
+
+
+@course_routes.route('/api/courses/deleteCourse//', methods=['DELETE'])
+@auto.doc()
+def deleteCourse(token,courseid):
+ """
+ This Call will delete a specific Course
+
+ Route Parameters
+ - seToken: 'seToken'
+ - courseid: 'courseid'
+
+
+ Payload
+ - NONE
+
+
+ Response
+
+ 202 - Deleted Course
+
+ ....
+ {
+ ...
+ }req
+
+ ]
+ 400 - no such Course
+
+ 403 - Invalid token or not a lecturer or lecturer is not owner of Course!
+ """
+
+ if not is_lecturer(token): #todo: change to lecturer id
+ return forbidden("Invalid token or not a lecturer!")
+
+ user = get_user_by_token(token)
+ c = Course.get_by_id(int(courseid))
+
+ if c is None:
+ return bad_request("no such course")
+
+
+ if c.master_id == user.key().id():
+ db.delete(c)
+ db.save
+ return accepted("course deleted")
+
+ return forbidden("lecturer is not owner of course")
+
+
+@course_routes.route('/api/courses/deleteCoursesByCampus//', methods=['DELETE'])
+@auto.doc()
+def deleteCoursesByCampus(token,campusName):
+ """
+ This Call will delete a specific campus's courses
+
+ Route Parameters
+ - seToken: 'seToken'
+ - title: 'campusName'
+
+
+ Payload
+ - NONE
+
+
+ Response
+
+ 202 - Deleted campus
+
+ 204 - No Matching Campus Found
+
+ ....
+ {
+ ...
+ }req
+
+ ]
+ 400 - Bad Request
+
+ 403 - Invalid token or not a lecturer!
+ """
+
+ if not is_lecturer(token): #todo: change to lecturer id
+ return forbidden("Invalid token or not a lecturer!")
+
+
+ user = get_user_by_token(token)
+ campus = get_campus_by_campusName(campusName)
+ if campus is None:
+ return bad_request("Not a campus!")
+
+ #check user is owner of campus
+ if campus.master_user_id != user.key().id():
+ return forbidden("lecturer is not owner of campus!")
+
+ query = Course.all()
+
+ try:
+ query.filter('campusName =', campusName)
+ except Exception as e:
+ print e
+ return bad_request("invalid course title attribute")
+
+ for c in query.run():
+ db.delete(c)
+ db.save
+
+ return no_content()
+
@course_routes.route('/api/courses/help')
def documentation():
diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py
index 18d2fb1..175a3a7 100644
--- a/SE_API/ProjectRoutes.py
+++ b/SE_API/ProjectRoutes.py
@@ -41,7 +41,7 @@ def create_project(token):
{
'projectName': 'Advance Math',
'courseName': 'JCE',
- 'logo_url': 'http://location.domain.com/image.jpg'
+ 'logo_url': 'http://location.domain.com/image.jpg',
'gitRepository': 'http://location.git.com/somthing'
}
@@ -57,10 +57,12 @@ def create_project(token):
if not request.data:
return bad_request()
payload = json.loads(request.data)
- if not is_lecturer(token): #todo: change to lecturer id
- return forbidden("Invalid token or not a lecturer!")
+ #if not is_lecturer(token): #todo: change to lecturer id
+ # return forbidden("Invalid token or not a lecturer!")
user = get_user_by_token(token)
+ if user is None:
+ return bad_request("Wrong user Token")
#todo: check legality
@@ -104,7 +106,8 @@ def getProjectsByCourseName(name):
'grade': 98,
'logo_url': 'http://location.domain.com/image.jpg',
'gitRepository': 'http://location.git.com/somthing',
- 'membersId': ['bob', 'dylan', 'quentin', 'terentino']
+ 'membersId': ['bob', 'dylan', 'quentin', 'terentino'],
+ 'id' : 1234567890
}
@@ -128,6 +131,53 @@ def getProjectsByCourseName(name):
+@project_routes.route('/api/projects/deleteProject//', methods=['DELETE'])
+@auto.doc()
+def deleteProject(token,projectid):
+ """
+ This Call will delete a specific Project
+
+ Route Parameters
+ - seToken: 'seToken'
+ - courseid: 'projectid'
+
+
+ Payload
+ - NONE
+
+
+ Response
+
+ 202 - Deleted Project
+
+ ....
+ {
+ ...
+ }req
+
+ ]
+ 400 - no such Project
+
+ 403 - Invalid token or not the owner of Project!
+ """
+
+ # if not is_lecturer(token): #todo: change to lecturer id
+ # return forbidden("Invalid token or not a lecturer!")
+
+ user = get_user_by_token(token)
+ p = Project.get_by_id(int(projectid))
+
+ if p is None:
+ return bad_request("no such Project")
+
+ if p.master_id == user.key().id():
+ db.delete(p)
+ db.save
+ return accepted("Project deleted")
+
+ return forbidden("user is not owner of Project")
+
+
@project_routes.route('/api/projects/help')
def documentation():
diff --git a/SE_API/TaskRoutes.py b/SE_API/TaskRoutes.py
new file mode 100644
index 0000000..769e25b
--- /dev/null
+++ b/SE_API/TaskRoutes.py
@@ -0,0 +1,324 @@
+__author__ = 'Aran'
+
+from flask import Blueprint
+import json
+from GithubAPI.GithubAPI import GitHubAPI_Keys
+
+from google.appengine.ext import db
+import requests
+import datetime
+from operator import itemgetter
+
+from flask import Flask, request, render_template, redirect, abort, Response
+
+from flask.ext.github import GitHub
+from flask.ext.cors import CORS, cross_origin
+from flask.ext.autodoc import Autodoc
+
+# DB Models
+from models.Task import Task
+from models.Course import Course
+from models.TaskComponent import TaskComponent
+
+#Validation Utils Libs
+from SE_API.Validation_Utils import *
+from SE_API.Respones_Utils import *
+
+
+
+
+task_routes = Blueprint("task_routes", __name__)
+auto = Autodoc()
+
+@task_routes.route('/api/tasks/create/', methods=['POST'])
+@auto.doc()
+def create_task(token):
+ """
+ This call will create a new Task in the DB
+
+ Route Parameters
+ - seToken: 'seToken'
+
+
+ Payload
+ - JSON Object, Example:
+ {
+ "title":"task1",
+ "courseName":"aran",
+ "description":"pls fddfsdfdsk",
+ "dueDate":{"year":2010,
+ "month":2,
+ "day":4
+ },
+ "isPersonal":true,
+ "components":[
+ {
+ "type" : "should be type1",
+ "label" : "should be label1",
+ "isMandatory" : true,
+ "order" : 1
+ },
+ {
+ "type" : "should be type2",
+ "label" : "should be label2",
+ "isMandatory" : true,
+ "order" : 2
+ },
+ {
+ "type" : "should be type3",
+ "label" : "should be label3",
+ "isMandatory" : false,
+ "order" : 3
+ }
+ ]
+}
+
+
+ Response
+
+ 201 - Created
+
+ 400 - Bad Request
+
+ 403 - Invalid token or not a lecturer
+ """
+ if not request.data:
+ return bad_request()
+ payload = json.loads(request.data)
+ if not is_lecturer(token): #todo: change to lecturer id
+ return forbidden("Invalid token or not a lecturer!")
+
+ user = get_user_by_token(token)
+ #TODO: add seconds and minutes
+ #check the user(lecturer) is owner of the course
+ # try:
+ # arr = []
+ # query = Course.all()
+ # query.filter('courseName =',payload['courseName'])
+ # for t in query.run():
+ # arr.append(dict(json.loads(t.to_JSON())))
+ # if len(arr) == 0:
+ # return bad_request("No such course")
+ # except Exception as e:
+ # print e
+ # return bad_request("Missing courseName")
+
+
+ #todo: check legality
+ #create Task object
+ try:
+ #parse dueDate
+ try:
+ date = datetime.date(payload['dueDate']['year'],payload['dueDate']['month'],payload['dueDate']['day'])
+ except Exception:
+ return bad_request("invalid dueDate format")
+
+ task = Task(title=payload['title'], courseName=payload['courseName'], description=payload['description'], dueDate=date)
+
+ # print "id: ",task.key().id()
+ #parse isPersonal
+ try:
+ task.isPersonal = payload['isPersonal']
+ except Exception:
+ pass
+ except Exception as e:
+ print e
+ return bad_request()
+ db.put(task)
+ db.save
+
+ #create components
+ for c in payload['components']:
+ try:
+ component = TaskComponent(taskId=task.key().id(), userId=-1, type=c['type'], label=c['label'], isMandatory=c['isMandatory'], order=c['order'])
+ except Exception as e:
+ print e
+ return bad_request("Bad component")
+ db.put(component)
+ db.save
+
+
+
+ return created()
+
+
+
+
+
+
+@task_routes.route('/api/tasks/getAllTasks/', methods=["GET"])
+@auto.doc()
+def getAllTasks(courseName):
+ """
+ >This Call will return an array of all Tasks in a course by date
+
+ Route Parameters
+ - name: 'course name'
+
+
+ Payload
+ - NONE
+
+
+ Response
+
+ 200 - JSON Example:
+
+ {
+ 'title' : 'Task1',
+ 'courseName' : 'advance Math',
+ 'description' : 'prepare by sunday',
+ 'dueDate' : {
+ 'year' : 2015,
+ 'month' : 12,
+ 'day' : 23
+ }
+ 'isPersonal' : true,
+ 'task_id' : 589689456894
+ }
+
+
+ """
+
+ arr = []
+ query = Task.all()
+ query.filter("courseName = ", courseName)
+
+ for t in query.run():
+ taskDic =dict(json.loads(t.to_JSON()))
+ #add a key 'forSortDate' for sorting dates
+ taskTime = datetime.datetime(taskDic['dueDate']['year'], taskDic['dueDate']['month'], taskDic['dueDate']['day'])
+ taskDic['forSortDate'] = taskTime
+ arr.append(taskDic)
+
+ #sort array by date, and remove added key
+ arr = sorted(arr, key=itemgetter('forSortDate'), reverse=False)
+ for i in arr:
+ del i['forSortDate']
+
+ if len(arr) != 0:
+ return Response(response=json.dumps(arr),
+ status=200,
+ mimetype="application/json")
+ else:
+ return no_content()
+
+
+@task_routes.route('/api/tasks/getTaskComponents/', methods=["GET"])
+@auto.doc()
+def getTaskComponents(taskId):
+ """
+ >This Call will return an array of all components for a given task
+
+ Route Parameters
+ - taskId: integer
+
+
+ Payload
+ - NONE
+
+
+ Response
+
+ 200 - JSON Example:
+
+ [
+ {
+ 'taskId' : 7589454894,
+ 'userId' : -1,
+ 'type' : 'kindOfType',
+ 'label' : 'kindOfLabel',
+ 'isMandatory' : true,
+ 'order' : 2
+ }
+ {
+ 'taskId' : 7589454894,
+ 'userId' : yossi,
+ 'type' : 'otherKindOfType',
+ 'label' : 'otherKindOfLabel',
+ 'isMandatory' : false,
+ 'order' : 4
+ }
+ ]
+
+
+ """
+
+ arr = []
+ query = TaskComponent.all()
+ query.filter("taskId = ", taskId)
+
+ for tc in query.run():
+ arr.append(dict(json.loads(tc.to_JSON())))
+
+ #sort array by order, and remove added key
+ arr = sorted(arr, key=itemgetter('order'), reverse=False)
+
+ if len(arr) != 0:
+ return Response(response=json.dumps(arr),
+ status=200,
+ mimetype="application/json")
+ else:
+ return no_content()
+
+
+
+@task_routes.route('/api/tasks/help')
+def documentation():
+ return auto.html()
+
+
+
+
+
+
+
+
+# @task_routes.route('/api/tasks/getClosestTask/', methods=["GET"])
+# @auto.doc()
+# def getClosestTask(courseName):
+# """
+# >This Call will return an array of all projects in a given course
+#
+# Route Parameters
+# - name: 'course name'
+#
+#
+# Payload
+# - NONE
+#
+#
+# Response
+#
+# 200 - JSON Example:
+#
+# {
+# 'projectName': 'Advance Math',
+# 'courseName': 'JCE',
+# 'grade': 98,
+# 'logo_url': 'http://location.domain.com/image.jpg',
+# 'gitRepository': 'http://location.git.com/somthing',
+# 'membersId': ['bob', 'dylan', 'quentin', 'terentino']
+# }
+#
+#
+# """
+# #get all tasks for a specific course
+# arr = []
+# query = Task.all()
+# query.filter("courseName =", courseName)
+# for t in query.run():
+# count+=1
+# if t.dueDate < closestDate:
+# closestDate = t.dueDate
+# index = count
+# arr.append(dict(json.loads(t.to_JSON())))
+#
+# print arr
+# if len(arr) != 0:
+# return Response(response=json.dumps(arr[index]),
+# status=200,
+# mimetype="application/json")
+# else:
+# return no_content("no Tasks")
+#
diff --git a/SE_API/Validation_Utils.py b/SE_API/Validation_Utils.py
index 90df681..56da380 100644
--- a/SE_API/Validation_Utils.py
+++ b/SE_API/Validation_Utils.py
@@ -13,6 +13,14 @@ def get_user_by_token(token):
return u
return None
+def get_campus_by_campusName(campusName):
+ query = Campus.all()
+ query.filter("title = ", campusName)
+
+ for u in query.run(limit = 1):
+ return u
+ return None
+
def get_campus_by_suffix(suffix):
query = Campus.all()
query.filter("email_ending = ", suffix)
diff --git a/models/Campus.py b/models/Campus.py
index f4e9cef..dd910de 100644
--- a/models/Campus.py
+++ b/models/Campus.py
@@ -14,7 +14,8 @@ class Campus(db.Model):
data = {'title': self.title,
'email_ending': self.email_ending,
'master_user_id': self.master_user_id,
- 'avatar_url': self.avatar_url
+ 'avatar_url': self.avatar_url,
+ 'id' : self.key().id()
}
return json.dumps(data)
diff --git a/models/Course.py b/models/Course.py
index fd2dc08..e2a6b7c 100644
--- a/models/Course.py
+++ b/models/Course.py
@@ -25,6 +25,7 @@ class Course(db.Model):
'year': self.endDate.year,
'month': self.endDate.month,
'day': self.endDate.day,
- }
- }
+ },
+ 'id' : self.key().id()
+ }
return json.dumps(data)
diff --git a/models/Message.py b/models/Message.py
new file mode 100644
index 0000000..a5dc29f
--- /dev/null
+++ b/models/Message.py
@@ -0,0 +1,24 @@
+import json
+
+__author__ = 'Aran'
+from google.appengine.ext import db
+
+class Message(db.Model):
+ courseName = db.StringProperty(required=True)
+ message = db.StringProperty(required=True)
+ msgDate = db.DateTimeProperty(required=True)
+
+ def to_JSON(self):
+ data = {
+ 'courseName' : self.courseName,
+ 'message' : self.message,
+ 'date' : {
+ 'year': self.msgDate.year,
+ 'month': self.msgDate.month,
+ 'day': self.msgDate.day,
+ 'hour': self.msgDate.hour,
+ 'minute': self.msgDate.minute
+ },
+ 'id' : self.key().id()
+ }
+ return json.dumps(data)
diff --git a/models/Project.py b/models/Project.py
index 579ecdd..4e6cacb 100644
--- a/models/Project.py
+++ b/models/Project.py
@@ -20,5 +20,6 @@ class Project(db.Model):
'logo_url' : self.logo_url,
'gitRepository' : self.gitRepository,
'membersId' : self.membersId,
+ 'id' : self.key().id()
}
return json.dumps(data)
diff --git a/models/Task.py b/models/Task.py
index 20119cc..cdbaae9 100644
--- a/models/Task.py
+++ b/models/Task.py
@@ -1,24 +1,27 @@
import json
-
+import time
__author__ = 'Aran'
from google.appengine.ext import db
+
class Task(db.Model):
title = db.StringProperty(required=True)
- description = db.StringProperty(required=True)
+ courseName = db.StringProperty(required=True)
+ description = db.StringProperty(required=True,default=" ")
dueDate = db.DateProperty(required=True)
- isProject = db.BooleanProperty(required=True)
- isClose = db.BooleanProperty(required=True)
- isDone = db.BooleanProperty(required=True)
- taskGrade = db.IntegerProperty(required=True)
+ isPersonal = db.BooleanProperty(required=True, default=True)
def to_JSON(self):
data = {'title' : self.title,
+ 'courseName' : self.courseName,
'description' : self.description,
- 'dueDate' : self.dueDate,
- 'isProject' : self.isProject,
- 'isClose' : self.membersId,
- 'isDone' : self.isDone,
- 'taskGrade' : self.taskGrade,
+ 'dueDate' : {
+ 'year': self.dueDate.year,
+ 'month': self.dueDate.month,
+ 'day': self.dueDate.day
+ },
+ 'isPersonal' : self.isPersonal,
+ 'id' : self.key().id()
}
return json.dumps(data)
+
diff --git a/models/TaskComponent.py b/models/TaskComponent.py
new file mode 100644
index 0000000..161cfcc
--- /dev/null
+++ b/models/TaskComponent.py
@@ -0,0 +1,25 @@
+__author__ = 'Aran'
+
+
+import json
+from google.appengine.ext import db
+
+
+class TaskComponent(db.Model):
+ taskId = db.IntegerProperty(required=True)
+ userId = db.IntegerProperty(required=True, default = -1)
+ type = db.StringProperty(required=True,default=" ")
+ label = db.StringProperty(required=True,default=" ")
+ isMandatory = db.BooleanProperty(required=True, default=True)
+ order = db.IntegerProperty(required=True)
+
+ def to_JSON(self):
+ data = {'taskId' : self.taskId,
+ 'userId' : self.userId,
+ 'type' : self.type,
+ 'label' : self.label,
+ 'isMandatory' : self.isMandatory,
+ 'order' : self.order,
+ 'id' : self.key().id()
+ }
+ return json.dumps(data)
diff --git a/templates/js/app.js b/templates/js/app.js
index bc9bd78..d0cf73f 100644
--- a/templates/js/app.js
+++ b/templates/js/app.js
@@ -49,6 +49,10 @@ app.config(['$routeProvider', '$locationProvider',
.when('/myClasses', {
templateUrl: 'templates/views/myClasses.html',
controller: 'myClassesController'
+ })
+ .when('/tasks/new', {
+ templateUrl: 'templates/views/newTask.html',
+ controller: 'newTasksController'
});
}
]);
diff --git a/templates/js/controllers/newTasksController.js b/templates/js/controllers/newTasksController.js
new file mode 100644
index 0000000..3766a2f
--- /dev/null
+++ b/templates/js/controllers/newTasksController.js
@@ -0,0 +1,23 @@
+angular.module('SeHub').controller('newTasksController', ['$scope',
+ function($scope) {
+
+
+
+ $scope.componentTypes = [{
+ "type": "textbox"
+ }, {
+ "type": "textarea"
+ }, {
+ "type": "checkbox"
+ }];
+
+
+
+ $scope.task = [];
+
+ $scope.addComponent = function(){
+ $scope.task.push($scope.newComp);
+ $scope.newComp = {};
+ }
+ }
+]);
\ No newline at end of file
diff --git a/templates/views/index.html b/templates/views/index.html
index f86b52b..af10388 100644
--- a/templates/views/index.html
+++ b/templates/views/index.html
@@ -102,6 +102,7 @@
+