Added models: Project, Course, Task.

also added imports to api.py
This commit is contained in:
Aran Zaiger 2015-06-10 21:39:42 +03:00
parent 336390d094
commit 827cb0c17f
5 changed files with 73 additions and 3 deletions

View file

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

22
models/Course.py Normal file
View 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
View 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
View 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)

View file

@ -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)
return json.dumps(data)