Example #1
0
    def put(self, site_name):
        """
        @api {put} /config/site/:site_name Update a configuration.

        @apiName UpdateSiteConfig
        @apiDescription Replace a configuration for a site.
        @apiGroup Configuration

        @apiParam {String} site_name Name of the site.
        @apiParam {String}   config    Configuration of the site.
        @apiParam {String}   enable    Activate the configuration.

        @apiSuccess (200) {int} state   Status of the operation, 1 if everything went well.

        @apiExample Example:
            PUT /config/site/default

        @apiParamExample {json} Configuration example:
            {
                'config': "Configuration...",
                'enable': "True"
            }

        @apiSuccessExample Success response
            HTTP/1.1 200 OK
            {
                'state': 1
            }

        """
        args = self.reqparse.parse_args()
        config = args['config']
        enable = args['enable']

        if enable is not None:
            enable = enable.lower() == "true"
        else:
            enable = False

        result = IO.update_site_config(site_name, config)
        if result is not True:
            raise UnableToPushConfiguration()

        print(enable)
        if enable:
            IO.enable_config(site_name)
        else:
            IO.disable_config(site_name)

        reload_nginx()

        return {'state': 1}
Example #2
0
    def put(self, site_name):
        """
        @api {put} /config/site/:site_name Update a configuration.

        @apiName UpdateSiteConfig
        @apiDescription Replace a configuration for a site.
        @apiGroup Configuration

        @apiParam {String} site_name Name of the site.
        @apiParam {String}   config    Configuration of the site.
        @apiParam {String}   enable    Activate the configuration.

        @apiSuccess (200) {int} state   Status of the operation, 1 if everything went well.

        @apiExample Example:
            PUT /config/site/default

        @apiParamExample {json} Configuration example:
            {
                'config': "Configuration...",
                'enable': "True"
            }

        @apiSuccessExample Success response
            HTTP/1.1 200 OK
            {
                'state': 1
            }

        """
        args = self.reqparse.parse_args()
        config = args['config']
        enable = args['enable']

        if enable is not None:
            enable = enable.lower() == "true"
        else:
            enable = False

        result = IO.update_site_config(site_name, config)
        if result is not True:
            raise UnableToPushConfiguration()

        print(enable)
        if enable:
            IO.enable_config(site_name)
        else:
            IO.disable_config(site_name)

        reload_nginx()

        return {'state': 1}