API: Seperate User module
This commit is contained in:
parent
58a0617395
commit
cb0e2643c6
4 changed files with 46 additions and 18 deletions
|
@ -10,6 +10,7 @@ from flask import Flask, request, render_template, redirect, abort
|
||||||
# from User import User
|
# from User import User
|
||||||
from flask.ext.github import GitHub
|
from flask.ext.github import GitHub
|
||||||
from flask.ext.cors import CORS, cross_origin
|
from flask.ext.cors import CORS, cross_origin
|
||||||
|
from models.User import User
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,16 +116,23 @@ def cookieMonster(uid):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class User(db.Model):
|
# class User(db.Model):
|
||||||
username = db.StringProperty(required=True)
|
# username = db.StringProperty(required=True)
|
||||||
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)
|
# accsessToken = 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):
|
||||||
return json.dumps(self, default=lambda o: o.__dict__,
|
# dick = {'username' : self.username,
|
||||||
sort_keys=True, indent=4)
|
# 'name' : self.name,
|
||||||
|
# 'email' : self.email,
|
||||||
|
# 'isLecturer' : self.isLecturer,
|
||||||
|
# 'seToken' : self.seToken,
|
||||||
|
# 'avatar_url' : self.avatar_url,
|
||||||
|
# 'isFirstLogin' : self.isFirstLogin,
|
||||||
|
# }
|
||||||
|
# return json.dumps(dick)
|
|
@ -1,4 +0,0 @@
|
||||||
from google.appengine.ext import db
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
__author__ = 'sagi'
|
|
25
models/User.py
Normal file
25
models/User.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
__author__ = 'Aran'
|
||||||
|
from google.appengine.ext import db
|
||||||
|
|
||||||
|
class User(db.Model):
|
||||||
|
username = db.StringProperty(required=True)
|
||||||
|
name = db.StringProperty(required=True)
|
||||||
|
email = db.StringProperty(required=True)
|
||||||
|
isLecturer = db.BooleanProperty(required=True)
|
||||||
|
accsessToken = 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,
|
||||||
|
'name' : self.name,
|
||||||
|
'email' : self.email,
|
||||||
|
'isLecturer' : self.isLecturer,
|
||||||
|
'seToken' : self.seToken,
|
||||||
|
'avatar_url' : self.avatar_url,
|
||||||
|
'isFirstLogin' : self.isFirstLogin,
|
||||||
|
}
|
||||||
|
return json.dumps(dick)
|
Loading…
Reference in a new issue