diff --git a/SE_API/CourseRoutes.py b/SE_API/CourseRoutes.py index 7075f36..578b36c 100644 --- a/SE_API/CourseRoutes.py +++ b/SE_API/CourseRoutes.py @@ -113,64 +113,6 @@ def create_course(token): mimetype="application/json") - - -@course_routes.route('/api/courses/createMessage/', methods=['POST']) -@auto.doc() -def createMessage(token): - """ - This call will create a new Message in the DB -
- Route Parameters
- - seToken: 'seToken' -
-
- Payload
- - JSON Object, Example:
- {
- 'courseName': 'Advance Math',
- 'message': 'The lecture today is canceled'
- }
-
-
- Response -
- 201 - Created -
- 400 - Bad Request -
- 403 - Invalid token or not a lecturer - """ - if not request.data: - return bad_request("no 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("here") - - try: - msg = Message(groupId=payload['groupId'], message=payload['message'], msgDate=datetime.datetime.now(), master_id=user.key().id()) - except Exception as e: - print e - return bad_request("there") - - try: - msg['isProject'] = payload['isProject'] - except Exception as e: - pass - - db.save(msg) - db.save - return created() - - - #---------------------------------------------------------- # PUT #---------------------------------------------------------- @@ -274,7 +216,7 @@ def getCourseByCampusName(name): @course_routes.route('/api/courses/getCoursesByUser//', methods=['GET']) @auto.doc() -def getCampusesByUser(token,campusId): +def getCampusesByUser(token, campusId): """ This Call will return an array of all Campuses of a certain User
@@ -332,61 +274,6 @@ def getCampusesByUser(token,campusId): mimetype="application/json") -@course_routes.route('/api/courses/getMessagesByCourseName/', methods=["GET"]) -@auto.doc() -def getMessagesByCourseName(name): - """ - >This Call will return an array of all courses in a given campus -
- Route Parameters
- - name: 'campus name' -
-
- Payload
- - NONE -
-
- Response -
- 200 - JSON Example:
- - {
- 'courseName': 'Advance Math',
- 'campusName': 'JCE',
- 'startDate': '2015-14-3'
- 'endDate': '2015-29-6'
- 'taskFlag': false,
- 'id' : 1234567890
- - } -
-
- """ - arr = [] - query = Message.all() - query.filter("courseName = ", name) - - for m in query.run(): - msgDic = dict(json.loads(m.to_JSON())) - #add a key 'forSortDate' for sorting dates - msgTime = datetime.datetime(msgDic['date']['year'], msgDic['date']['month'], msgDic['date']['day'], msgDic['date']['hour'], msgDic['date']['minute']) - msgDic['forSortDate'] = msgTime - arr.append(msgDic) - - arr = sorted(arr, key=itemgetter('forSortDate'), reverse=False) - for i in arr: - del i['forSortDate'] - 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") - #---------------------------------------------------------- # PUT #----------------------------------------------------------