From ce8efbcaa99ff685bc90cd0057bdba55282f9108 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 14 Jun 2015 20:06:00 +0300 Subject: [PATCH 01/36] Email verification added- empty user name test added --- .../js/controllers/registerController.js | 51 ++++++------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index c8cadcf..5be6f7f 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -1,25 +1,19 @@ angular.module('SeHub') -.controller('registerController', ['$scope', '$location', '$cookies', 'apiService', '$rootScope', function ($scope, $location, $cookies, apiService ,$rootScope) { +.controller('registerController', ['$scope', '$cookies', 'apiService', '$rootScope', function ($scope, $cookies, apiService ,$rootScope) { $scope.userHasNoName = false; $scope.campusChecked = false; $scope.isEmpty = true; // if the academic email line is empty - // $scope.fullMail = $scope.academicEmail + $scope.campusObj.email_ending; // Will hold the full academic email of the user $rootScope.seToken = $cookies['com.sehub.www']; var token = $rootScope.seToken; apiService.getUserByToken(token).success(function(data){ $scope.user = data; - console.log(data); + if(data.message == 'No User Found') console.error("No User Found!"); - - $scope.user = data; - $rootScope.user = data; - if($scope.user.isFirstLogin) - $location.path('/register') - + console.log(data); if($scope.user.name === ";"){ $scope.user.name = ""; @@ -38,8 +32,6 @@ angular.module('SeHub') }); - - $scope.dropdownClicked = function() { if($scope.campus){ @@ -51,37 +43,26 @@ angular.module('SeHub') console.log($scope.campusObj); // TODO REMOVE!! } }; - } - + }; }; $scope.submitClicked = function() { - console.log($scope.user.AcMail); - $scope.mail = 'pin'; - console.log($scope.mail); + if($scope.user.AcMail != null) + { + var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user + apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) // TODO: Add 2nd parameter email type Email + { + console.log("DONE - 200"); + // TODO - add a window that display that an email has been sent for verification + }).error(function() + { + // TODO + }); + }; }; - - apiService.getAllCampuses($scope.user.seToken).success(function(data) - { - $scope.campuses = data; - }).error(function() - { - // TODO - }); - - // apiService.sendValidationMail($scope.user.seToken, $scope.fullMail).success(function(data) // TODO: Add 2nd parameter email type Email - // { - // console.log($scope.fullMail); - // console.log("200"); - - // // TODO - // }).error(function() - // { - - // }); From 9276e7fe02018b48e738f377e5ad88304881d9f9 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Sun, 14 Jun 2015 20:21:19 +0300 Subject: [PATCH 02/36] removed some prints --- SE_API/API.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/SE_API/API.py b/SE_API/API.py index d203ddc..6732abe 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -168,9 +168,8 @@ def create_campus(token): :return: code 200 """ - print "1\n" if not request.data: - return Response(response=json.dumps({'message': 'Bad Request0'}), + return Response(response=json.dumps({'message': 'Bad Request'}), status=400, mimetype="application/json") payload = json.loads(request.data) @@ -187,7 +186,7 @@ def create_campus(token): try: campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url']) except Exception: - return Response(response=json.dumps({'message': 'Bad Request1'}), + return Response(response=json.dumps({'message': 'Bad Request'}), status=400, mimetype="application/json") @@ -199,6 +198,55 @@ def create_campus(token): +# @app.route('/api/Courses/create/', methods=['POST']) +# @auto.doc() +# def create_course(token): +# """ +# This call will create a new campus in the DB +# :param token: user seToken +# Payload +# { +# 'courseName': self.courseName, +# 'campusName': self.campusName, +# 'projects': self.projects +# 'startDate': self.startDate +# 'endDate': self.endDate +# 'taskFlag': self.taskFlag +# } +# +# :return: +# code 200 +# """ +# if not request.data: +# return Response(response=json.dumps({'message': 'Bad Request'}), +# status=400, +# mimetype="application/json") +# payload = json.loads(request.data) +# if not is_lecturer(token): #todo: change to lecturer id +# return Response(response=json.dumps({'message': 'Invalid token or not a lecturer!'}), +# status=403, +# mimetype="application/json") +# +# user = get_user_by_token(token) +# +# #todo: check legality +# +# +# try: +# course = Course(courseName=payload['courseName'], campusName=payload['campusName'], projects=payload['projects'], startDate=payload['startDate'], endDate=payload['endDate'], taskFlag=payload['taskFlag']) +# except Exception: +# return Response(response=json.dumps({'message': 'Bad Request'}), +# status=400, +# mimetype="application/json") +# +# db.put(course) +# db.save +# return Response(response=json.dumps(course.to_JSON()), +# status=200, +# mimetype="application/json") +# +# +# @app.route('/api/Campuses/', methods=['GET']) @auto.doc() From cadb95651ed603bc31644a291fda87f81d8e1dfd Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 14 Jun 2015 20:22:00 +0300 Subject: [PATCH 03/36] Email verification added- empty user name test added --- templates/js/controllers/registerController.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 5be6f7f..5c93628 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -8,7 +8,8 @@ angular.module('SeHub') $rootScope.seToken = $cookies['com.sehub.www']; var token = $rootScope.seToken; - apiService.getUserByToken(token).success(function(data){ + apiService.getUserByToken(token).success(function(data) // Get user token + { $scope.user = data; if(data.message == 'No User Found') @@ -21,7 +22,7 @@ angular.module('SeHub') $scope.userHasNoName = true; } - apiService.getAllCampuses($scope.user.seToken).success(function(data) + apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses { $scope.campuses = data; }).error(function() From 0a2f209311ea0bd0600f942c48a402f7c2e8f68b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 14 Jun 2015 22:05:16 +0300 Subject: [PATCH 04/36] Update AngularJS --- templates/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/index.html b/templates/index.html index ea840eb..c5e3215 100644 --- a/templates/index.html +++ b/templates/index.html @@ -32,11 +32,11 @@ - - - - - + + + + + From c3e39e895a37e5fc03cef499a1c5fe91ce5e0aba Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 14 Jun 2015 22:06:27 +0300 Subject: [PATCH 05/36] registration submit skeleton --- .../js/controllers/registerController.js | 58 ++++++++++++++----- templates/views/register.html | 6 +- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 5c93628..5c5e7b0 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -1,5 +1,6 @@ angular.module('SeHub') -.controller('registerController', ['$scope', '$cookies', 'apiService', '$rootScope', function ($scope, $cookies, apiService ,$rootScope) { +.controller('registerController', ['$scope', '$cookies', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $location, $mdToast, $mdDialog, apiService ,$rootScope) +{ $scope.userHasNoName = false; $scope.campusChecked = false; @@ -16,23 +17,23 @@ angular.module('SeHub') console.error("No User Found!"); console.log(data); - if($scope.user.name === ";"){ + if($scope.user.name === ";") + { $scope.user.name = ""; $scope.user.name = $scope.user.username $scope.userHasNoName = true; } - apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses - { - $scope.campuses = data; - }).error(function() - { - // TODO - }); + apiService.getAllCampuses($scope.user.seToken).success(function(data) // Get all the campuses + { + $scope.campuses = data; + }).error(function() + { + // TODO + }); }); - $scope.dropdownClicked = function() { if($scope.campus){ @@ -47,26 +48,51 @@ angular.module('SeHub') }; }; - $scope.submitClicked = function() + $scope.submitClicked = function(ev) { if($scope.user.AcMail != null) { var fullMail = $scope.user.AcMail + $scope.campusObj.email_ending; // Holds the full academic email of the user - apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) // TODO: Add 2nd parameter email type Email + apiService.sendValidationMail($scope.user.seToken, fullMail).success(function(data) { - console.log("DONE - 200"); - // TODO - add a window that display that an email has been sent for verification + console.log("DONE - 200"); + $mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') + .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); + // TODO - ADD DELETE COOKIES + $cookies.remove("com.sehub.www"); + // $location.path("templates/views/home.html"); // Redirecting to home page // TODO REMOVE REMOVE!! }).error(function() { - // TODO + $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') + .ariaLabel('Email verification error alert dialog').ok('Got it!').targetEvent(ev)); }); }; }; + // TODO FOR LATER + // TODO FOR LATER + $scope.getPopWindowPosition = function() + { + return Object.keys($scope.toastPosition).filter(function(pos) + { + return $scope.toastPosition[pos]; + }).join(' '); + }; + + $scope.toastPosition = + { + bottom: false, + top: true, + left: false, + right: true + }; + + // TODO FOR LATER + // TODO FOR LATER +}]); -}]); \ No newline at end of file diff --git a/templates/views/register.html b/templates/views/register.html index bbe6b26..d73d0d9 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -18,8 +18,8 @@
Are You A Lecturer? - - + +
@@ -37,7 +37,7 @@
- Submit + Submit
From ef28a39720e5c1126a292a08eb236e4e7f03acab Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 14 Jun 2015 22:09:08 +0300 Subject: [PATCH 06/36] Update AngularJS in App --- templates/views/index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/views/index.html b/templates/views/index.html index 816e633..0a66c32 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -32,11 +32,11 @@ - - - - - + + + + + From db63665214d9fe1849766ea63a4529635ad1883c Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Sun, 14 Jun 2015 22:13:25 +0300 Subject: [PATCH 07/36] Downgrade angular version: 1.4.0 -> 1.3.6 --- templates/js/controllers/registerController.js | 2 +- templates/views/index.html | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 5c5e7b0..48f2bb1 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -59,7 +59,7 @@ angular.module('SeHub') $mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); // TODO - ADD DELETE COOKIES - $cookies.remove("com.sehub.www"); + // $cookies.remove("com.sehub.www"); // $location.path("templates/views/home.html"); // Redirecting to home page // TODO REMOVE REMOVE!! }).error(function() { diff --git a/templates/views/index.html b/templates/views/index.html index 0a66c32..816e633 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -32,11 +32,11 @@ - - - - - + + + + + From 831617ac15c30348c2b9a2e09a1f7eb1c9f8bae3 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 14 Jun 2015 23:01:47 +0300 Subject: [PATCH 08/36] Made Email_Utils --- SE_API/API.py | 3 +- SE_API/Email_Utils.py | 127 +++++++++++++++++++++++++++++++++++++ SE_API/Validation_Utils.py | 49 +------------- 3 files changed, 130 insertions(+), 49 deletions(-) create mode 100644 SE_API/Email_Utils.py diff --git a/SE_API/API.py b/SE_API/API.py index 91cfb16..3f6be11 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -19,9 +19,10 @@ from models.Course import Course from models.Project import Project from models.Campus import Campus -#Validation Utils Libs +# All API from SE_API.Validation_Utils import * from SE_API.Respones_Utils import * +from SE_API.Email_Utils import * diff --git a/SE_API/Email_Utils.py b/SE_API/Email_Utils.py new file mode 100644 index 0000000..683f7e8 --- /dev/null +++ b/SE_API/Email_Utils.py @@ -0,0 +1,127 @@ +__author__ = 'sagi' + + +from google.appengine.api import mail + + +def send_validation_email(token, email, name): + emailSuffix = str(email).split('@')[1] + message = mail.EmailMessage(sender="SE-Hub Support ", + subject="SE-Hub Activate Account") + + message.to = email + + message.body = """ + Dear """+name+""": + + To Activate your SE-Hub Account please click on the link below:
+ http://se-hub.appspot.com/api/validation/confirm/"""+token+"""|"""+emailSuffix+""" + to get access to your Campus :) + + Please let us know if you have any questions. + + SE-Hub (c) 2015 niptop Team. + """ + + message.html = """ + +
+
+ + +
+
+
+

Hey """+name+"""- Just one More Step...

+

Dear """+name+""":

+ + To Activate your SE-Hub Account please click on the link below:
+ http://se-hub.appspot.com/api/validation/confirm/"""+token+"""|"""+emailSuffix+""" + + to access you virtual class. +
+

+ Please let us know if you have any questions. +
+ SE-Hub (c) 2015 niptop Team. + + + """ + + message.send() + +def send_create_campus_request(email, name, campus_name): + message = mail.EmailMessage(sender="SE-Hub Support ", + subject="SE-Hub: "+campus_name+" Is Being Evaluated") + + message.to = email + + message.body = """ + Dear """+name+""": + + Thank You For Choosing SE-Hub! + Your Request for creating a new Campus named """+campus_name + """ + is Being Evaluated. + You Will Receive an e-mail When We finish the process
+ + Please let us know if you have any questions. + + SE-Hub (c) 2015 niptop Team. + """ + + message.html = """ + +
+
+ + +
+
+
+

Thank You For Choosing SE-Hub!

+

Dear """+name+""":

+ + Your Request for creating a new Campus named """+campus_name + """ + is Being Evaluated. + You Will Receive an e-mail When We finish the process
+ + to access you virtual class. +
+

+ Please let us know if you have any questions. +
+ SE-Hub (c) 2015 niptop Team. + + + """ + message.send() + + +def notify_se_hub_campus_request(campus, campus_name): + message = mail.EmailMessage(sender="SE-Hub Support ", + subject="SE-Hub: "+campus_name+" Is Being Evaluated") + + message.to = 'se-hub@appspot.gserviceaccount.com' + + message.body = """ + a new Campus request + """+str(campus.to_JSON()) + + message.html = """ + +
+
+ + +
+
+
+

New Campus!

+
+ """ + str(campus.to_JSON()) + """ +
+ SE-Hub (c) 2015 niptop Team. + + + """ + message.send() diff --git a/SE_API/Validation_Utils.py b/SE_API/Validation_Utils.py index e99b2bd..90df681 100644 --- a/SE_API/Validation_Utils.py +++ b/SE_API/Validation_Utils.py @@ -2,7 +2,7 @@ __author__ = 'sagi' from google.appengine.ext import db from models.User import User from models.Campus import Campus -from google.appengine.api import mail + def get_user_by_token(token): @@ -32,50 +32,3 @@ def is_lecturer(token): if user is None: return False return user.isLecturer - - -def send_validation_email(token, email, name): - emailSuffix = str(email).split('@')[1] - message = mail.EmailMessage(sender="SE-Hub Support ", - subject="SE-Hub Activate Account") - - message.to = email - - message.body = """ - Dear """+name+""": - - To Activate your SE-Hub Account please click on the link below:
- http://se-hub.appspot.com/api/validation/confirm/"""+token+"""|"""+emailSuffix+""" - to get access to your Campus :) - - Please let us know if you have any questions. - - SE-Hub (c) 2015 niptop Team. - """ - - message.html = """ - -
-
- - -
-
-
-

Hey """+name+"""- Just one More Step...

-

Dear """+name+""":

- - To Activate your SE-Hub Account please click on the link below:
- http://se-hub.appspot.com/api/validation/confirm/"""+token+"""|"""+emailSuffix+""" - - to access you virtual class. -
-

- Please let us know if you have any questions. -
- SE-Hub (c) 2015 niptop Team. - - - """ - - message.send() From 279d637b822008d2de3f0f83058fd71604c1ae98 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 01:34:04 +0300 Subject: [PATCH 09/36] added responses --- SE_API/Respones_Utils.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/SE_API/Respones_Utils.py b/SE_API/Respones_Utils.py index b789974..3fe0e3f 100644 --- a/SE_API/Respones_Utils.py +++ b/SE_API/Respones_Utils.py @@ -3,6 +3,29 @@ __author__ = 'Aran' from flask import Response import json + +def ok(message='OK'): + return Response(response=json.dumps({'message': message}), + status=200, + mimetype="application/json") + +def created(message='Created'): + return Response(response=json.dumps({'message': message}), + status=201, + mimetype="application/json") + +def accepted(message='Accepted'): + return Response(response=json.dumps({'message': message}), + status=202, + mimetype="application/json") + + +def no_content(message='No Content'): + return Response(response=json.dumps({'message': message}), + status=204, + mimetype="application/json") + + def bad_request(message='Bad Request'): return Response(response=json.dumps({'message': message}), status=400, From 7239d27da2a13e34b064076c7df2748ec85f1004 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 01:35:18 +0300 Subject: [PATCH 10/36] Projects - added master_id and changed some properties --- models/Project.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/Project.py b/models/Project.py index edecd83..e165c58 100644 --- a/models/Project.py +++ b/models/Project.py @@ -5,13 +5,15 @@ 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) + masterId = db.IntegerProperty(required=True) + grade = db.IntegerProperty(required=True, default=0) + logo_url = db.StringProperty(required=False) gitRepository = db.StringProperty(required=True) membersId = db.StringListProperty(required=True) def to_JSON(self): data = {'projectName' : self.projectName, + 'masterId' : self.masterId, 'grade' : self.grade, 'logo_url' : self.logo_url, 'gitRepository' : self.gitRepository, From d9382e8fbedbe5271912a01aa0fa015777fb4450 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 01:37:07 +0300 Subject: [PATCH 11/36] Course - changed date formatting to JSON and some properties --- models/Course.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/models/Course.py b/models/Course.py index 83557a7..7b2ac75 100644 --- a/models/Course.py +++ b/models/Course.py @@ -6,17 +6,23 @@ 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) + projects = db.StringListProperty(required=True,default=[]) startDate = db.DateProperty(required=True) - endDate = db.DateProperty(required=False) - taskFlag = db.BooleanProperty(required=True) + endDate = db.DateProperty(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, + 'startDate' : { + 'year': self.startDate.year, + 'month': self.startDate.month, + 'day': self.startDate.day, + }, + 'endDate' : { + 'year': self.endDate.year, + 'month': self.endDate.month, + 'day': self.endDate.day, + } } return json.dumps(data) From 177292d7c8f505addf71cb24cdfca8f10ffdf492 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 01:38:46 +0300 Subject: [PATCH 12/36] API - separated different features of API --- SE_API/API.py | 234 +++++----------------------------------- SE_API/CampusRoutes.py | 135 +++++++++++++++++++++++ SE_API/CourseRoutes.py | 85 +++++++++++++++ SE_API/ProjectRoutes.py | 135 +++++++++++++++++++++++ 4 files changed, 379 insertions(+), 210 deletions(-) create mode 100644 SE_API/CampusRoutes.py create mode 100644 SE_API/CourseRoutes.py create mode 100644 SE_API/ProjectRoutes.py diff --git a/SE_API/API.py b/SE_API/API.py index 91cfb16..4779525 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -6,6 +6,7 @@ from GithubAPI.GithubAPI import GitHubAPI_Keys from google.appengine.ext import db import requests import uuid +import datetime from flask import Flask, request, render_template, redirect, abort, Response @@ -23,11 +24,18 @@ from models.Campus import Campus from SE_API.Validation_Utils import * from SE_API.Respones_Utils import * +from SE_API.UserRoutes import user_routes +from SE_API.CampusRoutes import campus_routes +from SE_API.CourseRoutes import course_routes +from SE_API.ProjectRoutes import project_routes + app = Flask(__name__, static_folder='../templates') + + githubKeys = GitHubAPI_Keys() app.config['GITHUB_CLIENT_ID'] = githubKeys.getId() @@ -35,6 +43,12 @@ app.config['GITHUB_CLIENT_SECRET'] = githubKeys.getSecret() github = GitHub(app) cross = CORS(app) + +app.register_blueprint(user_routes) +app.register_blueprint(campus_routes) +app.register_blueprint(course_routes) +app.register_blueprint(project_routes) + auto = Autodoc(app) @app.errorhandler(404) @@ -108,23 +122,18 @@ def send_activation(token): 403 - Invalid Token
""" if not request.data: - return Response(response=json.dumps({'message': 'Bad Request'}), - status=400, - mimetype="application/json") + return bad_request() payload = json.loads(request.data) if not is_user_token_valid(token): - return Response(response=json.dumps({'message': 'Not A Valid Token!'}), - status=403, - mimetype="application/json") + return forbidden("Not A Valid Token!") + query = User.all() query.filter('seToken =', token) for u in query.run(limit=1): try: send_validation_email(token=token, name=u.username, email=payload["email"]) except Exception: - return Response(response=json.dumps({'message': 'Bad Request'}), - status=400, - mimetype="application/json") + return bad_request() return Response(status=200) @@ -132,6 +141,10 @@ def send_activation(token): def documentation(): return auto.html() +# @app.route('/api/help/campuses') +# def documentation(): +# return auto.html() + @app.route('/home') def returnHome(): try: @@ -141,51 +154,6 @@ def returnHome(): -@app.route('/api/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=201, - mimetype="application/json") # Real response! - - return Response(response=json.dumps({'message' : 'No User Found'}), - status=400, - mimetype="application/json") - @app.route('/githubOAuth') @@ -229,162 +197,6 @@ def oauth(oauth_token): return cookieMonster(user.seToken) -@app.route('/api/Campuses/create/', methods=['POST']) -@auto.doc() -def create_campus(token): - """ - This call will create a new campus in the DB -
- Route Parameters
- - seToken: 'seToken' -
-
- Payload
- - JSON Object, Example:
- {
- 'title': 'Campus name',
- 'email_ending': '@campus.ac.com',
- 'avatar_url': 'http://location.domain.com/image.jpg'
- }
-
-
- Response -
- 201 - Created -
- 403 - Invalid Token/Forbidden - """ - if not request.data: - return Response(response=json.dumps({'message': 'Bad Request'}), - status=400, - mimetype="application/json") - payload = json.loads(request.data) - if not is_lecturer(token): #todo: change to lecturer id - return Response(response=json.dumps({'message': 'Invalid token or not a lecturer!'}), - status=403, - mimetype="application/json") - - user = get_user_by_token(token) - - #todo: check legality - - try: - campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url']) - except Exception: - return Response(response=json.dumps({'message': 'Bad Request'}), - status=400, - mimetype="application/json") - - db.put(campus) - db.save - return Response(response=json.dumps(campus.to_JSON()), - status=201, - mimetype="application/json") - - - -# @app.route('/api/Courses/create/', methods=['POST']) -# @auto.doc() -# def create_course(token): -# """ -# This call will create a new campus in the DB -# :param token: user seToken -# Payload -# { -# 'courseName': self.courseName, -# 'campusName': self.campusName, -# 'projects': self.projects -# 'startDate': self.startDate -# 'endDate': self.endDate -# 'taskFlag': self.taskFlag -# } -# -# :return: -# code 200 -# """ -# if not request.data: -# return Response(response=json.dumps({'message': 'Bad Request'}), -# status=400, -# mimetype="application/json") -# payload = json.loads(request.data) -# if not is_lecturer(token): #todo: change to lecturer id -# return Response(response=json.dumps({'message': 'Invalid token or not a lecturer!'}), -# status=403, -# mimetype="application/json") -# -# user = get_user_by_token(token) -# -# #todo: check legality -# -# -# try: -# course = Course(courseName=payload['courseName'], campusName=payload['campusName'], projects=payload['projects'], startDate=payload['startDate'], endDate=payload['endDate'], taskFlag=payload['taskFlag']) -# except Exception: -# return Response(response=json.dumps({'message': 'Bad Request'}), -# status=400, -# mimetype="application/json") -# -# db.put(course) -# db.save -# return Response(response=json.dumps(course.to_JSON()), -# status=200, -# mimetype="application/json") -# -# -# - -@app.route('/api/Campuses/', methods=['GET']) -@auto.doc() -def get_campuses(token): - """ - This Call will return an array of all Campuses available -
- Route Parameters
- - seToken: 'seToken' -
-
- Payload
- - NONE
-
-
- Response -
- 200 - JSON Array, Example:
- [
- { - 'title': 'JCE',
- 'email_ending': '@post.jce.ac.il',
- 'master_user_id': 123453433341, (User that created the campus)
- 'avatar_url': 'http://some.domain.com/imagefile.jpg'
- },
- ....
- {
- ...
- }req
- ]
-
- 403 - Invalid Token
- 500 - Server Error - """ - if is_user_token_valid(token): - arr = [] - query = Campus.all() - for c in query.run(): - arr.append(dict(json.loads(c.to_JSON()))) - print arr - if len(arr) != 0: - return Response(response=json.dumps(arr), - status=200, - mimetype="application/json") - else: - return Response(response=[], - status=200, - mimetype="application/json") - else: - return Response(response=json.dumps({'message': 'Invalid Token'}), - status=403, - mimetype="application/json") - @app.route('/login') @@ -433,3 +245,5 @@ def cookieMonster(uid): response = app.make_response(redirect_to_home ) response.set_cookie('com.sehub.www',value=uid) return response + + diff --git a/SE_API/CampusRoutes.py b/SE_API/CampusRoutes.py new file mode 100644 index 0000000..8a5d5d9 --- /dev/null +++ b/SE_API/CampusRoutes.py @@ -0,0 +1,135 @@ +__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.Campus import Campus + +#Validation Utils Libs +from SE_API.Validation_Utils import * +from SE_API.Respones_Utils import * + + + +campus_routes = Blueprint("campus_routes", __name__) +auto = Autodoc() + +@campus_routes.route('/api/campuses/create/', methods=['POST']) +@auto.doc() +def create_campus(token): + """ + This call will create a new campus in the DB +
+ Route Parameters
+ - seToken: 'seToken' +
+
+ Payload
+ - JSON Object, Example:
+ {
+ 'title': 'Campus name',
+ 'email_ending': '@campus.ac.com',
+ 'avatar_url': 'http://location.domain.com/image.jpg'
+ }
+
+
+ Response +
+ 201 - Created +
+ 403 - Invalid Token/Forbidden + """ + if not request.data: + return bad_request() + payload = json.loads(request.data) + if not is_lecturer(token): #todo: change to lecturer id + return forbidden("Invalid token or not a lecturer!") + + user = get_user_by_token(token) + + #todo: check legality + + try: + campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url']) + except Exception: + return bad_request() + + db.put(campus) + db.save + return Response(response=campus.to_JSON(), + status=201, + mimetype="application/json") + + + + + +@campus_routes.route('/api/campuses/', methods=['GET']) +@auto.doc() +def get_campuses(token): + """ + This Call will return an array of all Campuses available +
+ Route Parameters
+ - seToken: 'seToken' +
+
+ Payload
+ - NONE
+
+
+ Response +
+ 200 - JSON Array, Example:
+ [
+ { + 'title': 'JCE',
+ 'email_ending': '@post.jce.ac.il',
+ 'master_user_id': 123453433341, (User that created the campus)
+ 'avatar_url': 'http://some.domain.com/imagefile.jpg'
+ },
+ ....
+ {
+ ...
+ }req
+ ]
+
+ 403 - Invalid Token
+ 500 - Server Error + """ + + if is_user_token_valid(token): + arr = [] + query = Campus.all() + for c in query.run(): + arr.append(dict(json.loads(c.to_JSON()))) + print arr + if len(arr) != 0: + return Response(response=json.dumps(arr), + status=200, + mimetype="application/json") + else: + return Response(response=[], + status=200, + mimetype="application/json") + else: + return forbidden("Invalid Token") + + + + +@campus_routes.route('/api/campuses/help') +def documentation(): + return auto.html() \ No newline at end of file diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py new file mode 100644 index 0000000..28cb857 --- /dev/null +++ b/SE_API/CourseRoutes.py @@ -0,0 +1,85 @@ +__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.Course import Course + +#Validation Utils Libs +from SE_API.Validation_Utils import * +from SE_API.Respones_Utils import * + + + +course_routes = Blueprint("course_routes", __name__) +auto = Autodoc() + + +@course_routes.route('/api/courses/create/', methods=['POST']) +@auto.doc() +def create_course(token): + """ + This call will create a new campus in the DB + :param token: user seToken + Payload + { + 'courseName': self.courseName, + 'campusName': self.campusName, + 'projects': self.projects + 'startDate': self.startDate + 'endDate': self.endDate + 'taskFlag': self.taskFlag + } + + :return: + code 200 + """ + if not request.data: + return bad_request() + payload = json.loads(request.data) + if not is_lecturer(token): #todo: change to lecturer id + return forbidden("Invalid token or not a lecturer!") + + user = get_user_by_token(token) + + #todo: check legality + + + try: + start_date = datetime.date(payload['startDate']['year'],payload['startDate']['month'],payload['startDate']['day']) + end_date = datetime.date(payload['endDate']['year'],payload['endDate']['month'],payload['endDate']['day']) + + course = Course(courseName=payload['courseName'], campusName=payload['campusName'], + startDate=start_date, endDate=end_date) + + try: + course.projects=payload['projects'] + except Exception: + pass + + + except Exception: + return bad_request() + + + + db.put(course) + db.save + return Response(response=course.to_JSON(), + status=201, + mimetype="application/json") + + + diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py new file mode 100644 index 0000000..9b279fd --- /dev/null +++ b/SE_API/ProjectRoutes.py @@ -0,0 +1,135 @@ +__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.Project import Project + +#Validation Utils Libs +from SE_API.Validation_Utils import * +from SE_API.Respones_Utils import * + + + +project_routes = Blueprint("project_routes", __name__) +auto = Autodoc() + +@project_routes.route('/api/projects/Create//', methods=['POST']) +@auto.doc() +def create_project(token,id): + """ + This call will create a new project in the DB +
+ Route Parameters
+ - seToken: 'seToken' +
+
+ Payload
+ - JSON Object, Example:
+ {
+ 'title': 'Campus name',
+ 'email_ending': '@campus.ac.com',
+ 'avatar_url': 'http://location.domain.com/image.jpg'
+ }
+
+
+ Response +
+ 201 - Created +
+ 403 - Invalid Token/Forbidden + """ + if not request.data: + return bad_request() + payload = json.loads(request.data) + if not is_lecturer(token): #todo: change to lecturer id + return forbidden("Invalid token or not a lecturer!") + + user = get_user_by_token(token) + + #todo: check legality + + try: + project = Project(projectName=payload['projectName'], masterId=user.key().id(), gitRepository=payload['gitRepository'], membersId=[token]) + except Exception as e: + print e + return bad_request() + + db.put(project) + db.save + return Response(response=project.to_JSON(), + status=201, + mimetype="application/json") + + + + + +@project_routes.route('/api/projects/get/', methods=['GET']) +@auto.doc() +def get_projects(token): + """ + This Call will return an array of all projects available +
+ Route Parameters
+ - seToken: 'seToken' +
+
+ Payload
+ - NONE
+
+
+ Response +
+ 200 - JSON Array, Example:
+ [
+ { + 'title': 'JCE',
+ 'email_ending': '@post.jce.ac.il',
+ 'master_user_id': 123453433341, (User that created the campus)
+ 'avatar_url': 'http://some.domain.com/imagefile.jpg'
+ },
+ ....
+ {
+ ...
+ }req
+ ]
+
+ 403 - Invalid Token
+ 500 - Server Error + """ + if is_user_token_valid(token): + arr = [] + query = Campus.all() + for c in query.run(): + arr.append(dict(json.loads(c.to_JSON()))) + print arr + if len(arr) != 0: + return Response(response=json.dumps(arr), + status=200, + mimetype="application/json") + else: + return Response(response=[], + status=200, + mimetype="application/json") + else: + return forbidden("Invalid Token") + + + +@project_routes.route('/api/Projects/', methods=['GET']) +@auto.doc() +def get_campuses(token): + pass \ No newline at end of file From 644e36281807cb60ebcdf8b1949a81d5fd0753fb Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 01:41:53 +0300 Subject: [PATCH 13/36] 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 From 99c2128fa92291ce8652df6d69f73b236ccba666 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Mon, 15 Jun 2015 11:37:21 +0300 Subject: [PATCH 14/36] -Card Layout padding fixed -cookies removal after login fixed -redirect to welcome page added --- templates/css/theme.css | 61 ++++++---------- .../js/controllers/registerController.js | 34 ++------- templates/views/register.html | 70 +++++++++---------- 3 files changed, 61 insertions(+), 104 deletions(-) diff --git a/templates/css/theme.css b/templates/css/theme.css index a4067cd..7a1abfb 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -18,6 +18,11 @@ md-list .md-button { /* Using Data-URI converted from svg until becomes available https://github.com/google/material-design-icons */ + +p { + margin-left: 2em; +} + .menuBtn { background: transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iMjRweCIgaGVpZ2h0PSIyNHB4IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDI0IDI0IiB4bWw6c3BhY2U9InByZXNlcnZlIj4KPGcgaWQ9IkhlYWRlciI+CiAgICA8Zz4KICAgICAgICA8cmVjdCB4PSItNjE4IiB5PSItMjIzMiIgZmlsbD0ibm9uZSIgd2lkdGg9IjE0MDAiIGhlaWdodD0iMzYwMCIvPgogICAgPC9nPgo8L2c+CjxnIGlkPSJMYWJlbCI+CjwvZz4KPGcgaWQ9Ikljb24iPgogICAgPGc+CiAgICAgICAgPHJlY3QgZmlsbD0ibm9uZSIgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0Ii8+CiAgICAgICAgPHBhdGggZD0iTTMsMThoMTh2LTJIM1YxOHogTTMsMTNoMTh2LTJIM1YxM3ogTTMsNnYyaDE4VjZIM3oiIHN0eWxlPSJmaWxsOiNmM2YzZjM7Ii8+CiAgICA8L2c+CjwvZz4KPGcgaWQ9IkdyaWQiIGRpc3BsYXk9Im5vbmUiPgogICAgPGcgZGlzcGxheT0iaW5saW5lIj4KICAgIDwvZz4KPC9nPgo8L3N2Zz4=) no-repeat center center; } @@ -54,19 +59,13 @@ body.noscroll } .avatar { - float: left; margin-top: 1em; margin-right: 1em; - position: relative; - + position: center; - -webkit-border-radius: 50%; - -moz-border-radius: 50%; - border-radius: 50%; - - -webkit-box-shadow: 0 0 0 3px #fff, 0 0 0 4px #999, 0 2px 5px 4px rgba(0,0,0,.2); - -moz-box-shadow: 0 0 0 3px #fff, 0 0 0 4px #999, 0 2px 5px 4px rgba(0,0,0,.2); - box-shadow: 0 0 0 3px #fff, 0 0 0 4px #999, 0 2px 5px 4px rgba(0,0,0,.2); + -webkit-border-radius: 30%; + -moz-border-radius: 30%; + border-radius: 30%; } /*.avatar { @@ -75,9 +74,10 @@ body.noscroll .avatar img { border-radius: 40px; + position:center; width: 80px; height: 80px; - margin: 6px; /* centers the image in the parent element */ + margin: 6px; /*centers the image in the parent element */ } /* Added BY devMatan */ @@ -92,22 +92,19 @@ body.noscroll }*/ -.campusAvatar: +.campusAvatar img { - float: left; +/* margin-top: 1em; margin-right: 1em; - position: relative; - width:70%; - height:auto; - - -webkit-border-radius: 50%; - -moz-border-radius: 50%; - border-radius: 50%; - - -webkit-box-shadow: 0 0 0 3px #fff, 0 0 0 4px #999, 0 2px 5px 4px rgba(0,0,0,.2); - -moz-box-shadow: 0 0 0 3px #fff, 0 0 0 4px #999, 0 2px 5px 4px rgba(0,0,0,.2); - box-shadow: 0 0 0 3px #fff, 0 0 0 4px #999, 0 2px 5px 4px rgba(0,0,0,.2); + position: center; +*/ + + border-radius: 40px; + position:center; + width: 80px; + height: 80px; + margin: 6px; } .spacer{ @@ -131,23 +128,11 @@ body.noscroll float:right; }*/ -/*.dropDown: /* TODO * +/*.dropDown /* TODO * { border-bottom: 2px black solid; border-top: 2px black solid; border-left: 2px black solid; border-right: 2px black solid; border-radius: 1px black solid; -}*/ - - -/* -h1 -{ - position:center; -} -*/ - - - - +}*/ \ No newline at end of file diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index 48f2bb1..c243edc 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -1,5 +1,5 @@ angular.module('SeHub') -.controller('registerController', ['$scope', '$cookies', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $location, $mdToast, $mdDialog, apiService ,$rootScope) +.controller('registerController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { $scope.userHasNoName = false; @@ -57,10 +57,9 @@ angular.module('SeHub') { console.log("DONE - 200"); $mdDialog.show($mdDialog.alert().title('E-mail Verification').content('A verification e-mail has been sent to your email address.') - .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); - // TODO - ADD DELETE COOKIES - // $cookies.remove("com.sehub.www"); - // $location.path("templates/views/home.html"); // Redirecting to home page // TODO REMOVE REMOVE!! + .ariaLabel('Email verification alert dialog').ok('Got it!').targetEvent(ev)); // Pop-up alert for e-mail verification + $cookieStore.remove("com.sehub.www"); // Removing the cookies + $window.location.href = 'http://se-hub.appspot.com'; }).error(function() { $mdDialog.show($mdDialog.alert().title('Error - E-mail Verification').content('An error has occured in your e-mail address.') @@ -68,31 +67,6 @@ angular.module('SeHub') }); }; }; - - - // TODO FOR LATER - // TODO FOR LATER - - $scope.getPopWindowPosition = function() - { - return Object.keys($scope.toastPosition).filter(function(pos) - { - return $scope.toastPosition[pos]; - }).join(' '); - }; - - $scope.toastPosition = - { - bottom: false, - top: true, - left: false, - right: true - }; - - // TODO FOR LATER - // TODO FOR LATER - - }]); diff --git a/templates/views/register.html b/templates/views/register.html index d73d0d9..7bbebc3 100644 --- a/templates/views/register.html +++ b/templates/views/register.html @@ -1,44 +1,44 @@

Registration

- -
-

First Login Of {{user.name}}

-
- {{item.who}} + +
+ First Login Of {{user.name}} +
+ {{item.who}} +
+
+
+
+ + + + +
+

+
+

Are You A Lecturer?

+ + +
-
-

-
-
- - - - -
-
- Are You A Lecturer? - - -
-
-
+
campusAvatar
-
-
- Submit -
+
+
+ Submit
@@ -56,14 +56,12 @@
- -
-
+ From d0c91b0c704852d6f82ccea1e7faff98eb552a87 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 16:23:42 +0300 Subject: [PATCH 15/36] AngularJS: Updating Services to the new API scheme --- templates/js/services/apiService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index e240375..ea599f4 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -7,7 +7,7 @@ service.factory('apiService', ['$http', function($http) { return { getUserByToken: function(token){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/getUserByToken/" + token; + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserByToken/" + token; req = { method : "GET", url : url @@ -16,7 +16,7 @@ service.factory('apiService', ['$http', function($http) { return $http(req); }, getAllCampuses: function(token){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/Campuses/" + token; + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/" + token; req = { method : "GET", url : url From 97af27500d9e3cbc9ba534e6e3b28a23a30d0f3d Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 16:24:01 +0300 Subject: [PATCH 16/36] QA: Pormatting UserAPI_Test --- Testing/UserAPI_Test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/Testing/UserAPI_Test.py b/Testing/UserAPI_Test.py index 67b9cf6..598ea85 100644 --- a/Testing/UserAPI_Test.py +++ b/Testing/UserAPI_Test.py @@ -20,13 +20,11 @@ class UserTestPlan(unittest.TestCase): r = requests.get(self.__class__.url_+'api/getUserByToken/invalidtoken') self.assertEquals(r.status_code, 403) - def test_getUserByToken_valid(self): r = requests.get(self.__class__.url_+'api/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) self.assertEquals(r.status_code, 200) self.assertEquals(r.json()['username'], 'qa_student') - def test_getUserByToken_empty(self): r = requests.get(self.__class__.url_+'api/getUserByToken/') self.assertEquals(r.status_code, 400) From 2dc319af48106e2a8b22fd06944a3c0e9c064ad8 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 16:28:54 +0300 Subject: [PATCH 17/36] QA: Update UserAPI_Test.py to new API scheme --- Testing/UserAPI_Test.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Testing/UserAPI_Test.py b/Testing/UserAPI_Test.py index 598ea85..e907400 100644 --- a/Testing/UserAPI_Test.py +++ b/Testing/UserAPI_Test.py @@ -17,18 +17,27 @@ class UserTestPlan(unittest.TestCase): print 'Initialized' def test_getUserByToken_invalid(self): - r = requests.get(self.__class__.url_+'api/getUserByToken/invalidtoken') + r = requests.get(self.__class__.url_+'api/users/getUserByToken/invalidtoken') self.assertEquals(r.status_code, 403) def test_getUserByToken_valid(self): - r = requests.get(self.__class__.url_+'api/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) self.assertEquals(r.status_code, 200) self.assertEquals(r.json()['username'], 'qa_student') def test_getUserByToken_empty(self): - r = requests.get(self.__class__.url_+'api/getUserByToken/') + r = requests.get(self.__class__.url_+'api/users/getUserByToken/') self.assertEquals(r.status_code, 400) + def test_isStudent_Student(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['STUDENT']) + self.assertEquals(r.status_code, 200) + self.assertFalse(r.json()['isLecturer']) + + def test_isLecturer_Lecturer(self): + r = requests.get(self.__class__.url_+'api/users/getUserByToken/'+__CONFIG__['TOKENS']['LECTURER']) + self.assertEquals(r.status_code, 200) + self.assertTrue(r.json()['isLecturer']) if __name__ == '__main__': From 379ede2617e561ffe03b4ecc6c5d783f834fe7be Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 16:32:35 +0300 Subject: [PATCH 18/36] models - added master_id --- models/Course.py | 2 ++ models/Project.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/models/Course.py b/models/Course.py index 7b2ac75..4b3abe5 100644 --- a/models/Course.py +++ b/models/Course.py @@ -6,6 +6,7 @@ from google.appengine.ext import db class Course(db.Model): courseName = db.StringProperty(required=True) campusName = db.StringProperty(required=True) + master_id = db.IntegerProperty(required=True) projects = db.StringListProperty(required=True,default=[]) startDate = db.DateProperty(required=True) endDate = db.DateProperty(required=True) @@ -13,6 +14,7 @@ class Course(db.Model): def to_JSON(self): data = {'courseName' : self.courseName, 'campusName' : self.campusName, + 'master_id' : self.master_id, 'projects' : self.projects, 'startDate' : { 'year': self.startDate.year, diff --git a/models/Project.py b/models/Project.py index e165c58..97db04e 100644 --- a/models/Project.py +++ b/models/Project.py @@ -5,7 +5,7 @@ from google.appengine.ext import db class Project(db.Model): projectName = db.StringProperty(required=True) - masterId = db.IntegerProperty(required=True) + master_id = db.IntegerProperty(required=True) grade = db.IntegerProperty(required=True, default=0) logo_url = db.StringProperty(required=False) gitRepository = db.StringProperty(required=True) @@ -13,7 +13,7 @@ class Project(db.Model): def to_JSON(self): data = {'projectName' : self.projectName, - 'masterId' : self.masterId, + 'master_id' : self.master_id, 'grade' : self.grade, 'logo_url' : self.logo_url, 'gitRepository' : self.gitRepository, From f7172ab983ab1994fbad5c394709ccacf63e2d19 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 16:32:59 +0300 Subject: [PATCH 19/36] added function and changed functions path --- SE_API/CampusRoutes.py | 64 ++++++++++++++++++++++++++++++++++++++--- SE_API/ProjectRoutes.py | 3 +- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/SE_API/CampusRoutes.py b/SE_API/CampusRoutes.py index 8a5d5d9..93afc55 100644 --- a/SE_API/CampusRoutes.py +++ b/SE_API/CampusRoutes.py @@ -53,13 +53,25 @@ def create_campus(token): """ if not request.data: return bad_request() - payload = json.loads(request.data) if not is_lecturer(token): #todo: change to lecturer id return forbidden("Invalid token or not a lecturer!") - user = get_user_by_token(token) + #try to parse payload + try: + payload = json.loads(request.data) + except Exception as e: + return bad_request(e) - #todo: check legality + #check if name already exists + try: + query = Campus.all() + query.filter("title = ", payload['title']) + for c in query.run(limit=1): + return forbidden("Campus with same name already exists") + except Exception as e: + print e + + user = get_user_by_token(token) try: campus = Campus(title=payload['title'], email_ending=payload['email_ending'], master_user_id=user.key().id(), avatar_url=payload['avatar_url']) @@ -76,7 +88,7 @@ def create_campus(token): -@campus_routes.route('/api/campuses/', methods=['GET']) +@campus_routes.route('/api/campuses/getAll/', methods=['GET']) @auto.doc() def get_campuses(token): """ @@ -129,6 +141,50 @@ def get_campuses(token): +@campus_routes.route('/api/campuses/getCampusId/', methods=["GET"]) +@auto.doc() +def getCampusId(name): + ''' + 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 = Campus.all() + query.filter("title = ", name) + + for c in query.run(limit=5): + return Response(response=c.key().id(), + status=200, + mimetype="application/json") # Real response! + + return bad_request("No Campus Found") + + @campus_routes.route('/api/campuses/help') def documentation(): diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index ae089df..44c2015 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -77,7 +77,7 @@ def create_project(token,id): -@project_routes.route('/api/projects/get/', methods=['GET']) +@project_routes.route('/api/projects/getAll/', methods=['GET']) @auto.doc() def get_projects(token): """ @@ -136,6 +136,7 @@ def get_campuses(token): + @project_routes.route('/api/projects/help') def documentation(): return auto.html() \ No newline at end of file From 1ec45d107cb38b1df49deff755b21f6fc1a9ec44 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 16:51:13 +0300 Subject: [PATCH 20/36] API & AngularJS: Updating API Routes - API_Dev Merge and Service Update --- SE_API/CampusRoutes.py | 2 +- templates/js/services/apiService.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SE_API/CampusRoutes.py b/SE_API/CampusRoutes.py index 93afc55..a93c187 100644 --- a/SE_API/CampusRoutes.py +++ b/SE_API/CampusRoutes.py @@ -188,4 +188,4 @@ def getCampusId(name): @campus_routes.route('/api/campuses/help') def documentation(): - return auto.html() \ No newline at end of file + return auto.html() diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index ea599f4..108b309 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -16,7 +16,7 @@ service.factory('apiService', ['$http', function($http) { return $http(req); }, getAllCampuses: function(token){ - var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/" + token; + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getAll/" + token; req = { method : "GET", url : url From 5b0d67152f034e69ae3911e13b36c10036561c05 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 16:53:56 +0300 Subject: [PATCH 21/36] removed function --- SE_API/CampusRoutes.py | 45 ------------------------------------------ 1 file changed, 45 deletions(-) diff --git a/SE_API/CampusRoutes.py b/SE_API/CampusRoutes.py index 93afc55..43afbf1 100644 --- a/SE_API/CampusRoutes.py +++ b/SE_API/CampusRoutes.py @@ -141,51 +141,6 @@ def get_campuses(token): -@campus_routes.route('/api/campuses/getCampusId/', methods=["GET"]) -@auto.doc() -def getCampusId(name): - ''' - 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 = Campus.all() - query.filter("title = ", name) - - for c in query.run(limit=5): - return Response(response=c.key().id(), - status=200, - mimetype="application/json") # Real response! - - return bad_request("No Campus Found") - - - @campus_routes.route('/api/campuses/help') def documentation(): return auto.html() \ No newline at end of file From 26c66842b4b409978eac2cc594816ef4036729dc Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 16:54:12 +0300 Subject: [PATCH 22/36] added getCourseByCampusName function --- SE_API/CourseRoutes.py | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index 6b76f3b..4131674 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -83,6 +83,49 @@ def create_course(token): +@course_routes.route('/api/courses/getCourseByCampusName/', methods=["GET"]) +@auto.doc() +def getCourseByCampusName(name): + ''' + 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 = Course.all() + query.filter("title = ", name) + + for c in query.run(limit=5): + return Response(response=c.key().id(), + status=200, + mimetype="application/json") # Real response! + + return bad_request("No Campus Found") + @course_routes.route('/api/courses/help') def documentation(): return auto.html() \ No newline at end of file From fd11a512bd1faf8c6d57fd602fd9044f6f8d3f37 Mon Sep 17 00:00:00 2001 From: Matan Bar Yosef Date: Mon, 15 Jun 2015 17:46:02 +0300 Subject: [PATCH 23/36] changing branch name to UI --- .../js/controllers/registerController.js | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/templates/js/controllers/registerController.js b/templates/js/controllers/registerController.js index c243edc..71abbaa 100644 --- a/templates/js/controllers/registerController.js +++ b/templates/js/controllers/registerController.js @@ -1,7 +1,6 @@ angular.module('SeHub') .controller('registerController', ['$scope', '$cookies', '$cookieStore', '$window', '$location', '$mdToast', '$mdDialog', 'apiService', '$rootScope', function ($scope, $cookies, $cookieStore, $window, $location, $mdToast, $mdDialog, apiService ,$rootScope) { - $scope.userHasNoName = false; $scope.campusChecked = false; $scope.isEmpty = true; // if the academic email line is empty @@ -31,7 +30,6 @@ angular.module('SeHub') { // TODO }); - }); $scope.dropdownClicked = function() @@ -67,6 +65,28 @@ angular.module('SeHub') }); }; }; + + + // TODO FOR LATER - toast + // TODO FOR LATER + + // $scope.getPopWindowPosition = function() + // { + // return Object.keys($scope.toastPosition).filter(function(pos) + // { + // return $scope.toastPosition[pos]; + // }).join(' '); + // }; + + // $scope.toastPosition = + // { + // bottom: false, + // top: true, + // left: false, + // right: true + // }; + + // TODO FOR LATER + // TODO FOR LATER + }]); - - From ed7519305bee84f26bc1ffeb610361457eab57ff Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 18:07:15 +0300 Subject: [PATCH 24/36] AngularJS: Finally fixed the logo in welcome screen! --- templates/css/theme.css | 4 ++++ templates/index.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/css/theme.css b/templates/css/theme.css index 7a1abfb..75bff2e 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -15,6 +15,10 @@ md-list .md-button { width: 100%; } +.welcome-logo-banner{ + width: 100%; +} + /* Using Data-URI converted from svg until becomes available https://github.com/google/material-design-icons */ diff --git a/templates/index.html b/templates/index.html index c5e3215..e612d8e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -14,7 +14,7 @@
- +

Wellcome To SE-Hub!

From 39a5697fd0793e2ce32a95d2996e3e1e9548c2ff Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 18:15:36 +0300 Subject: [PATCH 25/36] Added small Shadow to avatars - looks better --- templates/css/theme.css | 76 +++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/templates/css/theme.css b/templates/css/theme.css index 75bff2e..a8b0155 100644 --- a/templates/css/theme.css +++ b/templates/css/theme.css @@ -63,74 +63,82 @@ body.noscroll } .avatar { - margin-top: 1em; - margin-right: 1em; - position: center; + margin-top: 1em; + margin-right: 1em; + position: center; + + -webkit-border-radius: 30%; + -moz-border-radius: 30%; + border-radius: 30%; + - -webkit-border-radius: 30%; - -moz-border-radius: 30%; - border-radius: 30%; } /*.avatar { background: rgba(0, 0, 0, 0.2); -}*/ + }*/ -.avatar img { - border-radius: 40px; - position:center; - width: 80px; - height: 80px; - margin: 6px; /*centers the image in the parent element */ -} + .avatar img { + border-radius: 40px; + position:center; + width: 80px; + height: 80px; + margin: 6px; /*centers the image in the parent element */ + -webkit-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.75); + -moz-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.75); + box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.75); + } -/* Added BY devMatan */ + /* Added BY devMatan */ /*.disabledSubmitButton: { /*background: #f7f7f7;*/ /*border-radius: 10000px;*/ /*text-align: center;*/ - + /*position: relative !important;* -}*/ + }*/ -.campusAvatar img -{ + .campusAvatar img + { /* margin-top: 1em; margin-right: 1em; position: center; -*/ - + */ + border-radius: 40px; position:center; width: 80px; height: 80px; margin: 6px; -} + -webkit-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.75); + -moz-box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.75); + box-shadow: 2px 2px 5px 0px rgba(0,0,0,0.75); + } -.spacer{ - margin-right: auto; - margin-left: auto; -} + .spacer{ + margin-right: auto; + margin-left: auto; + } -.port_spacer{ - margin-top: auto; - margin-bottom: auto; -} + .port_spacer{ + margin-top: auto; + margin-bottom: auto; + } -.mail_suffix{ - margin-top: auto; -} + .mail_suffix{ + margin-top: auto; + } /*div.img campusAvatar { border: 1px solid #0000ff; padding-right: 10px; float:right; -}*/ + }*/ /*.dropDown /* TODO * { From ab4cdab12da2ccb721b2fd938567e317419d7398 Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 18:34:02 +0300 Subject: [PATCH 26/36] removed project list from course and added course to project --- models/Course.py | 4 ++-- models/Project.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/models/Course.py b/models/Course.py index 4b3abe5..fd2dc08 100644 --- a/models/Course.py +++ b/models/Course.py @@ -7,7 +7,7 @@ class Course(db.Model): courseName = db.StringProperty(required=True) campusName = db.StringProperty(required=True) master_id = db.IntegerProperty(required=True) - projects = db.StringListProperty(required=True,default=[]) + # projects = db.StringListProperty(required=True,default=[]) startDate = db.DateProperty(required=True) endDate = db.DateProperty(required=True) @@ -15,7 +15,7 @@ class Course(db.Model): data = {'courseName' : self.courseName, 'campusName' : self.campusName, 'master_id' : self.master_id, - 'projects' : self.projects, + # 'projects' : self.projects, 'startDate' : { 'year': self.startDate.year, 'month': self.startDate.month, diff --git a/models/Project.py b/models/Project.py index 97db04e..579ecdd 100644 --- a/models/Project.py +++ b/models/Project.py @@ -5,6 +5,7 @@ from google.appengine.ext import db class Project(db.Model): projectName = db.StringProperty(required=True) + courseName = db.StringProperty(required=True) master_id = db.IntegerProperty(required=True) grade = db.IntegerProperty(required=True, default=0) logo_url = db.StringProperty(required=False) @@ -13,6 +14,7 @@ class Project(db.Model): def to_JSON(self): data = {'projectName' : self.projectName, + 'courseName' : self.courseName, 'master_id' : self.master_id, 'grade' : self.grade, 'logo_url' : self.logo_url, From 991d6a73bcd7083c1ef5c06026296ad8b58d2f6c Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 18:35:47 +0300 Subject: [PATCH 27/36] added some data verifiaction --- SE_API/CourseRoutes.py | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index 4131674..95a2539 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -48,13 +48,16 @@ def create_course(token): """ if not request.data: return bad_request() - payload = json.loads(request.data) if not is_lecturer(token): #todo: change to lecturer id return forbidden("Invalid token or not a lecturer!") user = get_user_by_token(token) - #todo: check legality + #try to parse payload + try: + payload = json.loads(request.data) + except Exception as e: + return bad_request(e) try: @@ -64,10 +67,20 @@ def create_course(token): course = Course(courseName=payload['courseName'], campusName=payload['campusName'], startDate=start_date, endDate=end_date) + #check if name already exists try: - course.projects=payload['projects'] - except Exception: - pass + query = Course.all() + query.filter("courseName = ", payload['courseName']) + for c in query.run(limit=1): + return forbidden("Campus with same name already exists") + except Exception as e: + print e + + #check if and projects needs to be added + # try: + # course.projects=payload['projects'] + # except Exception: + # pass except Exception: @@ -116,15 +129,23 @@ def getCourseByCampusName(name):
403 - Invalid Token ''' + + arr = [] query = Course.all() - query.filter("title = ", name) + query.filter("campusName = ", name) - for c in query.run(limit=5): - return Response(response=c.key().id(), + for c in query.run(): + arr.append(dict(json.loads(c.to_JSON()))) + print arr + if len(arr) != 0: + return Response(response=json.dumps(arr), status=200, - mimetype="application/json") # Real response! + mimetype="application/json") + else: + return Response(response=[], + status=200, + mimetype="application/json") - return bad_request("No Campus Found") @course_routes.route('/api/courses/help') def documentation(): From 1d9cbbfa6b1108cc5aa76f0bae838d2645127aeb Mon Sep 17 00:00:00 2001 From: aranzaiger Date: Mon, 15 Jun 2015 18:37:08 +0300 Subject: [PATCH 28/36] getProjectsByCourseName function fix --- SE_API/ProjectRoutes.py | 87 +++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/SE_API/ProjectRoutes.py b/SE_API/ProjectRoutes.py index 44c2015..46d35cc 100644 --- a/SE_API/ProjectRoutes.py +++ b/SE_API/ProjectRoutes.py @@ -26,9 +26,9 @@ from SE_API.Respones_Utils import * project_routes = Blueprint("project_routes", __name__) auto = Autodoc() -@project_routes.route('/api/projects/Create//', methods=['POST']) +@project_routes.route('/api/projects/create/', methods=['POST']) @auto.doc() -def create_project(token,id): +def create_project(token): """ This call will create a new project in the DB
@@ -62,7 +62,7 @@ def create_project(token,id): #todo: check legality try: - project = Project(projectName=payload['projectName'], masterId=user.key().id(), gitRepository=payload['gitRepository'], membersId=[token]) + project = Project(projectName=payload['projectName'], courseName=payload['courseName'], masterId=user.key().id(), gitRepository=payload['gitRepository'], membersId=[token]) except Exception as e: print e return bad_request() @@ -77,62 +77,55 @@ def create_project(token,id): -@project_routes.route('/api/projects/getAll/', methods=['GET']) +@project_routes.route('/api/projects/getProjectsByCourseName/', methods=["GET"]) @auto.doc() -def get_projects(token): - """ - This Call will return an array of all projects available +def getProjectsByCourseName(name): + ''' + This Function is will Activate a user and add tha campus to it
Route Parameters
- - seToken: 'seToken' + - validation_token: 'seToken|email_suffix'

Payload
- - NONE
+ - NONE

Response
- 200 - JSON Array, Example:
- [
- { - 'title': 'JCE',
- 'email_ending': '@post.jce.ac.il',
- 'master_user_id': 123453433341, (User that created the campus)
- 'avatar_url': 'http://some.domain.com/imagefile.jpg'
- },
- ....
- {
- ...
- }req
- ]
+ 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
- 500 - Server Error - """ - if is_user_token_valid(token): - arr = [] - query = Campus.all() - for c in query.run(): - arr.append(dict(json.loads(c.to_JSON()))) - print arr - if len(arr) != 0: - return Response(response=json.dumps(arr), - status=200, - mimetype="application/json") - else: - return Response(response=[], - status=200, - mimetype="application/json") + 403 - Invalid Token + ''' + + arr = [] + query = Project.all() + query.filter("courseName = ", name) + + for p in query.run(): + arr.append(dict(json.loads(p.to_JSON()))) + print arr + if len(arr) != 0: + return Response(response=json.dumps(arr), + status=200, + mimetype="application/json") else: - return forbidden("Invalid Token") - - - -@project_routes.route('/api/Projects/', methods=['GET']) -@auto.doc() -def get_campuses(token): - pass + return Response(response=[], + status=200, + mimetype="application/json") From 73d9a65dab043d2f489727f3a565b12298ed4c68 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 15 Jun 2015 18:41:44 +0300 Subject: [PATCH 29/36] AngularJS: Fixed Scope Issue & more Starting to work on the mailController --- templates/index.html | 10 ++++----- templates/js/app.js | 7 +++--- templates/js/controllers/mainController.js | 15 ++++++++----- templates/views/index.html | 26 +++++++++++++++++++--- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/templates/index.html b/templates/index.html index e612d8e..a94ff2e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -32,11 +32,11 @@ - - - - - + + + + + diff --git a/templates/js/app.js b/templates/js/app.js index 46b8d12..9b93421 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -14,8 +14,10 @@ welcome.controller('welcomeController', ['$scope', 'apiService', '$cookies', '$w console.log("Welcome Controller"); var uid = $cookies['com.sehub.www']; - if(uid) + if(uid){ + console.info("Session in Place"); $window.location.href = DEBUG ? 'http://localhost:8080/home' : 'http://se-hub.appspot.com/home'; + } @@ -26,8 +28,7 @@ app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { $routeProvider .when('/', { - templateUrl: 'templates/views/home.html', - controller: 'mainController' + templateUrl: 'templates/views/home.html' }) .when('/register', { templateUrl: 'templates/views/register.html', diff --git a/templates/js/controllers/mainController.js b/templates/js/controllers/mainController.js index c27cf90..d05f895 100644 --- a/templates/js/controllers/mainController.js +++ b/templates/js/controllers/mainController.js @@ -1,19 +1,24 @@ angular.module('SeHub') .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function ($scope, $rootScope, apiService, $cookies, $location) { - $rootScope.seToken = $cookies['com.sehub.www']; - var token = $rootScope.seToken; + var token = $cookies['com.sehub.www']; + $scope.loadingData = true; + $scope.isInRegisterMode = false; apiService.getUserByToken(token).success(function(data){ - console.log(data); - if(data.message == 'No User Found') + if(data.message == 'No User Found'){ console.error("No User Found!"); + } $scope.user = data; $rootScope.user = data; - if($scope.user.isFirstLogin) + if($scope.user.isFirstLogin){ + $scope.menuObj = {}; + $scope.isInRegisterMode = true; + $scope.loadingData = false; $location.path('/register') + } }) $scope.loadingData = false; diff --git a/templates/views/index.html b/templates/views/index.html index 816e633..fcc374d 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -8,8 +8,8 @@ - - + +