Пример #1
0
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
Пример #2
0
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	
Пример #3
0
 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
Пример #4
0
	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
Пример #5
0
 def get(self):
     try:
         videos = Video.get_list()
     except Exception as e:
         logger.exception(e)
         return {'message': str(e)}, 400
     return videos
Пример #6
0
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
Пример #7
0
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
Пример #8
0
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
Пример #9
0
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
Пример #11
0
 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
Пример #12
0
def video(user, session):
    video = Video(
        user_id=user.id,
        name='Video 1',
        description='Description'
    )
    session.add(video)
    session.commit()

    return video
Пример #13
0
 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
Пример #14
0
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
Пример #15
0
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
Пример #16
0
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
Пример #17
0
 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
Пример #18
0
 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
Пример #19
0
def video(user, session):
    video = Video(user_id=user.id, name='Видео 1', desc='Тестовое описание')
    session.add(video)
    session.commit()

    return video