Skip to content
This repository has been archived by the owner on Jan 1, 2020. It is now read-only.

Commit

Permalink
add new update method
Browse files Browse the repository at this point in the history
  • Loading branch information
sdayu committed Sep 26, 2015
1 parent 6882be3 commit 8508d06
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions nokkhumapi/views/admin/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,36 @@ def get(self):

return result

@view_config(request_method='PUT')
def update(self):
matchdict = self.request.matchdict
processor_id = matchdict.get('processor_id')

processor = models.Processor.objects(id=processor_id).first()

if not processor:
self.request.response.status = '404 Not Found'
return {}

processor_dict = self.request.json_body["processor"]

processor.name = processor_dict['name']
processor.storage_period = processor_dict['storage_period']
processor.image_processors = processor_dict['image_processors']

processor.cameras = list()
for camera_attribute in processor_dict['cameras']:
camera = models.Camera.objects(id=camera_attribute['id']).first()
processor.cameras.append(camera)

processor.save()
processor.reload()

return dict(
processor=self.build_result(processor)
)


@view_config(route_name='admin.processors.resources',
permission='admin',
request_method='GET')
Expand Down

0 comments on commit 8508d06

Please sign in to comment.