|
|
|
@ -56,7 +56,7 @@ from operator import itemgetter, attrgetter |
|
|
|
|
from validate import Validator |
|
|
|
|
|
|
|
|
|
""" --- STASHR CORE IMPORTS --- """ |
|
|
|
|
from stashr import log, database, utils, paths, folders, naming, forms, tasks |
|
|
|
|
from stashr import log, database, utils, paths, folders, naming, forms, tasks, server |
|
|
|
|
|
|
|
|
|
from stashr.config import stashrconfig |
|
|
|
|
from stashr.comicvine import cv |
|
|
|
@ -2261,6 +2261,93 @@ def api_put_directories_edit(scrape_id): |
|
|
|
|
return jsonify(create_json_return('200')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" --- PLUGIN UPLOAD/INSTALL --- """ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@api.route('/plugins/upload', methods=['POST']) |
|
|
|
|
def api_post_upload_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')) |
|
|
|
|
|
|
|
|
|
if 'file' not in request.files: |
|
|
|
|
return jsonify(create_json_return('400')) |
|
|
|
|
|
|
|
|
|
# DO THINGS HERE |
|
|
|
|
file = request.files['file'] |
|
|
|
|
|
|
|
|
|
file_path =os.path.join( |
|
|
|
|
folders.StashrFolders().temp_folder(), |
|
|
|
|
file.filename |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
file.save(file_path) |
|
|
|
|
|
|
|
|
|
utils.install_plugin(file_path) |
|
|
|
|
|
|
|
|
|
return jsonify(create_json_return('200')) |
|
|
|
|
|
|
|
|
|
""" --- RESTART SERVER --- """ |
|
|
|
|
|
|
|
|
|
@api.route('/restart', methods=['POST']) |
|
|
|
|
def restart_server(): |
|
|
|
|
"""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')) |
|
|
|
|
|
|
|
|
|
server.server.restart_server() |
|
|
|
|
|
|
|
|
|
return create_json_return('200') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" --- API WRAPPER --- """ |
|
|
|
|
|
|
|
|
|
"""--------------------- |
|
|
|
|