(self, sketch_id, graph_id)
return self.to_json(graph, status_code=HTTP_STATUS_CODE_CREATED)
Handles GET request to the resource.

        Returns:
            List of graphs in JSON (instance of flask.wrappers.Response)
Handles GET request to the resource.
Handles GET request to the resource .
def post(self, sketch_id, graph_id):
        """Handles GET request to the resource.

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

        graph = Graph.query.get(graph_id)
        if not graph:
            abort(HTTP_STATUS_CODE_NOT_FOUND, 'No graph found with this ID.')

        if not sketch.id == graph.sketch.id:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Graph does not belong to this sketch.')

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

        name = form.get('name')
        if name:
            graph.name = name

        description = form.get('description')
        if description:
            graph.description = description

        elements = form.get('elements')
        if elements:
            graph.graph_elements = json.dumps(elements)

        graph_config = form.get('graph_config')
        graph_json = ''
        if graph_config:
            if isinstance(graph_config, dict):
                graph_json = json.dumps(graph_config)
            elif isinstance(graph_config, str):
                graph_json = graph_config
        if graph_json:
            graph.graph_config = graph_json

        db_session.add(graph)
        db_session.commit()

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

        return self.to_json(graph, status_code=HTTP_STATUS_CODE_CREATED)
def post ( self , sketch_id , graph_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' ) : abort ( HTTP_STATUS_CODE_FORBIDDEN , 'User does not have write access controls on sketch.' ) graph = Graph . query . get ( graph_id ) if not graph : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No graph found with this ID.' ) if not sketch . id == graph . sketch . id : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Graph does not belong to this sketch.' ) form = request . json if not form : form = request . data name = form . get ( 'name' ) if name : graph . name = name description = form . get ( 'description' ) if description : graph . description = description elements = form . get ( 'elements' ) if elements : graph . graph_elements = json . dumps ( elements ) graph_config = form . get ( 'graph_config' ) graph_json = '' if graph_config : if isinstance ( graph_config , dict ) : graph_json = json . dumps ( graph_config ) elif isinstance ( graph_config , str ) : graph_json = graph_config if graph_json : graph . graph_config = graph_json db_session . add ( graph ) db_session . commit ( ) # Update the last activity of a sketch. utils . update_sketch_last_activity ( sketch ) return self . to_json ( graph , status_code = HTTP_STATUS_CODE_CREATED )