|
|
@ -2064,6 +2064,7 @@ def api_get_plugins(): |
|
|
|
list_item['plugin_url'] = item.plugin_url |
|
|
|
list_item['plugin_url'] = item.plugin_url |
|
|
|
list_item['plugin_license'] = item.plugin_license |
|
|
|
list_item['plugin_license'] = item.plugin_license |
|
|
|
list_item['plugin_state'] = item.plugin_state |
|
|
|
list_item['plugin_state'] = item.plugin_state |
|
|
|
|
|
|
|
list_item['plugin_package_name'] = item.plugin_package_name |
|
|
|
# list_item[] |
|
|
|
# list_item[] |
|
|
|
data.append(list_item) |
|
|
|
data.append(list_item) |
|
|
|
|
|
|
|
|
|
|
@ -2311,6 +2312,110 @@ def api_post_upload_plugin(): |
|
|
|
|
|
|
|
|
|
|
|
return jsonify(create_json_return('200')) |
|
|
|
return jsonify(create_json_return('200')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api.route('/plugins/enable/<plugin>', methods=['POST']) |
|
|
|
|
|
|
|
def api_post_plugin_enable(plugin): |
|
|
|
|
|
|
|
"""To Update Later |
|
|
|
|
|
|
|
This is using docstrings for specifications. |
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
tags: |
|
|
|
|
|
|
|
- plugins |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = current_user |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not user.is_authenticated: |
|
|
|
|
|
|
|
if not request.json: |
|
|
|
|
|
|
|
return jsonify(create_json_return('400')) |
|
|
|
|
|
|
|
if "api_key" not in request.json: |
|
|
|
|
|
|
|
return jsonify(create_json_return('400')) |
|
|
|
|
|
|
|
if request.json['api_key'] == "": |
|
|
|
|
|
|
|
return jsonify(create_json_return('100')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = database.session \ |
|
|
|
|
|
|
|
.query(database.Users) \ |
|
|
|
|
|
|
|
.filter(database.Users.api_key == request.json['api_key']) \ |
|
|
|
|
|
|
|
.first() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if user is None: |
|
|
|
|
|
|
|
return jsonify(create_json_return('100')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if user.role != 'admin': |
|
|
|
|
|
|
|
return jsonify(create_json_return('401')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.enable_plugin(plugin) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return jsonify(create_json_return('200')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api.route('/plugins/disable/<plugin>', methods=['POST']) |
|
|
|
|
|
|
|
def api_post_plugin_disable(plugin): |
|
|
|
|
|
|
|
"""To Update Later |
|
|
|
|
|
|
|
This is using docstrings for specifications. |
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
tags: |
|
|
|
|
|
|
|
- plugins |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = current_user |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not user.is_authenticated: |
|
|
|
|
|
|
|
if not request.json: |
|
|
|
|
|
|
|
return jsonify(create_json_return('400')) |
|
|
|
|
|
|
|
if "api_key" not in request.json: |
|
|
|
|
|
|
|
return jsonify(create_json_return('400')) |
|
|
|
|
|
|
|
if request.json['api_key'] == "": |
|
|
|
|
|
|
|
return jsonify(create_json_return('100')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = database.session \ |
|
|
|
|
|
|
|
.query(database.Users) \ |
|
|
|
|
|
|
|
.filter(database.Users.api_key == request.json['api_key']) \ |
|
|
|
|
|
|
|
.first() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if user is None: |
|
|
|
|
|
|
|
return jsonify(create_json_return('100')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if user.role != 'admin': |
|
|
|
|
|
|
|
return jsonify(create_json_return('401')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.disable_plugin(plugin) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return jsonify(create_json_return('200')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api.route('/plugins/remove/<plugin>', methods=['POST']) |
|
|
|
|
|
|
|
def api_post_plugin_remove(plugin): |
|
|
|
|
|
|
|
"""To Update Later |
|
|
|
|
|
|
|
This is using docstrings for specifications. |
|
|
|
|
|
|
|
--- |
|
|
|
|
|
|
|
tags: |
|
|
|
|
|
|
|
- plugins |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = current_user |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not user.is_authenticated: |
|
|
|
|
|
|
|
if not request.json: |
|
|
|
|
|
|
|
return jsonify(create_json_return('400')) |
|
|
|
|
|
|
|
if "api_key" not in request.json: |
|
|
|
|
|
|
|
return jsonify(create_json_return('400')) |
|
|
|
|
|
|
|
if request.json['api_key'] == "": |
|
|
|
|
|
|
|
return jsonify(create_json_return('100')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = database.session \ |
|
|
|
|
|
|
|
.query(database.Users) \ |
|
|
|
|
|
|
|
.filter(database.Users.api_key == request.json['api_key']) \ |
|
|
|
|
|
|
|
.first() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if user is None: |
|
|
|
|
|
|
|
return jsonify(create_json_return('100')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if user.role != 'admin': |
|
|
|
|
|
|
|
return jsonify(create_json_return('401')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.uninstall_plugin(plugin) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return jsonify(create_json_return('200')) |
|
|
|
|
|
|
|
|
|
|
|
""" --- RESTART SERVER --- """ |
|
|
|
""" --- RESTART SERVER --- """ |
|
|
|
|
|
|
|
|
|
|
|
@api.route('/restart', methods=['POST']) |
|
|
|
@api.route('/restart', methods=['POST']) |
|
|
|