2017-08-29 19:12:07 +08:00
|
|
|
import json
|
|
|
|
|
|
|
|
import flask_restful
|
2018-02-22 22:21:03 +08:00
|
|
|
from flask import request, jsonify
|
2017-08-29 19:12:07 +08:00
|
|
|
|
2018-02-22 22:21:03 +08:00
|
|
|
from cc.auth import jwt_required
|
2017-09-13 16:29:47 +08:00
|
|
|
from cc.services.config import ConfigService
|
2017-08-29 19:12:07 +08:00
|
|
|
|
|
|
|
__author__ = 'Barak'
|
|
|
|
|
|
|
|
|
|
|
|
class MonkeyConfiguration(flask_restful.Resource):
|
2018-02-22 22:21:03 +08:00
|
|
|
@jwt_required()
|
2017-08-29 19:12:07 +08:00
|
|
|
def get(self):
|
2017-09-13 16:29:47 +08:00
|
|
|
return jsonify(schema=ConfigService.get_config_schema(), configuration=ConfigService.get_config())
|
2017-08-29 19:12:07 +08:00
|
|
|
|
2018-02-22 22:21:03 +08:00
|
|
|
@jwt_required()
|
2017-08-29 19:12:07 +08:00
|
|
|
def post(self):
|
|
|
|
config_json = json.loads(request.data)
|
2017-09-21 22:32:36 +08:00
|
|
|
if config_json.has_key('reset'):
|
|
|
|
ConfigService.reset_config()
|
|
|
|
else:
|
|
|
|
ConfigService.update_config(config_json)
|
2017-09-19 20:30:42 +08:00
|
|
|
return self.get()
|