def get(self): try: try: MovieSearchSchema().load(self.post_data) except ValidationError as e: return render_error_response(message=str(e), code=422) movies = search_movies(self.post_data) self.data = {"movies": movies} except Exception as e: print(e) return render_error_response() return render_success_response(data=self.data, message="Movie Listed Successfully", code=200)
def post(self): try: try: NewUser().load(self.post_data) except ValidationError as e: return render_error_response(message=str(e), code=422) user_exist = check_user_exist(self.post_data.get('email')) if user_exist: return render_error_response(message="User Exist!!!", code=409) token = add_new_user(self.post_data) self.data['token'] = token except Exception as e: print(e) return render_error_response() return render_success_response(data=self.data, message="User Created Successfully", code=201)
def post(self): try: self.check_authorisation() try: MovieSchema().load(self.post_data) except ValidationError as e: return render_error_response(message=str(e), code=422) movie_exist = check_movie_exist(self.post_data.get('name')) if movie_exist: return render_error_response(message="Movie Already Exist!!!", code=409) add_movie(self.post_data, self.user_details) except Exception as e: print(e) return render_error_response() return render_success_response(data=self.data, message="Movie Added Successfully", code=201)
def put(self): try: self.check_authorisation() try: MovieUpdateSchema().load(self.post_data) except ValidationError as e: return render_error_response(message=str(e), code=422) movie_exist = check_movie_exist(self.post_data.get('name')) if not movie_exist: return render_error_response(message="Movie Does not Exist!!!", code=404) update_movie(self.post_data, self.user_details, movie_exist) except Exception as e: print(e) return render_error_response() return render_success_response(data=self.data, message="Movie Updated Successfully", code=202)
def get(self): try: try: MovieDetailsSchema().load(self.post_data) except ValidationError as e: return render_error_response(message=str(e), code=422) movie_exist = check_movie_exist(self.post_data.get('name')) if not movie_exist: return render_error_response(message="Movie Not Found !!!", code=404) movie_data = movie_exist.to_json() self.data = {"movie_details": movie_data} except Exception as e: print(e) return render_error_response() return render_success_response(data=self.data, message="Successful", code=200)