(self)
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):
        """Handles POST request to the resource.

        Returns:
            A sketch in JSON (instance of flask.wrappers.Response)
        """
        form = forms.NameDescriptionForm.build(request)
        if not form.validate_on_submit():
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST, 'Unable to validate form data.')
        sketch = Sketch(
            name=form.name.data,
            description=form.description.data,
            user=current_user)
        sketch.status.append(sketch.Status(user=None, status='new'))
        db_session.add(sketch)
        db_session.commit()

        # Give the requesting user permissions on the new sketch.
        sketch.grant_permission(permission='read', user=current_user)
        sketch.grant_permission(permission='write', user=current_user)
        sketch.grant_permission(permission='delete', user=current_user)
        return self.to_json(sketch, status_code=HTTP_STATUS_CODE_CREATED)
def post ( self ) : form = forms . NameDescriptionForm . build ( request ) if not form . validate_on_submit ( ) : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to validate form data.' ) sketch = Sketch ( name = form . name . data , description = form . description . data , user = current_user ) sketch . status . append ( sketch . Status ( user = None , status = 'new' ) ) db_session . add ( sketch ) db_session . commit ( ) # Give the requesting user permissions on the new sketch. sketch . grant_permission ( permission = 'read' , user = current_user ) sketch . grant_permission ( permission = 'write' , user = current_user ) sketch . grant_permission ( permission = 'delete' , user = current_user ) return self . to_json ( sketch , status_code = HTTP_STATUS_CODE_CREATED )