def add_list(**kwargs): try: user_id = get_jwt_identity() new_one = Video(user_id=user_id, **kwargs) new_one.save() except Exception as e: logger.exception(e) return {'message': str(e)}, 400 return new_one
def update_list(**kwargs): try: user_id = get_jwt_identity() new_one = Video(user_id=user_id,**kwargs) new_one.save() except Exception as e: logger.warning(f'user:{user_id} tutorials - create action filed with error: {e}') return {'message':str(e)}, 400 return new_one
def post(self, **kwargs): # создать новое видео для пользователя user_id user_id = get_jwt_identity() try: new_tutorial = Video(user_id=user_id, **kwargs) new_tutorial.save_video() except Exception as e: logger.warning( f'user {user_id}: tutorials - create action failed with errors: {str(e)}\n' ) return {'message': str(e)}, 400 return new_tutorial
def get(self): try: videos = Video.get_list() except Exception as e: logger.warning(f' tutorials - read action filed with error: {e}') return {'message':str(e)}, 400 return videos
def get(self): try: videos = Video.get_list() except Exception as e: logger.exception(e) return {'message': str(e)}, 400 return videos
def get_list(): try: user_id = get_jwt_identity() videos = Video.get_user_list(user_id=user_id) except Exception as e: logger.exception(e) return {'message': str(e)}, 400 return videos
def get_list(): try: user_id = get_jwt_identity() videos = Video.get_user_list(user_id=user_id) except Exception as e: logger.warning( f'user:{user_id} tutorials - read action failed with errors: {e}') return {'message': str(e)}, 400 return videos
def delete_list(tutorial_id): try: user_id = get_jwt_identity() item = Video.get(tutorial_id=tutorial_id, user_id=user_id) item.delete() except Exception as e: logger.exception(e) return {'message': str(e)}, 400 return '', 204
def update_list(tutorial_id: int, **kwargs): try: user_id = get_jwt_identity() item = Video.get(tutorial_id, user_id) item.update(**kwargs) except Exception as e: logger.exception(e) return {'message': str(e)}, 400 return item
def video(user, session): video = Video( user_id=user.id, name='Test Video', description='Just test video', ) session.add(video) session.commit() return video
def get(self, tut_id): user_id = get_jwt_identity() try: tutorial = Video.get_video(tut_id=tut_id, user_id=user_id) except Exception as e: logger.warning( f'user {user_id}: tutorial {tut_id} - read action failed with errors: {str(e)}\n' ) return {'message': str(e)}, 400 return tutorial
def video(user, session): video = Video( user_id=user.id, name='Video 1', description='Description' ) session.add(video) session.commit() return video
def get(self): user_id = get_jwt_identity() try: videos = Video.get_user_list(user_id=user_id) except Exception as e: logger.warning( f'user {user_id}: tutorials - read action failed with errors: {str(e)}\n' ) return {'message': str(e)}, 400 return videos
def delete_tutorials(tutorials_id): try: user_id = get_jwt_identity() item = Video.get(tutorials_id,user_id) item.delete() except Exception as e: logger.warning(f'user:{user_id},tutorial_id:{tutorials_id} tutorials - delete action filed with error: {e}') return {'message':str(e)}, 400 return 204
def update_tutorial(tutorial_id, **kwargs): try: user_id = get_jwt_identity() item = Video.get(tutorial_id, user_id) item.update(**kwargs) except Exception as e: logger.warning( f'user:{user_id} tutorial:{tutorial_id} - update action failed with errors: {e}' ) return {'message': str(e)}, 400 return item
def update_tutorials(tutorials_id,**kwargs): try: user_id = get_jwt_identity() item = Video.update(tutorials_id,user_id,kwargs) except Exception as e: logger.warning(f'user:{user_id},tutorial_id:{tutorials_id} tutorials - update action filed with error: {e}') return {'message':str(e)}, 400 return item,200
def put(self, tut_id, **kwargs): # обновить видео video_id для пользователя user_id user_id = get_jwt_identity() try: item = Video.get_video(tut_id, user_id) item.update_video(**kwargs) except Exception as e: logger.warning( f'user {user_id}: tutorials {tut_id} - update action failed with errors: {str(e)}\n' ) return {'message': str(e)}, 400 return item
def delete(self, tut_id): # удалить видео video_id для пользователя user_id user_id = get_jwt_identity() try: item = Video.get_video(tut_id, user_id) if not item: return {'message': 'No tutorials with this id.'}, 400 item.delete_video() except Exception as e: logger.warning( f'user {user_id}: tutorials {tut_id} - delete action failed with errors: {str(e)}\n' ) return {'message': str(e)}, 400 return '', 204
def video(user, session): video = Video(user_id=user.id, name='Видео 1', desc='Тестовое описание') session.add(video) session.commit() return video