You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.8 KiB

  1. ###################################################################################
  2. #
  3. # Copyright (c) 2017-2019 MuK IT GmbH.
  4. #
  5. # This file is part of MuK SaaS Branding
  6. # (see https://mukit.at).
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Lesser General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Lesser General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Lesser General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ###################################################################################
  22. import os
  23. import sys
  24. import json
  25. from odoo import http, tools, service
  26. from odoo.http import request, db_monodb, db_list
  27. from odoo.addons.web.controllers.main import DBNAME_PATTERN
  28. from odoo.addons.web.controllers.main import jinja2, Database
  29. if hasattr(sys, 'frozen'):
  30. location = os.path.dirname(__file__)
  31. path = os.path.join(location, '..', 'templates')
  32. loader = jinja2.FileSystemLoader(os.path.realpath(path))
  33. else:
  34. loader = jinja2.PackageLoader('odoo.addons.muk_saas_branding', 'templates')
  35. env = jinja2.Environment(loader=loader, autoescape=True)
  36. env.filters["json"] = json.dumps
  37. class Database(Database):
  38. def _render_template(self, **d):
  39. d.setdefault('manage', True)
  40. d['insecure'] = tools.config.verify_admin_password('admin')
  41. d['list_db'] = tools.config['list_db']
  42. d['langs'] = service.db.exp_list_lang()
  43. d['countries'] = service.db.exp_list_countries()
  44. d['pattern'] = DBNAME_PATTERN
  45. d['system_name'] = tools.config.get(
  46. "database_manager_system_name", "Odoo"
  47. )
  48. d['system_logo'] = tools.config.get(
  49. "database_manager_system_logo_url",
  50. "/web/static/src/img/logo2.png"
  51. )
  52. d['system_favicon'] = tools.config.get(
  53. "database_manager_system_favicon_url",
  54. "/web/static/src/img/favicon.ico"
  55. )
  56. d['privacy_policy'] = tools.config.get(
  57. "database_manager_privacy_policy_url",
  58. "https://www.odoo.com/privacy"
  59. )
  60. d['databases'] = []
  61. try:
  62. d['databases'] = db_list()
  63. d['incompatible_databases'] = service.db.list_db_incompatible(d['databases'])
  64. except odoo.exceptions.AccessDenied:
  65. monodb = db_monodb()
  66. if monodb:
  67. d['databases'] = [monodb]
  68. return env.get_template("database_manager.html").render(d)