(self, sketch_id)
return abort(
            HTTP_STATUS_CODE_NOT_FOUND,
            'The action: [{0:s}] is not supported.'.format(action))
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)
        """
        if current_user.admin:
            sketch = Sketch.query.get(sketch_id)
        else:
            sketch = Sketch.query.get_with_acl(sketch_id)

        if not sketch:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND, 'No sketch found with this ID.')

        self._sketch = sketch
        form = request.json
        if not form:
            form = request.data

        action = form.get('action', '')
        if action == 'archive':
            if not sketch.has_permission(current_user, 'delete'):
                if not current_user.admin:
                    abort(
                        HTTP_STATUS_CODE_FORBIDDEN,
                        'User does not have sufficient access rights to '
                        'delete a sketch.')

            return self._archive_sketch(sketch)

        if action == 'export':
            if not sketch.has_permission(current_user, 'read'):
                abort(
                    HTTP_STATUS_CODE_FORBIDDEN,
                    'User does not have sufficient access rights to '
                    'read from a sketch.')

            return self._export_sketch(sketch)

        if action == 'unarchive':
            if not sketch.has_permission(current_user, 'delete'):
                if not current_user.admin:
                    abort(
                        HTTP_STATUS_CODE_FORBIDDEN,
                        'User does not have sufficient access rights to '
                        'unarchive a sketch.')

            return self._unarchive_sketch(sketch)

        return abort(
            HTTP_STATUS_CODE_NOT_FOUND,
            'The action: [{0:s}] is not supported.'.format(action))
def post ( self , sketch_id ) : if current_user . admin : sketch = Sketch . query . get ( sketch_id ) else : sketch = Sketch . query . get_with_acl ( sketch_id ) if not sketch : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No sketch found with this ID.' ) self . _sketch = sketch form = request . json if not form : form = request . data action = form . get ( 'action' , '' ) if action == 'archive' : if not sketch . has_permission ( current_user , 'delete' ) : if not current_user . admin : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'User does not have sufficient access rights to ' 'delete a sketch.' ) return self . _archive_sketch ( sketch ) if action == 'export' : if not sketch . has_permission ( current_user , 'read' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'User does not have sufficient access rights to ' 'read from a sketch.' ) return self . _export_sketch ( sketch ) if action == 'unarchive' : if not sketch . has_permission ( current_user , 'delete' ) : if not current_user . admin : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'User does not have sufficient access rights to ' 'unarchive a sketch.' ) return self . _unarchive_sketch ( sketch ) return abort ( HTTP_STATUS_CODE_NOT_FOUND , 'The action: [{0:s}] is not supported.' . format ( action ) )