From 644e36281807cb60ebcdf8b1949a81d5fd0753fb Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 01:41:53 +0300 Subject: [PATCH] API - added userRoutes documentation - added to each API class --- SE_API/CourseRoutes.py | 3 ++ SE_API/ProjectRoutes.py | 8 ++++- SE_API/UserRoutes.py | 75 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 SE_API/UserRoutes.py diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index 28cb857..6b76f3b 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -83,3 +83,6 @@ def create_course(token): +@course_routes.route('/api/courses/help') +def documentation(): + return auto.html() \ No newline at end of file diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index 9b279fd..ae089df 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -132,4 +132,10 @@ def get_projects(token): @project_routes.route('/api/Projects/', methods=['GET']) @auto.doc() def get_campuses(token): - pass \ No newline at end of file + pass + + + +@project_routes.route('/api/projects/help') +def documentation(): + return auto.html() \ No newline at end of file diff --git a/SE_API/UserRoutes.py b/SE_API/UserRoutes.py new file mode 100644 index 0000000..ddb5202 --- /dev/null +++ b/SE_API/UserRoutes.py @@ -0,0 +1,75 @@ +__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 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.User import User + +#Validation Utils Libs +from SE_API.Validation_Utils import * +from SE_API.Respones_Utils import * + + +user_routes = Blueprint("user_routes", __name__) +auto = Autodoc() + + +@user_routes.route('/api/users/getUserByToken/', methods=["GET"]) +@auto.doc() +def getUserByToken(token): + ''' + This Function is will Activate a user and add tha campus to it +
+ Route Parameters
+ - validation_token: 'seToken|email_suffix' +
+
+ Payload
+ - NONE +
+
+ Response +
+ 200 - JSON Example:
+ + {
+ 'username' : 'github_username',
+ 'name' : 'Bob Dylan',
+ 'email' : 'email@domain.com',
+ 'isLecturer' : true,
+ 'seToken' : 'dds2d-sfvvsf-qqq-fdf33-sfaa',
+ 'avatar_url' : 'http://location.domain.com/image.jpg',
+ 'isFirstLogin' : false,
+ 'campuses_id_list': ['22314','243512',...,'356'],
+ 'classes_id_list': ['22314','243512',...,'356']
+ } +
+
+ 403 - Invalid Token + ''' + query = User.all() + query.filter("seToken = ", token) + + for u in query.run(limit=5): + return Response(response=u.to_JSON(), + status=200, + mimetype="application/json") # Real response! + + return bad_request("No User Found") + + +@user_routes.route('/api/users/help') +def documentation(): + return auto.html() \ No newline at end of file