Added editing of shots
This commit is contained in:
@@ -80,3 +80,28 @@ class ShotManager(object):
|
||||
shot_id_to_tasks[task.parent][task_type].add(task)
|
||||
|
||||
return shot_id_to_tasks
|
||||
|
||||
def edit_shot(self, shot_id, **fields):
|
||||
"""Edits a shot.
|
||||
|
||||
:type shot_id: str
|
||||
:type fields: dict
|
||||
:rtype: pillarsdk.Node
|
||||
"""
|
||||
|
||||
api = pillar_api()
|
||||
shot = pillarsdk.Node.find(shot_id, api=api)
|
||||
|
||||
shot.name = fields.pop('name')
|
||||
shot.description = fields.pop('description')
|
||||
shot.properties.status = fields.pop('status')
|
||||
shot.properties.notes = fields.pop('notes', '').strip() or None
|
||||
|
||||
self._log.info('Saving shot %s', shot.to_dict())
|
||||
|
||||
if fields:
|
||||
self._log.warning('edit_shot(%r, ...) called with unknown fields %r; ignoring them.',
|
||||
shot_id, fields)
|
||||
|
||||
shot.update(api=api)
|
||||
return shot
|
||||
|
@@ -72,6 +72,18 @@ def view_shot(project, attract_props, shot_id):
|
||||
attract_props=attract_props)
|
||||
|
||||
|
||||
@perproject_blueprint.route('/<shot_id>', methods=['POST'])
|
||||
@attract_project_view()
|
||||
def save(project, shot_id):
|
||||
log.info('Saving shot %s', shot_id)
|
||||
log.debug('Form data: %s', request.form)
|
||||
|
||||
shot_dict = request.form.to_dict()
|
||||
shot = current_attract.shot_manager.edit_shot(shot_id, **shot_dict)
|
||||
|
||||
return flask.jsonify({'shot_id': shot_id, 'etag': shot._etag, 'time': shot._updated })
|
||||
|
||||
|
||||
# TODO: remove GET method once Pablo has made a proper button to call this URL with a POST.
|
||||
@perproject_blueprint.route('/create', methods=['POST', 'GET'])
|
||||
@attract_project_view()
|
||||
|
Reference in New Issue
Block a user