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

        Args:
            sketch_id: Integer primary key for a sketch database model

        Returns:
            An aggregation 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: Integer primary key for a sketch database model

        Returns:
            An aggregation 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(user=current_user, permission='write'):
            abort(
                HTTP_STATUS_CODE_FORBIDDEN,
                'The user does not have write permission on the sketch.')

        form = request.json
        if not form:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'No JSON data, unable to process request to create '
                'a new aggregation group.')

        aggregation_string = form.get('aggregations', '')
        if not aggregation_string:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to create an empty group.')

        agg_list = json.loads(aggregation_string)
        if not isinstance(agg_list, (list, tuple)):
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Aggregations needs to be a list of IDs.')

        named_aggs = sketch.get_named_aggregations
        aggregations = [agg for agg in named_aggs if agg.id in agg_list]

        # Create the aggregation in the database
        aggregation_group = AggregationGroup(
            name=form.get('name', 'No Group Name'),
            description=form.get('description', ''),
            parameters=form.get('parameters', ''),
            aggregations=aggregations,
            orientation=form.get('orientation', 'layer'),
            user=current_user,
            sketch=sketch,
            view=form.get('view_id')
        )
        db_session.add(aggregation_group)
        db_session.commit()

        # Update the last activity of a sketch.
        utils.update_sketch_last_activity(sketch)

        return self.to_json(
            aggregation_group, 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 ( user = current_user , permission = 'write' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'The user does not have write permission on the sketch.' ) form = request . json if not form : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'No JSON data, unable to process request to create ' 'a new aggregation group.' ) aggregation_string = form . get ( 'aggregations' , '' ) if not aggregation_string : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to create an empty group.' ) agg_list = json . loads ( aggregation_string ) if not isinstance ( agg_list , ( list , tuple ) ) : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Aggregations needs to be a list of IDs.' ) named_aggs = sketch . get_named_aggregations aggregations = [ agg for agg in named_aggs if agg . id in agg_list ] # Create the aggregation in the database aggregation_group = AggregationGroup ( name = form . get ( 'name' , 'No Group Name' ) , description = form . get ( 'description' , '' ) , parameters = form . get ( 'parameters' , '' ) , aggregations = aggregations , orientation = form . get ( 'orientation' , 'layer' ) , user = current_user , sketch = sketch , view = form . get ( 'view_id' ) ) db_session . add ( aggregation_group ) db_session . commit ( ) # Update the last activity of a sketch. utils . update_sketch_last_activity ( sketch ) return self . to_json ( aggregation_group , status_code = HTTP_STATUS_CODE_CREATED )