(self, sketch_id)
return abort(
            HTTP_STATUS_CODE_BAD_REQUEST,
            'Unable to delete the attribute, couldn\'t find it.')
Handles delete request to the resource.

        Returns:
            A HTTP response code.
Handles delete request to the resource.
Handles delete request to the resource .
def delete(self, sketch_id):
        """Handles delete request to the resource.

        Returns:
            A HTTP response code.
        """
        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'):
            return abort(
                HTTP_STATUS_CODE_FORBIDDEN,
                'User does not have write permission on the sketch.')

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

        if not form:
            return abort(
                HTTP_STATUS_CODE_FORBIDDEN,
                'Unable to remove an attribute from a '
                'sketch without any data submitted.')

        for check in ['name', 'ontology']:
            error_message = self._validate_form_entry(form, check)
            if error_message:
                return abort(
                    HTTP_STATUS_CODE_BAD_REQUEST, error_message)

        name = form.get('name')
        ontology = form.get('ontology', 'text')

        for attribute in sketch.attributes:
            if attribute.name != name:
                continue
            if attribute.ontology != ontology:
                continue

            for value in attribute.values:
                attribute.values.remove(value)
            sketch.attributes.remove(attribute)
            db_session.commit()

            return HTTP_STATUS_CODE_OK

        return abort(
            HTTP_STATUS_CODE_BAD_REQUEST,
            'Unable to delete the attribute, couldn\'t find it.')
def delete ( 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' ) : return abort ( HTTP_STATUS_CODE_FORBIDDEN , 'User does not have write permission on the sketch.' ) form = request . json if not form : form = request . data if not form : return abort ( HTTP_STATUS_CODE_FORBIDDEN , 'Unable to remove an attribute from a ' 'sketch without any data submitted.' ) for check in [ 'name' , 'ontology' ] : error_message = self . _validate_form_entry ( form , check ) if error_message : return abort ( HTTP_STATUS_CODE_BAD_REQUEST , error_message ) name = form . get ( 'name' ) ontology = form . get ( 'ontology' , 'text' ) for attribute in sketch . attributes : if attribute . name != name : continue if attribute . ontology != ontology : continue for value in attribute . values : attribute . values . remove ( value ) sketch . attributes . remove ( attribute ) db_session . commit ( ) return HTTP_STATUS_CODE_OK return abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to delete the attribute, couldn\'t find it.' )