def delete_from_cart(course, user, sem): auth_header = request.headers.get('Authorization') try: status = Jwt.decode_auth_token(auth_header) if (status): response = Service.delete_from_cart(course, user, sem) if (response): return jsonify({"response": "Success"}), 200 else: return jsonify({"Error": "Something went wrong"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def update_color_theme(theme, student): auth_header = request.headers.get('Authorization') try: status = Jwt.decode_auth_token(auth_header) if (status): response = Service.update_color_theme(theme, student) if (response == True): return jsonpickle.encode(response, unpicklable=False), 200 else: return jsonify({"Error": "Something went wrong"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def get_students_by_course(id): auth_header = request.headers.get('Authorization') try: status = Jwt.decode_auth_token(auth_header) if (status): response = Service.get_students_by_course(id) if (response): return jsonpickle.encode(response, unpicklable=False), 200 else: return jsonify({"Error": "Something went wrong"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def get_all_professors(start, end): auth_header = request.headers.get('Authorization') try: status = Jwt.decode_auth_token(auth_header) if (status): response = Service.get_all("PROFESSORS", start, end) if (response): return jsonpickle.encode(response, unpicklable=False), 200 else: return jsonify({"Error": "Something went wrong"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def enroll_courses(): auth_header = request.headers.get('Authorization') data = request.json try: status = Jwt.decode_auth_token(auth_header) if (status): response = Service.enroll_courses(data) if (response): return jsonpickle.encode(response, unpicklable=False), 200 else: return jsonify({'Error': "Course timings clash"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def drop_course(course_id, user_id, sem): auth_header = request.headers.get('Authorization') data = request.json try: status = Jwt.decode_auth_token(auth_header) if (status): response = Service.delete_enrolled_course(user_id, course_id, sem) if (response): return jsonify({'Success': "Dropped the course"}), 200 else: return jsonify({'Error': "Something went wrong"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def update_financial_aid(value, student): auth_header = request.headers.get('Authorization') try: status = Jwt.decode_auth_token(auth_header) if (status): if (status['role'] == str(1)): response = Service.update_financial_aid(value, student) if (response == True): return jsonpickle.encode(response, unpicklable=False), 200 else: return jsonify({"Error": "Something went wrong"}), 500 else: return jsonify({"Error": "Unauthorised"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def get_all_students(start, end): auth_header = request.headers.get('Authorization') try: status = Jwt.decode_auth_token(auth_header) if (status): if (status['role'] == str(1)): response = Service.get_all("STUDENTS", start, end) if (response): return jsonpickle.encode(response, unpicklable=False), 200 else: return jsonify({"Error": "Something went wrong"}), 500 else: return jsonify({"Error": "Unauthorised"}), 500 else: return jsonify({"Error": "Invalid token"}), 500 except Exception as e: return jsonify(e), 500
def auth_token(token): return Jwt.decode_auth_token(token)