From 827cb0c17fa36b24143e08fcc3ad7d874d167b8b Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Wed, 10 Jun 2015 21:39:42 +0300 Subject: [PATCH] Added models: Project, Course, Task. also added imports to api.py --- SE_API/API.py | 4 ++++ models/Course.py | 22 ++++++++++++++++++++++ models/Project.py | 20 ++++++++++++++++++++ models/Task.py | 24 ++++++++++++++++++++++++ models/User.py | 6 +++--- 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 models/Course.py create mode 100644 models/Project.py create mode 100644 models/Task.py diff --git a/SE_API/API.py b/SE_API/API.py index aa2b33b..f298ffc 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -14,6 +14,8 @@ from flask.ext.autodoc import Autodoc # DB Models from models.User import User +from models.Course import Course +from models.Project import Project @@ -72,6 +74,8 @@ def getUserByToken(token): + + @app.route('/githubOAuth') @cross_origin('*') @github.authorized_handler diff --git a/models/Course.py b/models/Course.py new file mode 100644 index 0000000..83557a7 --- /dev/null +++ b/models/Course.py @@ -0,0 +1,22 @@ +import json + +__author__ = 'Aran' +from google.appengine.ext import db + +class Course(db.Model): + courseName = db.StringProperty(required=True) + campusName = db.StringProperty(required=True) + projects = db.StringListProperty(required=True) + startDate = db.DateProperty(required=True) + endDate = db.DateProperty(required=False) + taskFlag = db.BooleanProperty(required=True) + + def to_JSON(self): + data = {'courseName' : self.courseName, + 'campusName' : self.campusName, + 'projects' : self.projects, + 'startDate' : self.startDate, + 'endDate' : self.endDate, + 'taskFlag' : self.taskFlag, + } + return json.dumps(data) diff --git a/models/Project.py b/models/Project.py new file mode 100644 index 0000000..edecd83 --- /dev/null +++ b/models/Project.py @@ -0,0 +1,20 @@ +import json + +__author__ = 'Aran' +from google.appengine.ext import db + +class Project(db.Model): + projectName = db.StringProperty(required=True) + grade = db.IntegerProperty(required=True) + logo_url = db.StringProperty(required=True) + gitRepository = db.StringProperty(required=True) + membersId = db.StringListProperty(required=True) + + def to_JSON(self): + data = {'projectName' : self.projectName, + 'grade' : self.grade, + 'logo_url' : self.logo_url, + 'gitRepository' : self.gitRepository, + 'membersId' : self.membersId, + } + return json.dumps(data) diff --git a/models/Task.py b/models/Task.py new file mode 100644 index 0000000..20119cc --- /dev/null +++ b/models/Task.py @@ -0,0 +1,24 @@ +import json + +__author__ = 'Aran' +from google.appengine.ext import db + +class Task(db.Model): + title = db.StringProperty(required=True) + description = db.StringProperty(required=True) + 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) + + def to_JSON(self): + data = {'title' : self.title, + 'description' : self.description, + 'dueDate' : self.dueDate, + 'isProject' : self.isProject, + 'isClose' : self.membersId, + 'isDone' : self.isDone, + 'taskGrade' : self.taskGrade, + } + return json.dumps(data) diff --git a/models/User.py b/models/User.py index e2aa922..8ce26a0 100644 --- a/models/User.py +++ b/models/User.py @@ -8,13 +8,13 @@ class User(db.Model): name = db.StringProperty(required=True) email = db.StringProperty(required=True) isLecturer = db.BooleanProperty(required=True) - accsessToken = db.StringProperty(required=True) + accessToken = db.StringProperty(required=True) seToken = db.StringProperty(required=True) avatar_url = db.StringProperty(required=True) isFirstLogin = db.BooleanProperty(default=True) def to_JSON(self): - dick = {'username' : self.username, + data = {'username' : self.username, 'name' : self.name, 'email' : self.email, 'isLecturer' : self.isLecturer, @@ -22,4 +22,4 @@ class User(db.Model): 'avatar_url' : self.avatar_url, 'isFirstLogin' : self.isFirstLogin, } - return json.dumps(dick) \ No newline at end of file + return json.dumps(data) \ No newline at end of file