|
|
@ -25,7 +25,6 @@ import re |
|
|
|
|
|
|
|
from odoo import http |
|
|
|
from odoo.http import request |
|
|
|
|
|
|
|
from odoo.modules.module import get_module_resource |
|
|
|
|
|
|
|
|
|
|
@ -84,9 +83,7 @@ class ThemeStudio(http.Controller): |
|
|
|
def save_styles(self, changed_styles, object_class, hover=False): |
|
|
|
"""Create Dynamic Styles css file""" |
|
|
|
changed_styles = json.loads(changed_styles) |
|
|
|
working_dir = os.path.dirname(os.path.realpath(__file__)) |
|
|
|
working_dir = working_dir.replace('/controllers', '') |
|
|
|
file_path = working_dir + '/static/src/css/dynamic_styles.css' |
|
|
|
file_path = get_module_resource('backend_theme_infinito', 'static', 'src', 'css', 'dynamic_styles.css') |
|
|
|
style_file = open(file_path, 'a') |
|
|
|
if os.stat(file_path).st_size == 0: |
|
|
|
style_file.write('/* This file is generated automatically by ' |
|
|
@ -104,9 +101,7 @@ class ThemeStudio(http.Controller): |
|
|
|
|
|
|
|
@http.route(['/theme_studio/get_current_style'], type="json") |
|
|
|
def get_current_style(self, selector): |
|
|
|
working_dir = os.path.dirname(os.path.realpath(__file__)) |
|
|
|
file_path = working_dir.replace('controllers', |
|
|
|
'static/src/css/dynamic_styles.css') |
|
|
|
file_path = get_module_resource('backend_theme_infinito', 'static', 'src', 'css', 'dynamic_styles.css') |
|
|
|
style_file = open(file_path, 'r') |
|
|
|
css = style_file.read() |
|
|
|
css = re.sub(r'/\*[\s\S]*?\*/', "", css) |
|
|
@ -132,9 +127,7 @@ class ThemeStudio(http.Controller): |
|
|
|
|
|
|
|
@http.route(['/theme_studio/reset_to_default'], type="json") |
|
|
|
def reset_to_default(self): |
|
|
|
working_dir = os.path.dirname(os.path.realpath(__file__)) |
|
|
|
file_path = working_dir.replace('controllers', |
|
|
|
'static/src/css/dynamic_styles.css') |
|
|
|
file_path = get_module_resource('backend_theme_infinito', 'static', 'src', 'css', 'dynamic_styles.css') |
|
|
|
style_file = open(file_path, 'w') |
|
|
|
style_file.write('') |
|
|
|
return True |
|
|
@ -225,10 +218,7 @@ class ThemeStudio(http.Controller): |
|
|
|
|
|
|
|
@http.route(['/theme_studio/get_presets'], type="json") |
|
|
|
def get_presets(self): |
|
|
|
working_dir = os.path.dirname(os.path.realpath(__file__)) |
|
|
|
working_dir = working_dir.replace('/controllers', '') |
|
|
|
file_path = working_dir + '/static/src/json/presets.json' |
|
|
|
file_path = get_module_resource('backend_theme_infinito', 'static', 'src', 'json', 'presets.json') |
|
|
|
file = open(file_path, 'r') |
|
|
|
presets = json.load(file) |
|
|
|
|
|
|
|
return presets |
|
|
|