From f79ca7f38812bff759e91fc534e5efea87d82095 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Fri, 15 Jan 2021 19:22:52 +0700 Subject: [PATCH 01/17] [web_website] fix reinstallation error by adding IF NOT EXISTS --- web_website/__init__.py | 4 ++-- web_website/__manifest__.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web_website/__init__.py b/web_website/__init__.py index 8bde15e15d..399425eccf 100644 --- a/web_website/__init__.py +++ b/web_website/__init__.py @@ -8,5 +8,5 @@ def post_init_hook(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) # emulate updating existing field to website-dependent one - env.cr.execute("ALTER TABLE test_website_dependent ADD COLUMN foo VARCHAR") - env.cr.execute("ALTER TABLE test_website_dependent ADD COLUMN user_id INTEGER") + env.cr.execute("ALTER TABLE test_website_dependent ADD COLUMN IF NOT EXISTS foo VARCHAR") + env.cr.execute("ALTER TABLE test_website_dependent ADD COLUMN IF NOT EXISTS user_id INTEGER") diff --git a/web_website/__manifest__.py b/web_website/__manifest__.py index b7a3ced401..a806cf1405 100644 --- a/web_website/__manifest__.py +++ b/web_website/__manifest__.py @@ -6,9 +6,9 @@ "category": "Hidden", # "live_test_url": "", "images": [], - "version": "11.0.3.0.5", + "version": "11.0.3.0.6", "application": False, - "author": "IT-Projects LLC, Ivan Yelizariev", + "author": "IT-Projects LLC, Ivan Yelizariev, Zell Co., Ltd.", "support": "apps@itpp.dev", "website": "https://it-projects.info/team/yelizariev", "license": "Other OSI approved licence", # MIT From 0fa2ac8c4fd52cb8fb145e795014909c419f5270 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Fri, 15 Jan 2021 19:26:27 +0700 Subject: [PATCH 02/17] [ir_config_parameter] improve migration.py sql --- .../migrations/11.0.2.0.0/pre-prepare-value-column.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ir_config_parameter_multi_company/migrations/11.0.2.0.0/pre-prepare-value-column.py b/ir_config_parameter_multi_company/migrations/11.0.2.0.0/pre-prepare-value-column.py index 0189422be9..4ba0091296 100644 --- a/ir_config_parameter_multi_company/migrations/11.0.2.0.0/pre-prepare-value-column.py +++ b/ir_config_parameter_multi_company/migrations/11.0.2.0.0/pre-prepare-value-column.py @@ -3,4 +3,4 @@ def migrate(cr, version): # will be renamed to value_tmp during updating the module # Create Column - cr.execute("ALTER TABLE ir_config_parameter ADD COLUMN value VARCHAR") + cr.execute("ALTER TABLE ir_config_parameter ADD COLUMN IF NOT EXISTS value VARCHAR") From 9053c47a4491a5a6a81cd60a909f45adef7c980a Mon Sep 17 00:00:00 2001 From: Sengrith Date: Fri, 15 Jan 2021 19:41:13 +0700 Subject: [PATCH 03/17] [ir_config_parameter_multi_company] update version --- ir_config_parameter_multi_company/__manifest__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ir_config_parameter_multi_company/__manifest__.py b/ir_config_parameter_multi_company/__manifest__.py index b06331511b..76abebf33f 100644 --- a/ir_config_parameter_multi_company/__manifest__.py +++ b/ir_config_parameter_multi_company/__manifest__.py @@ -4,9 +4,9 @@ "category": "Extra Tools", # "live_test_url": "", "images": [], - "version": "11.0.5.0.0", + "version": "11.0.5.0.1", "application": False, - "author": "IT-Projects LLC, Ivan Yelizariev", + "author": "IT-Projects LLC, Ivan Yelizariev, Zell Co., Ltd.", "support": "apps@itpp.dev", "website": "https://it-projects.info/team/yelizariev", "license": "Other OSI approved licence", # MIT From 8da6f98b729dadfb25a06582633b43156003aad9 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sat, 16 Jan 2021 11:52:33 +0700 Subject: [PATCH 04/17] [theme_kit] change 'web_widget_colorpicker' to 'web_widget_color' --- theme_kit/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme_kit/__manifest__.py b/theme_kit/__manifest__.py index 4915100ff6..1bcf0257d4 100644 --- a/theme_kit/__manifest__.py +++ b/theme_kit/__manifest__.py @@ -14,7 +14,7 @@ "license": "Other OSI approved licence", # MIT "price": 50.00, "currency": "EUR", - "depends": ["web_debranding", "web_login_background", "web_widget_colorpicker"], + "depends": ["web_debranding", "web_login_background", "web_widget_color"], "external_dependencies": {"python": [], "bin": []}, "data": [ "security/ir.model.access.csv", From 0e275958915c93c9ebf78ead088c31972cd06fbe Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sat, 16 Jan 2021 12:53:43 +0700 Subject: [PATCH 05/17] [11.0][theme_kit] fix some top panel buttons is not properly recolored --- .gitignore | 2 ++ theme_kit/models/theme.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..fdcbd0e933 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +*.sh \ No newline at end of file diff --git a/theme_kit/models/theme.py b/theme_kit/models/theme.py index 74468e3a5d..ad711b4752 100644 --- a/theme_kit/models/theme.py +++ b/theme_kit/models/theme.py @@ -242,8 +242,12 @@ def _compute_less(self): code = ( code + """.navbar-nav .active a{{ - background-color: {theme.top_panel_active_item_bg}!important; - }}""" + background-color: {theme.top_panel_active_item_bg}!important; + }} + .o_dashboards .o_website_dashboard .o_dashboard_common .o_inner_box.o_primary {{ + background-color: {theme.top_panel_active_item_bg}!important; + }} + """ ) if self.top_panel_hover_item_font_active: code = ( @@ -307,6 +311,9 @@ def _compute_less(self): .open .dropdown-menu > li a:focus {{ background-color: {theme.top_panel_hover_item_bg}!important; }} + .o_dashboards .o_website_dashboard .o_dashboard_common .o_inner_box.o_primary {{ + background-color: {theme.top_panel_hover_item_bg}; + }} """ ) code = code.format(theme=r) From 739024f01682095a150cf014030150629234e048 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sat, 16 Jan 2021 15:51:13 +0700 Subject: [PATCH 06/17] [11.0][theme_kit] Improve less code for color branding --- theme_kit/__manifest__.py | 4 ++-- theme_kit/data/theme_data.xml | 1 + theme_kit/models/theme.py | 38 +++++++++++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/theme_kit/__manifest__.py b/theme_kit/__manifest__.py index 1bcf0257d4..312e0aeb50 100644 --- a/theme_kit/__manifest__.py +++ b/theme_kit/__manifest__.py @@ -7,14 +7,14 @@ "summary": """Brand your odoo instance in few clicks""", "category": "Debranding", "images": ["images/brandkit.png"], - "version": "11.0.2.0.0", + "version": "11.0.2.0.1", "application": False, "author": "IT-Projects LLC, Ivan Yelizariev", "website": "https://odoo-debranding.com", "license": "Other OSI approved licence", # MIT "price": 50.00, "currency": "EUR", - "depends": ["web_debranding", "web_login_background", "web_widget_color"], + "depends": ["web_debranding", "web_login_background", "web_widget_colorpicker"], "external_dependencies": {"python": [], "bin": []}, "data": [ "security/ir.model.access.csv", diff --git a/theme_kit/data/theme_data.xml b/theme_kit/data/theme_data.xml index 914ba28fb7..b469953759 100644 --- a/theme_kit/data/theme_data.xml +++ b/theme_kit/data/theme_data.xml @@ -117,6 +117,7 @@ + .o_input, .btn {border-radius: 0;} diff --git a/theme_kit/models/theme.py b/theme_kit/models/theme.py index ad711b4752..845ca1525b 100644 --- a/theme_kit/models/theme.py +++ b/theme_kit/models/theme.py @@ -150,10 +150,12 @@ def _compute_less(self): .datepicker .table-condensed > thead {{ background-color: {theme.top_panel_bg}; }} - .datepicker .table-condensed > thead th:hover {{ background-color: darken({theme.top_panel_bg}, 15%) !important; }} + .o_form_view .o_form_statusbar {{ + background-color: transparent; + }} """ ) @@ -247,6 +249,9 @@ def _compute_less(self): .o_dashboards .o_website_dashboard .o_dashboard_common .o_inner_box.o_primary {{ background-color: {theme.top_panel_active_item_bg}!important; }} + .o_dashboards .o_website_dashboard .o_dashboard_common .o_inner_box.o_apps {{ + background-color: {theme.top_panel_active_item_bg}!important; + }} """ ) if self.top_panel_hover_item_font_active: @@ -311,8 +316,8 @@ def _compute_less(self): .open .dropdown-menu > li a:focus {{ background-color: {theme.top_panel_hover_item_bg}!important; }} - .o_dashboards .o_website_dashboard .o_dashboard_common .o_inner_box.o_primary {{ - background-color: {theme.top_panel_hover_item_bg}; + .o_dashboards:hover .o_website_dashboard:hover .o_dashboard_common:hover .o_inner_box.o_primary:hover {{ + background-color: {theme.top_panel_hover_item_bg}!important; }} """ ) @@ -485,6 +490,7 @@ def _compute_less(self): }} .o_mail_chat .o_mail_chat_sidebar .o_mail_chat_channel_item.o_active {{ background-color: {theme.left_panel_active_item_bg}!important; + box-shadow: inset 3px 0 0 darken({theme.left_panel_active_item_bg}, 10%); }} """ ) @@ -665,6 +671,7 @@ def _compute_less(self): .o_application_switcher .o_app:hover{{ background-color: darken({theme.content_bg}, 1%) !important; }} + """ ) @@ -704,6 +711,9 @@ def _compute_less(self): .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .ui-state-active {{ background-color: darken({theme.content_form}, 25%); }} + .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .ui-state-active:hover {{ + background-color: darken({theme.content_form},15%) !important; + }} .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table td a:hover {{ background-color: darken({theme.content_form}, 25%); @@ -763,7 +773,7 @@ def _compute_less(self): if self.content_form_link_active: code = ( code - + """ .o_main_content a {{ + + """ .o_main_content a:not(.btn-primary) {{ color: {theme.content_form_link}; }} .o_control_panel .breadcrumb > li > a {{ @@ -804,6 +814,26 @@ def _compute_less(self): .o_searchview .o_searchview_facet .o_facet_remove {{ color: {theme.content_button} !important; }} + .o_tooltip {{ + background-color: {theme.content_button}; + border: 2px solid {theme.content_button} !important; + }} + .o_tooltip.active.right::before, .o_tooltip.right::before {{ + border-right-color: {theme.content_button}; + }} + .o_tooltip.active.left::before, .o_tooltip.left::before {{ + border-left-color: {theme.content_button}; + }} + .o_tooltip.active.bottom::before, .o_tooltip.bottom::before {{ + border-bottom-color: {theme.content_button}; + }} + .o_tooltip.active.top::before, .o_tooltip.top::before {{ + border-top-color: {theme.content_button}; + }} + .o_tooltip::after {{ + border-color: {theme.content_button}; + background: radial-gradient(lighten({theme.content_button}, 5%), {theme.content_button}); + }} """ ) if self.content_text_active: From 87e083c56bdd5ccef917a2fe19a59bd8930744a4 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sun, 24 Jan 2021 16:53:32 +0700 Subject: [PATCH 07/17] [theme_kit] update YouTube custom_css --- theme_kit/data/theme_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme_kit/data/theme_data.xml b/theme_kit/data/theme_data.xml index b469953759..673e3367f0 100644 --- a/theme_kit/data/theme_data.xml +++ b/theme_kit/data/theme_data.xml @@ -117,7 +117,7 @@ - .o_input, .btn {border-radius: 0;} + .o_web_client { .o_input, .btn {border-radius: 0;} .o_list_view thead {color: #222222;} } From b8ca1d904772d9d8e580019dce2408eaad60ff50 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sun, 24 Jan 2021 17:55:25 +0700 Subject: [PATCH 08/17] [theme_kit] update model less --- theme_kit/models/theme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme_kit/models/theme.py b/theme_kit/models/theme.py index 845ca1525b..f0b580c48a 100644 --- a/theme_kit/models/theme.py +++ b/theme_kit/models/theme.py @@ -779,7 +779,7 @@ def _compute_less(self): .o_control_panel .breadcrumb > li > a {{ color: {theme.content_form_link}; }} - .o_control_panel .dropdown-toggle {{ + .o_control_panel .dropdown-toggle:not(.btn-primary) {{ color: {theme.content_form_link}; }} .o_control_panel .o_cp_right, .o_control_panel .o_pager_previous, .o_control_panel .o_pager_next {{ From c5d660ab02177ac1a1504e2cfb38b2a5d0ff7873 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Wed, 27 Jan 2021 17:16:05 +0700 Subject: [PATCH 09/17] [theme_kit] IMP color branding --- theme_kit/models/theme.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/theme_kit/models/theme.py b/theme_kit/models/theme.py index f0b580c48a..cd1d3f2127 100644 --- a/theme_kit/models/theme.py +++ b/theme_kit/models/theme.py @@ -252,6 +252,17 @@ def _compute_less(self): .o_dashboards .o_website_dashboard .o_dashboard_common .o_inner_box.o_apps {{ background-color: {theme.top_panel_active_item_bg}!important; }} + .o_chat_window .o_chat_header {{ + background-color: {theme.top_panel_active_item_bg}!important; + }} + .o_mail_navbar_item .o_mail_navbar_dropdown .o_mail_navbar_dropdown_top .o_filter_button:hover, + .o_mail_navbar_item .o_mail_navbar_dropdown .o_mail_navbar_dropdown_top .o_filter_button.active {{ + color: {theme.top_panel_active_item_bg}!important; + }} + .o_mail_navbar_item .o_mail_navbar_dropdown .o_mail_navbar_dropdown_top .o_filter_button, + .o_mail_navbar_item .o_mail_navbar_dropdown .o_mail_navbar_dropdown_top .o_new_message {{ + color: {theme.top_panel_active_item_bg}!important; + }} """ ) if self.top_panel_hover_item_font_active: @@ -671,7 +682,6 @@ def _compute_less(self): .o_application_switcher .o_app:hover{{ background-color: darken({theme.content_bg}, 1%) !important; }} - """ ) @@ -779,7 +789,7 @@ def _compute_less(self): .o_control_panel .breadcrumb > li > a {{ color: {theme.content_form_link}; }} - .o_control_panel .dropdown-toggle:not(.btn-primary) {{ + .o_control_panel .dropdown-toggle:not(.btn) {{ color: {theme.content_form_link}; }} .o_control_panel .o_cp_right, .o_control_panel .o_pager_previous, .o_control_panel .o_pager_next {{ @@ -808,12 +818,24 @@ def _compute_less(self): .o_main .e_tag {{ border: 1px solid {theme.content_button} !important; }} + .o_form_view .oe_link, .o_field_widget.o_field_many2one .o_external_button {{ + color: {theme.content_button} !important; + }} .o_searchview_facet_label {{ background-color: {theme.content_button} !important; }} .o_searchview .o_searchview_facet .o_facet_remove {{ color: {theme.content_button} !important; }} + .o_searchview .o_searchview_autocomplete li.o-selection-focus {{ + color: {theme.content_button} !important; + }} + .o_searchview .o_searchview_autocomplete li.o-selection-focus {{ + background-color: {theme.content_button}; + }} + .tooltip .tooltip-inner .oe_tooltip_string {{ + background-color: {theme.content_button}; + }} .o_tooltip {{ background-color: {theme.content_button}; border: 2px solid {theme.content_button} !important; @@ -834,6 +856,9 @@ def _compute_less(self): border-color: {theme.content_button}; background: radial-gradient(lighten({theme.content_button}, 5%), {theme.content_button}); }} + .o_field_widget.o_field_image .o_form_image_controls {{ + background-color: {theme.content_button}; + }} """ ) if self.content_text_active: From d0873e796609a864becbdefdcfb3967dae4bf1a8 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Wed, 27 Jan 2021 17:26:47 +0700 Subject: [PATCH 10/17] [theme_kit] FIX texting color branding of .open .dropdown-menu > li a span --- theme_kit/models/theme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/theme_kit/models/theme.py b/theme_kit/models/theme.py index cd1d3f2127..8426a0c59d 100644 --- a/theme_kit/models/theme.py +++ b/theme_kit/models/theme.py @@ -200,7 +200,7 @@ def _compute_less(self): .o_main_navbar .o_menu_brand {{ color: {theme.top_panel_font}!important; }} - .open .dropdown-menu > li a span {{ + .open .dropdown-menu > li:not(.active) a span {{ color: {theme.top_panel_font}!important; }} .open .dropdown-menu > li.dropdown-header {{ From 4a38df7ec698ea2004da1a1fb8126891b69e9e29 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Wed, 27 Jan 2021 19:26:27 +0700 Subject: [PATCH 11/17] [theme_kit] IMP color branding --- theme_kit/models/theme.py | 54 ++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/theme_kit/models/theme.py b/theme_kit/models/theme.py index 8426a0c59d..80db7aba8b 100644 --- a/theme_kit/models/theme.py +++ b/theme_kit/models/theme.py @@ -154,7 +154,7 @@ def _compute_less(self): background-color: darken({theme.top_panel_bg}, 15%) !important; }} .o_form_view .o_form_statusbar {{ - background-color: transparent; + background-color: transparent; }} """ ) @@ -231,6 +231,9 @@ def _compute_less(self): .datepicker .table-condensed > thead {{ color: {theme.top_panel_font}!important; }} + .navbar-inverse .navbar-toggle {{ + background-color: {theme.top_panel_font}; + }} """ ) if self.top_panel_active_item_font_active: @@ -263,6 +266,12 @@ def _compute_less(self): .o_mail_navbar_item .o_mail_navbar_dropdown .o_mail_navbar_dropdown_top .o_new_message {{ color: {theme.top_panel_active_item_bg}!important; }} + a {{ + color: {theme.top_panel_active_item_bg}; + }} + a:hover, a:focus {{ + color: lighten({theme.top_panel_active_item_bg}, 10%); + }} """ ) if self.top_panel_hover_item_font_active: @@ -724,7 +733,6 @@ def _compute_less(self): .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .ui-state-active:hover {{ background-color: darken({theme.content_form},15%) !important; }} - .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table td a:hover {{ background-color: darken({theme.content_form}, 25%); }} @@ -766,9 +774,6 @@ def _compute_less(self): .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .ui-state-default {{ color: {theme.content_form_text}; }} - .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .ui-state-active {{ - color: lighten({theme.content_form_text}, 30%)!important; - }} .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table thead {{ color: {theme.content_form_text}; }} @@ -783,7 +788,8 @@ def _compute_less(self): if self.content_form_link_active: code = ( code - + """ .o_main_content a:not(.btn-primary) {{ + + """ .o_main_content a:not(.btn-primary), + .o_form_view .o_form_uri:first-line {{ color: {theme.content_form_link}; }} .o_control_panel .breadcrumb > li > a {{ @@ -833,9 +839,44 @@ def _compute_less(self): .o_searchview .o_searchview_autocomplete li.o-selection-focus {{ background-color: {theme.content_button}; }} + .ui-autocomplete .ui-menu-item.ui-state-focus, .tooltip .tooltip-inner .oe_tooltip_string {{ background-color: {theme.content_button}; }} + .ui-autocomplete .ui-menu-item.o_m2o_dropdown_option > a, + .o_form_view .oe_button_box .oe_stat_button .o_button_icon, + .o_form_view .oe_button_box .oe_stat_button .o_stat_info .o_stat_value, + .o_form_view .oe_button_box .oe_stat_button > span .o_stat_value, + .o_web_settings_dashboard .o_web_settings_dashboard_col .o_web_settings_dashboard_planner .o_web_settings_dashboard_progress_title, + .btn-link {{ + color: {theme.content_button}; + }} + .datepicker .table-condensed > tbody > tr > td.active, .datepicker .table-condensed > tbody > tr > td .active, + .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .ui-state-active {{ + background-color: {theme.content_button}; + color: white; + }} + .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .ui-state-default:hover {{ + background-color: lighten({theme.content_button}, 15%); + border-color: lighten({theme.content_button}, 15%); + }} + .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table .o_selected_range.o_color {{ + background-color: lighten({theme.content_button}, 15%); + animation: backgroundfade 3s forwards; + }} + .o_calendar_container .o_calendar_sidebar_container .ui-datepicker table {{ + .ui-state-default.ui-state-hover.o_selected_range.o_color {{ + color: black; + }} + }} + .bootstrap-datetimepicker-widget table td.today:before, + .datepicker .table-condensed > tbody > tr > td.today:before {{ + border-bottom-color: {theme.content_button}; + }} + .btn-link:hover, .btn-link:focus, + .o_form_view .o_form_uri:hover:first-line {{ + color: lighten({theme.content_button}, 10%); + }} .o_tooltip {{ background-color: {theme.content_button}; border: 2px solid {theme.content_button} !important; @@ -859,6 +900,7 @@ def _compute_less(self): .o_field_widget.o_field_image .o_form_image_controls {{ background-color: {theme.content_button}; }} + """ ) if self.content_text_active: From 1b3a62c03e0bdd892a4bc26b5cae1ec918088431 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sun, 21 Feb 2021 15:38:46 +0700 Subject: [PATCH 12/17] [theme_kit] improve You Tube theme --- theme_kit/data/theme_data.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/theme_kit/data/theme_data.xml b/theme_kit/data/theme_data.xml index 673e3367f0..97e64c1f9e 100644 --- a/theme_kit/data/theme_data.xml +++ b/theme_kit/data/theme_data.xml @@ -111,6 +111,8 @@ True #FFFFFF True + #FFFFFF + True You Tube From e057c993772b284862051bf1675cabdeb7aeaf8d Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sat, 17 Apr 2021 16:35:41 +0700 Subject: [PATCH 13/17] [base_session_store_psql] fix serialized error --- base_session_store_psql/sessionstore.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/base_session_store_psql/sessionstore.py b/base_session_store_psql/sessionstore.py index 9ee4992bbf..14addb44c4 100644 --- a/base_session_store_psql/sessionstore.py +++ b/base_session_store_psql/sessionstore.py @@ -46,7 +46,7 @@ def get_cursor(self, create_session_store_db=True): with closing(db_connect("postgres").cursor()) as cr: cr.autocommit(True) # avoid transaction block cr.execute( - """CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" """ + """CREATE DATABASE IF NOT EXISTS "%s" ENCODING 'unicode' TEMPLATE "%s" """ % (db_name, config["db_template"]) ) return self.get_cursor(create_session_store_db=False) @@ -65,7 +65,8 @@ def get_cursor(self, create_session_store_db=True): def is_valid_key(self, key): with self.get_cursor() as cr: - cr.execute("SELECT id FROM sessionstore WHERE id = %s LIMIT 1;", (key,)) + cr.execute( + "SELECT id FROM sessionstore WHERE id = %s LIMIT 1;", (key,)) return cr.rowcount == 1 def save(self, session): @@ -96,7 +97,10 @@ def save(self, session): def delete(self, session): with self.get_cursor() as cr: - cr.execute("DELETE FROM sessionstore WHERE id = %s;", (session.sid,)) + cr.autocommit(True) # avoid transaction block + if self.is_valid_key(session.sid): + cr.execute("DELETE FROM sessionstore WHERE id = %s;", + (session.sid,)) def get(self, sid): with self.get_cursor() as cr: From 9ff8ccd1b5a42a6a2382ea7cbac10c1f7e9b8fc2 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sat, 17 Apr 2021 18:36:20 +0700 Subject: [PATCH 14/17] [base_session_store_psql] fix sql --- base_session_store_psql/sessionstore.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base_session_store_psql/sessionstore.py b/base_session_store_psql/sessionstore.py index 14addb44c4..f47db3b90a 100644 --- a/base_session_store_psql/sessionstore.py +++ b/base_session_store_psql/sessionstore.py @@ -46,8 +46,8 @@ def get_cursor(self, create_session_store_db=True): with closing(db_connect("postgres").cursor()) as cr: cr.autocommit(True) # avoid transaction block cr.execute( - """CREATE DATABASE IF NOT EXISTS "%s" ENCODING 'unicode' TEMPLATE "%s" """ - % (db_name, config["db_template"]) + """CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = "%s")""" + % (db_name, config["db_template"], db_name) ) return self.get_cursor(create_session_store_db=False) From fd81553cd5e8a8e92d3a8dfe6c10f7e7c6481757 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Sat, 17 Apr 2021 18:38:24 +0700 Subject: [PATCH 15/17] [base_session_store_psql] fix sql --- base_session_store_psql/sessionstore.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base_session_store_psql/sessionstore.py b/base_session_store_psql/sessionstore.py index f47db3b90a..888267d8bd 100644 --- a/base_session_store_psql/sessionstore.py +++ b/base_session_store_psql/sessionstore.py @@ -46,8 +46,8 @@ def get_cursor(self, create_session_store_db=True): with closing(db_connect("postgres").cursor()) as cr: cr.autocommit(True) # avoid transaction block cr.execute( - """CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = "%s")""" - % (db_name, config["db_template"], db_name) + """CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" """ + % (db_name, config["db_template"]) ) return self.get_cursor(create_session_store_db=False) From 9725686788e35495aac6efc239e706d3c5da1425 Mon Sep 17 00:00:00 2001 From: Sengrith Date: Fri, 14 May 2021 13:00:37 +0700 Subject: [PATCH 16/17] [base_session_store] remove encoding when creating session_store_db --- base_session_store_psql/sessionstore.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_session_store_psql/sessionstore.py b/base_session_store_psql/sessionstore.py index 888267d8bd..63ace0dbe6 100644 --- a/base_session_store_psql/sessionstore.py +++ b/base_session_store_psql/sessionstore.py @@ -46,7 +46,7 @@ def get_cursor(self, create_session_store_db=True): with closing(db_connect("postgres").cursor()) as cr: cr.autocommit(True) # avoid transaction block cr.execute( - """CREATE DATABASE "%s" ENCODING 'unicode' TEMPLATE "%s" """ + """CREATE DATABASE "%s" TEMPLATE "%s" """ % (db_name, config["db_template"]) ) return self.get_cursor(create_session_store_db=False) From fd8758af132c2974f878230f55540364c52ba34e Mon Sep 17 00:00:00 2001 From: Sengrith Date: Fri, 14 May 2021 13:16:22 +0700 Subject: [PATCH 17/17] [base_session_store] fix create db --- base_session_store_psql/sessionstore.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/base_session_store_psql/sessionstore.py b/base_session_store_psql/sessionstore.py index 63ace0dbe6..0772e38a4f 100644 --- a/base_session_store_psql/sessionstore.py +++ b/base_session_store_psql/sessionstore.py @@ -36,6 +36,8 @@ def __init__(self, session_class=None): def get_cursor(self, create_session_store_db=True): db_name = config.get("session_store_db", "session_store") + db_encoding = config.get("db_encoding", "UTF8") + db_template = config.get("db_template", "template0") try: con = db_connect(db_name) cr = con.cursor() @@ -46,8 +48,8 @@ def get_cursor(self, create_session_store_db=True): with closing(db_connect("postgres").cursor()) as cr: cr.autocommit(True) # avoid transaction block cr.execute( - """CREATE DATABASE "%s" TEMPLATE "%s" """ - % (db_name, config["db_template"]) + """CREATE DATABASE "%s" ENCODING "%s" TEMPLATE "%s" """ + % (db_name, db_encoding, db_template) ) return self.get_cursor(create_session_store_db=False)