diff --git a/SE_API/API.py b/SE_API/API.py index d62914a..2fb2f16 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -45,24 +45,25 @@ def page_not_found(e): def wellcomePage(): return app.send_static_file('index.html') -@app.route('/api/validation/confirm/') +@app.route('/api/validation/confirm/', methods=["GET"]) @auto.doc() def confirm_user_to_campus(validation_token): """ This Function is will Activate a user and add tha campus to it
- Route Parameters - - :return: + Route Parameters
+ - validation_token: 'seToken|email_suffix' +
+
+ Payload
+ - NONE +
+
+ Response +
200 - redirect to home + new cookie +
403 - Invalid Token - main(){ - asd = 3 - } """ #TODO token = str(validation_token).split('|')[0] @@ -100,7 +101,8 @@ def send_activation(token): {email: 'academic@email.ac.com'}

- Response
+ Response +
200 - Email Sent - No Response
400 - Bad Request
403 - Invalid Token
@@ -143,9 +145,34 @@ def returnHome(): @auto.doc() def getUserByToken(token): ''' - param: String - token: users se-Token - return: JSON object of the user - if no valid seToken, return message: No User Found + 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) @@ -206,15 +233,26 @@ def oauth(oauth_token): @auto.doc() def create_campus(token): """ - This call will create a new campus in the DB - :param token: user seToken - Payload - {'title': self.title, - 'email_ending': self.email_ending, - 'avatar_url': self.avatar_url - } - :return: - code 200 + 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 """ print "1\n" if not request.data: @@ -231,7 +269,6 @@ def create_campus(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: @@ -242,7 +279,7 @@ def create_campus(token): db.put(campus) db.save return Response(response=json.dumps(campus.to_JSON()), - status=200, + status=201, mimetype="application/json") @@ -252,25 +289,34 @@ def create_campus(token): @auto.doc() def get_campuses(token): """ - This Call will return an array of all Campuses available - :param token: user seToken - :return: - code 200: - [ + 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 - ] - - code 403: Forbidden - Invalid Token - code 500: internal server error + '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 = []