def create_shot(request):
"""runs when adding a new shot
"""
logged_in_user = get_logged_in_user(request)
name = request.params.get('name')
code = request.params.get('code')
status_id = request.params.get('status_id')
status = Status.query.filter_by(id=status_id).first()
project_id = request.params.get('project_id')
project = Project.query.filter_by(id=project_id).first()
logger.debug('project_id : %s' % project_id)
if name and code and status and project:
# get descriptions
description = request.params.get('description')
sequence_id = request.params['sequence_id']
sequence = Sequence.query.filter_by(id=sequence_id).first()
# get the status_list
status_list = StatusList.query.filter_by(
target_entity_type='Shot'
).first()
# there should be a status_list
# TODO: you should think about how much possible this is
if status_list is None:
return HTTPServerError(detail='No StatusList found')
new_shot = Shot(
name=name,
code=code,
description=description,
sequence=sequence,
status_list=status_list,
status=status,
created_by=logged_in_user,
project=project
)
DBSession.add(new_shot)
else:
logger.debug('there are missing parameters')
logger.debug('name : %s' % name)
logger.debug('code : %s' % code)
logger.debug('status : %s' % status)
logger.debug('project : %s' % project)
HTTPServerError()
return HTTPOk()
评论列表
文章目录