-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1134 from edissyum/dev_v3
3.0.5
- Loading branch information
Showing
11 changed files
with
125 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,16 +16,31 @@ | |
# @dev : Nathan Cheval <[email protected]> | ||
|
||
|
||
from flask import Blueprint, request, make_response, jsonify | ||
from flask_babel import gettext | ||
from flask import Blueprint, request, make_response, jsonify | ||
|
||
from src.backend.functions import rest_validator | ||
from src.backend.import_controllers import auth, history, privileges | ||
|
||
bp = Blueprint('history', __name__, url_prefix='/ws/') | ||
|
||
|
||
@bp.route('history/add', methods=['POST']) | ||
def add_history(): | ||
check, message = rest_validator(request.json, [ | ||
{'id': 'desc', 'type': str, 'mandatory': True}, | ||
{'id': 'module', 'type': str, 'mandatory': True}, | ||
{'id': 'user_id', 'type': int, 'mandatory': True}, | ||
{'id': 'user_info', 'type': str, 'mandatory': True}, | ||
{'id': 'submodule', 'type': str, 'mandatory': True} | ||
]) | ||
|
||
if not check: | ||
return make_response({ | ||
"errors": gettext('BAD_REQUEST'), | ||
"message": message | ||
}, 400) | ||
|
||
data = request.json | ||
data['ip'] = request.remote_addr | ||
res = history.add_history(data) | ||
|
@@ -38,6 +53,21 @@ def get_history(): | |
if not privileges.has_privileges(request.environ['user_id'], ['history | statistics']): | ||
return jsonify({'errors': gettext('UNAUTHORIZED_ROUTE'), 'message': '/history/list'}), 403 | ||
|
||
check, message = rest_validator(request.args, [ | ||
{'id': 'user', 'type': str, 'mandatory': False}, | ||
{'id': 'year', 'type': int, 'mandatory': False}, | ||
{'id': 'limit', 'type': int, 'mandatory': False}, | ||
{'id': 'offset', 'type': int, 'mandatory': False}, | ||
{'id': 'module', 'type': str, 'mandatory': False}, | ||
{'id': 'submodule', 'type': str, 'mandatory': False} | ||
]) | ||
|
||
if not check: | ||
return make_response({ | ||
"errors": gettext('BAD_REQUEST'), | ||
"message": message | ||
}, 400) | ||
|
||
_history = history.get_history(request.args) | ||
return make_response(jsonify(_history[0])), _history[1] | ||
|
||
|
@@ -48,6 +78,16 @@ def get_history_submodules(): | |
if not privileges.has_privileges(request.environ['user_id'], ['history']): | ||
return jsonify({'errors': gettext('UNAUTHORIZED_ROUTE'), 'message': '/history/submodules'}), 403 | ||
|
||
check, message = rest_validator(request.args, [ | ||
{'id': 'module', 'type': str, 'mandatory': False} | ||
]) | ||
|
||
if not check: | ||
return make_response({ | ||
"errors": gettext('BAD_REQUEST'), | ||
"message": message | ||
}, 400) | ||
|
||
_history = history.get_history_submodules(request.args) | ||
return make_response(jsonify(_history[0])), _history[1] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
# @dev : Nathan Cheval <[email protected]> | ||
|
||
from flask_babel import gettext | ||
from src.backend.functions import rest_validator | ||
from flask import Blueprint, jsonify, make_response, request | ||
from src.backend.import_controllers import mailcollect, auth, privileges | ||
|
||
|
@@ -28,13 +29,7 @@ def retrieve_processes(): | |
if not privileges.has_privileges(request.environ['user_id'], ['settings', 'mailcollect']): | ||
return jsonify({'errors': gettext('UNAUTHORIZED_ROUTE'), 'message': '/mailcollect/getProcesses'}), 403 | ||
|
||
args = { | ||
'select': ['*'], | ||
'where': ['status <> %s'], | ||
'data': ['DEL'] | ||
} | ||
|
||
res = mailcollect.retrieve_processes(args) | ||
res = mailcollect.retrieve_processes({}) | ||
return make_response(jsonify(res[0])), res[1] | ||
|
||
|
||
|
@@ -44,8 +39,21 @@ def retrieve_folders(): | |
if not privileges.has_privileges(request.environ['user_id'], ['settings', 'mailcollect']): | ||
return jsonify({'errors': gettext('UNAUTHORIZED_ROUTE'), 'message': '/mailcollect/retrieveFolders'}), 403 | ||
|
||
args = request.json | ||
res = mailcollect.retrieve_folders(args) | ||
check, message = rest_validator(request.json, [ | ||
{'id': 'port', 'type': int, 'mandatory': True}, | ||
{'id': 'login', 'type': str, 'mandatory': True}, | ||
{'id': 'hostname', 'type': str, 'mandatory': True}, | ||
{'id': 'password', 'type': str, 'mandatory': True}, | ||
{'id': 'secured_connection', 'type': bool, 'mandatory': False} | ||
]) | ||
|
||
if not check: | ||
return make_response({ | ||
"errors": gettext('BAD_REQUEST'), | ||
"message": message | ||
}, 400) | ||
|
||
res = mailcollect.retrieve_folders(request.json) | ||
return make_response(jsonify(res[0])), res[1] | ||
|
||
|
||
|
@@ -54,14 +62,33 @@ def retrieve_folders(): | |
def update_process(process_name): | ||
if not privileges.has_privileges(request.environ['user_id'], ['settings', 'mailcollect']): | ||
return jsonify({'errors': gettext('UNAUTHORIZED_ROUTE'), | ||
'message': f'/mailcollect/updateProcesses/{process_name}'}), 403 | ||
|
||
data = request.json | ||
args = { | ||
'set': data, | ||
'process_name': process_name | ||
} | ||
res = mailcollect.update_process(args) | ||
'message': f'/mailcollect/updateProcess/{process_name}'}), 403 | ||
|
||
check, message = rest_validator(request.json, [ | ||
{'id': 'name', 'type': str, 'mandatory': True}, | ||
{'id': 'port', 'type': int, 'mandatory': True}, | ||
{'id': 'login', 'type': str, 'mandatory': True}, | ||
{'id': 'enabled', 'type': bool, 'mandatory': True}, | ||
{'id': 'hostname', 'type': str, 'mandatory': True}, | ||
{'id': 'password', 'type': str, 'mandatory': True}, | ||
{'id': 'is_splitter', 'type': bool, 'mandatory': False}, | ||
{'id': 'folder_trash', 'type': str, 'mandatory': False}, | ||
{'id': 'folder_to_crawl', 'type': str, 'mandatory': True}, | ||
{'id': 'verifier_form_id', 'type': str, 'mandatory': False}, | ||
{'id': 'folder_destination', 'type': str, 'mandatory': True}, | ||
{'id': 'secured_connection', 'type': bool, 'mandatory': False}, | ||
{'id': 'action_after_process', 'type': str, 'mandatory': True}, | ||
{'id': 'verifier_customer_id', 'type': str, 'mandatory': False}, | ||
{'id': 'splitter_technical_workflow_id', 'type': int, 'mandatory': False} | ||
]) | ||
|
||
if not check: | ||
return make_response({ | ||
"errors": gettext('BAD_REQUEST'), | ||
"message": message | ||
}, 400) | ||
|
||
res = mailcollect.update_process({'set': request.json, 'process_name': process_name}) | ||
return make_response(jsonify(res[0])), res[1] | ||
|
||
|
||
|
@@ -71,11 +98,31 @@ def create_process(): | |
if not privileges.has_privileges(request.environ['user_id'], ['settings', 'mailcollect']): | ||
return jsonify({'errors': gettext('UNAUTHORIZED_ROUTE'), 'message': '/mailcollect/createProcess'}), 403 | ||
|
||
data = request.json | ||
args = { | ||
'columns': data | ||
} | ||
res = mailcollect.create_process(args) | ||
check, message = rest_validator(request.json, [ | ||
{'id': 'name', 'type': str, 'mandatory': True}, | ||
{'id': 'port', 'type': int, 'mandatory': True}, | ||
{'id': 'login', 'type': str, 'mandatory': True}, | ||
{'id': 'enabled', 'type': bool, 'mandatory': False}, | ||
{'id': 'hostname', 'type': str, 'mandatory': True}, | ||
{'id': 'password', 'type': str, 'mandatory': True}, | ||
{'id': 'is_splitter', 'type': bool, 'mandatory': False}, | ||
{'id': 'folder_trash', 'type': str, 'mandatory': False}, | ||
{'id': 'folder_to_crawl', 'type': str, 'mandatory': True}, | ||
{'id': 'verifier_form_id', 'type': str, 'mandatory': False}, | ||
{'id': 'folder_destination', 'type': str, 'mandatory': True}, | ||
{'id': 'secured_connection', 'type': bool, 'mandatory': False}, | ||
{'id': 'action_after_process', 'type': str, 'mandatory': True}, | ||
{'id': 'verifier_customer_id', 'type': str, 'mandatory': False}, | ||
{'id': 'splitter_technical_workflow_id', 'type': int, 'mandatory': False} | ||
]) | ||
|
||
if not check: | ||
return make_response({ | ||
"errors": gettext('BAD_REQUEST'), | ||
"message": message | ||
}, 400) | ||
|
||
res = mailcollect.create_process({'columns': request.json}) | ||
return make_response(jsonify(res[0])), res[1] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters