Aucune description

manage_srv_settings_routes.py 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # IRIS Source Code
  2. # Copyright (C) 2021 - Airbus CyberSecurity (SAS)
  3. # ir@cyberactionlab.net
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 3 of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. from flask import Blueprint
  19. from flask import render_template
  20. from flask import url_for
  21. from flask_wtf import FlaskForm
  22. from werkzeug.utils import redirect
  23. from app import app
  24. from app.datamgmt.manage.manage_srv_settings_db import get_alembic_revision
  25. from app.datamgmt.manage.manage_srv_settings_db import get_srv_settings
  26. from app.iris_engine.updater.updater import is_updates_available
  27. from app.models.authorization import Permissions
  28. from app.blueprints.access_controls import ac_requires
  29. manage_srv_settings_blueprint = Blueprint(
  30. 'manage_srv_settings_blueprint',
  31. __name__,
  32. template_folder='templates'
  33. )
  34. @manage_srv_settings_blueprint.route('/manage/server/make-update', methods=['GET'])
  35. @ac_requires(Permissions.server_administrator, no_cid_required=True)
  36. def manage_update(caseid, url_redir):
  37. if url_redir:
  38. return redirect(url_for('manage_srv_settings_blueprint.manage_settings', cid=caseid))
  39. # Return default page of case management
  40. return render_template('manage_make_update.html')
  41. @manage_srv_settings_blueprint.route('/manage/server/check-updates/modal', methods=['GET'])
  42. @ac_requires(Permissions.server_administrator, no_cid_required=True)
  43. def manage_check_updates_modal(caseid, url_redir):
  44. if url_redir:
  45. return redirect(url_for('manage_srv_settings_blueprint.manage_settings', cid=caseid))
  46. has_updates, updates_content, _ = is_updates_available()
  47. # Return default page of case management
  48. return render_template('modal_server_updates.html', has_updates=has_updates, updates_content=updates_content)
  49. @manage_srv_settings_blueprint.route('/manage/settings', methods=['GET'])
  50. @ac_requires(Permissions.server_administrator, no_cid_required=True)
  51. def manage_settings(caseid, url_redir):
  52. if url_redir:
  53. return redirect(url_for('manage_srv_settings_blueprint.manage_settings', cid=caseid))
  54. form = FlaskForm()
  55. server_settings = get_srv_settings()
  56. versions = {
  57. "iris_current": app.config.get('IRIS_VERSION'),
  58. "api_min": app.config.get('API_MIN_VERSION'),
  59. "api_current": app.config.get('API_MAX_VERSION'),
  60. "interface_min": app.config.get('MODULES_INTERFACE_MIN_VERSION'),
  61. "interface_current": app.config.get('MODULES_INTERFACE_MAX_VERSION'),
  62. "db_revision": get_alembic_revision()
  63. }
  64. # Return default page of case management
  65. return render_template('manage_srv_settings.html', form=form, settings=server_settings, versions=versions)