(self, sketch_id)
return self.to_json(sketch, status_code=HTTP_STATUS_CODE_CREATED)
Handles POST request to the resource.

        Returns:
            A sketch in JSON (instance of flask.wrappers.Response)
Handles POST request to the resource.
Handles POST request to the resource .
def post(self, sketch_id):
        """Handles POST request to the resource.

        Returns:
            A sketch in JSON (instance of flask.wrappers.Response)
        """
        sketch = Sketch.query.get_with_acl(sketch_id)
        if not sketch:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND, 'No sketch found with this ID.')

        if not sketch.has_permission(current_user, 'write'):
            abort(HTTP_STATUS_CODE_FORBIDDEN,
                  'User does not have write access controls on sketch.')

        form = request.json
        if not form:
            form = request.data

        update_object = False
        name = form.get('name', '')
        if name:
            sketch.name = name
            update_object = True

        description = form.get('description', '')
        if description:
            sketch.description = description
            update_object = True

        labels = form.get('labels', [])
        label_action = form.get('label_action', 'add')
        if label_action not in ('add', 'remove'):
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Label actions needs to be either "add" or "remove", '
                'not [{0:s}]'.format(label_action))

        if labels and isinstance(labels, (tuple, list)):
            for label in labels:
                if label_action == 'add':
                    changed = self._add_label(sketch=sketch, label=label)
                elif label_action == 'remove':
                    changed = self._remove_label(sketch=sketch, label=label)

                if changed:
                    update_object = True

        if update_object:
            db_session.add(sketch)
            db_session.commit()

        return self.to_json(sketch, status_code=HTTP_STATUS_CODE_CREATED)
def post ( self , sketch_id ) : sketch = Sketch . query . get_with_acl ( sketch_id ) if not sketch : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No sketch found with this ID.' ) if not sketch . has_permission ( current_user , 'write' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'User does not have write access controls on sketch.' ) form = request . json if not form : form = request . data update_object = False name = form . get ( 'name' , '' ) if name : sketch . name = name update_object = True description = form . get ( 'description' , '' ) if description : sketch . description = description update_object = True labels = form . get ( 'labels' , [ ] ) label_action = form . get ( 'label_action' , 'add' ) if label_action not in ( 'add' , 'remove' ) : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Label actions needs to be either "add" or "remove", ' 'not [{0:s}]' . format ( label_action ) ) if labels and isinstance ( labels , ( tuple , list ) ) : for label in labels : if label_action == 'add' : changed = self . _add_label ( sketch = sketch , label = label ) elif label_action == 'remove' : changed = self . _remove_label ( sketch = sketch , label = label ) if changed : update_object = True if update_object : db_session . add ( sketch ) db_session . commit ( ) return self . to_json ( sketch , status_code = HTTP_STATUS_CODE_CREATED )