diff --git a/SE_API/API.py b/SE_API/API.py index bbf7921..91cfb16 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -254,9 +254,8 @@ def create_campus(token):
403 - Invalid Token/Forbidden """ - 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) @@ -272,7 +271,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") @@ -284,6 +283,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()