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

        Args:
          sketch_id (int): Identifier for the Sketch the datasource belongs to.

        Returns:
            A datasource 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.

        Args:
          sketch_id (int): Identifier for the Sketch the datasource belongs to.

        Returns:
            A datasource 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 sketch.get_status.status == 'archived':
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to fetch data sources from an archived sketch.')

        if not sketch.has_permission(current_user, 'write'):
            abort(
                HTTP_STATUS_CODE_FORBIDDEN, (
                    'User does not have sufficient write access to '
                    'to the sketch.'))

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

        timeline_id = form.get('timeline_id')
        if not timeline_id:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to create a data source without a timeline '
                'identifier.')

        timeline = Timeline.query.get(timeline_id)
        if not timeline:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND,
                'No timeline found with this ID.')

        if timeline not in sketch.active_timelines:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND,
                'The timeline is not part of the active timelines in '
                'the sketch.')

        datasource = DataSource(
            timeline=timeline,
            user=current_user,
            provider=form.get('provider', 'N/A'),
            context=form.get('context', 'N/A'),
            file_on_disk='',
            file_size=0,
            original_filename=form.get('original_filename', ''),
            data_label=form.get('data_label', 'data')
        )

        timeline.datasources.append(datasource)
        db_session.add(datasource)
        db_session.add(timeline)
        db_session.commit()

        return self.to_json(datasource, 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 sketch . get_status . status == 'archived' : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to fetch data sources from an archived sketch.' ) if not sketch . has_permission ( current_user , 'write' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , ( 'User does not have sufficient write access to ' 'to the sketch.' ) ) form = request . json if not form : form = request . data timeline_id = form . get ( 'timeline_id' ) if not timeline_id : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to create a data source without a timeline ' 'identifier.' ) timeline = Timeline . query . get ( timeline_id ) if not timeline : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No timeline found with this ID.' ) if timeline not in sketch . active_timelines : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'The timeline is not part of the active timelines in ' 'the sketch.' ) datasource = DataSource ( timeline = timeline , user = current_user , provider = form . get ( 'provider' , 'N/A' ) , context = form . get ( 'context' , 'N/A' ) , file_on_disk = '' , file_size = 0 , original_filename = form . get ( 'original_filename' , '' ) , data_label = form . get ( 'data_label' , 'data' ) ) timeline . datasources . append ( datasource ) db_session . add ( datasource ) db_session . add ( timeline ) db_session . commit ( ) return self . to_json ( datasource , status_code = HTTP_STATUS_CODE_CREATED )