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

        Handler for /api/v1/sketches/:sketch_id/aggregation/:aggregation_id

        Args:
            sketch_id: Integer primary key for a sketch database model
            aggregation_id: Integer primary key for an aggregation database
                model
Handles POST request to the resource.
Handles POST request to the resource .
def post(self, sketch_id, aggregation_id):
        """Handles POST request to the resource.

        Handler for /api/v1/sketches/:sketch_id/aggregation/:aggregation_id

        Args:
            sketch_id: Integer primary key for a sketch database model
            aggregation_id: Integer primary key for an aggregation database
                model
        """
        form = request.json
        if not form:
            form = request.data

        if not form:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST, 'Unable to validate form data.')

        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'):
            abort(HTTP_STATUS_CODE_FORBIDDEN,
                  'User does not have write access controls on sketch.')

        aggregation = Aggregation.query.get(aggregation_id)
        if not aggregation:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND,
                'No aggregation 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.')

        aggregation.name = form.get('name', '')
        aggregation.description = form.get('description', '')
        aggregation.agg_type = form.get('agg_type', aggregation.agg_type)
        aggregation.chart_type = form.get('chart_type', aggregation.chart_type)
        aggregation.user = current_user
        aggregation.sketch = sketch

        labels = form.get('labels', '')
        if labels:
            for label in json.loads(labels):
                if aggregation.has_label(label):
                    continue
                aggregation.add_label(label)

        if form.get('parameters'):
            aggregation.parameters = json.dumps(
                form.get('parameters'), ensure_ascii=False)

        if form.get('view_id'):
            aggregation.view = form.get('view_id')

        db_session.add(aggregation)
        db_session.commit()

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

        return self.to_json(aggregation, status_code=HTTP_STATUS_CODE_CREATED)
def post ( self , sketch_id , aggregation_id ) : form = request . json if not form : form = request . data if not form : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to validate form data.' ) 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' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'User does not have write access controls on sketch.' ) aggregation = Aggregation . query . get ( aggregation_id ) if not aggregation : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No aggregation 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.' ) aggregation . name = form . get ( 'name' , '' ) aggregation . description = form . get ( 'description' , '' ) aggregation . agg_type = form . get ( 'agg_type' , aggregation . agg_type ) aggregation . chart_type = form . get ( 'chart_type' , aggregation . chart_type ) aggregation . user = current_user aggregation . sketch = sketch labels = form . get ( 'labels' , '' ) if labels : for label in json . loads ( labels ) : if aggregation . has_label ( label ) : continue aggregation . add_label ( label ) if form . get ( 'parameters' ) : aggregation . parameters = json . dumps ( form . get ( 'parameters' ) , ensure_ascii = False ) if form . get ( 'view_id' ) : aggregation . view = form . get ( 'view_id' ) db_session . add ( aggregation ) db_session . commit ( ) # Update the last activity of a sketch. utils . update_sketch_last_activity ( sketch ) return self . to_json ( aggregation , status_code = HTTP_STATUS_CODE_CREATED )