Added models: Project, Course, Task.
also added imports to api.py
This commit is contained in:
parent
336390d094
commit
827cb0c17f
5 changed files with 73 additions and 3 deletions
|
@ -14,6 +14,8 @@ from flask.ext.autodoc import Autodoc
|
||||||
|
|
||||||
# DB Models
|
# DB Models
|
||||||
from models.User import User
|
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')
|
@app.route('/githubOAuth')
|
||||||
@cross_origin('*')
|
@cross_origin('*')
|
||||||
@github.authorized_handler
|
@github.authorized_handler
|
||||||
|
|
22
models/Course.py
Normal file
22
models/Course.py
Normal file
|
@ -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)
|
20
models/Project.py
Normal file
20
models/Project.py
Normal file
|
@ -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)
|
24
models/Task.py
Normal file
24
models/Task.py
Normal file
|
@ -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)
|
|
@ -8,13 +8,13 @@ class User(db.Model):
|
||||||
name = db.StringProperty(required=True)
|
name = db.StringProperty(required=True)
|
||||||
email = db.StringProperty(required=True)
|
email = db.StringProperty(required=True)
|
||||||
isLecturer = db.BooleanProperty(required=True)
|
isLecturer = db.BooleanProperty(required=True)
|
||||||
accsessToken = db.StringProperty(required=True)
|
accessToken = db.StringProperty(required=True)
|
||||||
seToken = db.StringProperty(required=True)
|
seToken = db.StringProperty(required=True)
|
||||||
avatar_url = db.StringProperty(required=True)
|
avatar_url = db.StringProperty(required=True)
|
||||||
isFirstLogin = db.BooleanProperty(default=True)
|
isFirstLogin = db.BooleanProperty(default=True)
|
||||||
|
|
||||||
def to_JSON(self):
|
def to_JSON(self):
|
||||||
dick = {'username' : self.username,
|
data = {'username' : self.username,
|
||||||
'name' : self.name,
|
'name' : self.name,
|
||||||
'email' : self.email,
|
'email' : self.email,
|
||||||
'isLecturer' : self.isLecturer,
|
'isLecturer' : self.isLecturer,
|
||||||
|
@ -22,4 +22,4 @@ class User(db.Model):
|
||||||
'avatar_url' : self.avatar_url,
|
'avatar_url' : self.avatar_url,
|
||||||
'isFirstLogin' : self.isFirstLogin,
|
'isFirstLogin' : self.isFirstLogin,
|
||||||
}
|
}
|
||||||
return json.dumps(dick)
|
return json.dumps(data)
|
Loading…
Reference in a new issue