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

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

        Returns:
            A view in JSON (instance of flask.wrappers.Response)
Handles POST request to the resource.
Handles POST request to the resource .
def post(self, sketch_id, view_id):
        """Handles POST request to the resource.

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

        Returns:
            A view in JSON (instance of flask.wrappers.Response)
        """
        form = forms.SaveViewForm.build(request)
        if not form.validate_on_submit():
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to update view, not able 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.')

        view = View.query.get(view_id)
        if not view:
            abort(
                HTTP_STATUS_CODE_NOT_FOUND, 'No view found with this ID.')

        if view.sketch.id != sketch.id:
            abort(
                HTTP_STATUS_CODE_BAD_REQUEST,
                'Unable to update view, view not attached to sketch.')

        view.query_string = form.query.data
        description = form.description.data
        if description:
            view.description = description

        query_filter = form.filter.data

        # Stripping potential pagination from views before saving it.
        if 'from' in query_filter:
            del query_filter['from']

        view.query_filter = json.dumps(query_filter, ensure_ascii=False)

        view.query_dsl = json.dumps(form.dsl.data, ensure_ascii=False)

        name = form.name.data
        if name:
            view.name = name

        view.user = current_user
        view.sketch = sketch

        if form.dsl.data:
            view.query_string = ''

        db_session.add(view)
        db_session.commit()

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

        return self.to_json(view, status_code=HTTP_STATUS_CODE_CREATED)
def post ( self , sketch_id , view_id ) : form = forms . SaveViewForm . build ( request ) if not form . validate_on_submit ( ) : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to update view, not able 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.' ) view = View . query . get ( view_id ) if not view : abort ( HTTP_STATUS_CODE_NOT_FOUND , 'No view found with this ID.' ) if view . sketch . id != sketch . id : abort ( HTTP_STATUS_CODE_BAD_REQUEST , 'Unable to update view, view not attached to sketch.' ) view . query_string = form . query . data description = form . description . data if description : view . description = description query_filter = form . filter . data # Stripping potential pagination from views before saving it. if 'from' in query_filter : del query_filter [ 'from' ] view . query_filter = json . dumps ( query_filter , ensure_ascii = False ) view . query_dsl = json . dumps ( form . dsl . data , ensure_ascii = False ) name = form . name . data if name : view . name = name view . user = current_user view . sketch = sketch if form . dsl . data : view . query_string = '' db_session . add ( view ) db_session . commit ( ) # Update the last activity of a sketch. utils . update_sketch_last_activity ( sketch ) return self . to_json ( view , status_code = HTTP_STATUS_CODE_CREATED )