summaryrefslogtreecommitdiff
path: root/addons/website/controllers/main.py
diff options
context:
space:
mode:
authorAndrea Ulliana <aul@odoo.com>2019-06-26 12:28:13 +0000
committerqsm-odoo <qsm@odoo.com>2019-07-30 09:59:28 +0000
commit7deceae18c209c67f6cfbbe3f7704798bb02a42e (patch)
tree625139a2d2a20e9cf4ee0768c92dc172bbde892b /addons/website/controllers/main.py
parent15bae2920cf6cf9e8f399ecc0374da04654ef66f (diff)
[IMP] website, *: use "auto" widget for font customization
* theme_bootswatch, theme_default, website_theme_install This commit makes use of the new 'auto' widget for font selection: instead of enabling a template which will enable a scss file which sets a font variable to a specific value... we directly allow to do a scss custo which sets that value. The code in charge of resetting font customizations on theme switching is also moved and refactored here in website (instead of being specific to each theme). Part of https://github.com/odoo/odoo/pull/33442 task-1974659 Co-authored-by: qsm-odoo <qsm@odoo.com>
Diffstat (limited to 'addons/website/controllers/main.py')
-rw-r--r--addons/website/controllers/main.py25
1 files changed, 4 insertions, 21 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py
index e17a216e762..a1cca57919f 100644
--- a/addons/website/controllers/main.py
+++ b/addons/website/controllers/main.py
@@ -369,10 +369,6 @@ class Website(Home):
@http.route(['/website/make_scss_custo'], type='json', auth='user', website=True)
def make_scss_custo(self, url, values):
"""
- Makes a scss customization of the given file. That file must
- contain a scss map including a line comment containing the word 'hook',
- to indicate the location where to write the new key,value pairs.
-
Params:
url (str):
the URL of the scss file to customize (supposed to be a variable
@@ -382,24 +378,11 @@ class Website(Home):
key,value mapping to integrate in the file's map (containing the
word hook). If a key is already in the file's map, its value is
overridden.
- """
- AssetsUtils = request.env['web_editor.assets']
-
- custom_url = AssetsUtils.make_custom_asset_file_url(url, 'web.assets_common')
- updatedFileContent = AssetsUtils.get_asset_content(custom_url) or AssetsUtils.get_asset_content(url)
- updatedFileContent = updatedFileContent.decode('utf-8')
- for name, value in values.items():
- pattern = "'%s': %%s,\n" % name
- regex = re.compile(pattern % ".+")
- replacement = pattern % value
- if regex.search(updatedFileContent):
- updatedFileContent = re.sub(regex, replacement, updatedFileContent)
- else:
- updatedFileContent = re.sub(r'( *)(.*hook.*)', r'\1%s\1\2' % replacement, updatedFileContent)
- # Bundle is 'assets_common' as this route is only meant to update
- # variables scss files
- AssetsUtils.save_asset(url, 'web.assets_common', updatedFileContent, 'scss')
+ Returns:
+ boolean
+ """
+ request.env['web_editor.assets'].make_scss_customization(url, values)
return True
@http.route(['/website/multi_render'], type='json', auth="public", website=True)