From 25fc6f193746f8924f3fca06fbdda260b282afdf Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Wed, 22 Jul 2020 18:44:03 +0200 Subject: [PATCH] Further fixes for #1530 (Handle improper migrated database with config_mature_content_tags, allowed_tags, denied_tags, denied_column_value, allowed_column_value NULL instead of "") --- cps/config_sql.py | 21 ++++++++------------- cps/ub.py | 22 ++++++++-------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/cps/config_sql.py b/cps/config_sql.py index b965eace..f0cd78af 100644 --- a/cps/config_sql.py +++ b/cps/config_sql.py @@ -214,25 +214,20 @@ class _ConfigSQL(object): return self.show_element_new_user(constants.DETAIL_RANDOM) def list_denied_tags(self): - try: - mct = self.config_denied_tags.split(",") - return [t.strip() for t in mct] - except AttributeError: - # Fix for improper migrated database with config_mature_content_tags NULL instead of "" - self.config_denied_tags = "" - return [''] + mct = self.config_denied_tags or "" + return [t.strip() for t in mct.split(",")] def list_allowed_tags(self): - mct = self.config_allowed_tags.split(",") - return [t.strip() for t in mct] + mct = self.config_allowed_tags or "" + return [t.strip() for t in mct.split(",")] def list_denied_column_values(self): - mct = self.config_denied_column_value.split(",") - return [t.strip() for t in mct] + mct = self.config_denied_column_value or "" + return [t.strip() for t in mct.split(",")] def list_allowed_column_values(self): - mct = self.config_allowed_column_value.split(",") - return [t.strip() for t in mct] + mct = self.config_allowed_column_value or "" + return [t.strip() for t in mct.split(",")] def get_log_level(self): return logger.get_level_name(self.config_log_level) diff --git a/cps/ub.py b/cps/ub.py index 8fcec1af..2b732cc2 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -176,26 +176,20 @@ class UserBase: return self.check_visibility(constants.DETAIL_RANDOM) def list_denied_tags(self): - try: - mct = self.denied_tags.split(",") - return [t.strip() for t in mct] - except AttributeError: - # Fix for improper migrated database with config_mature_content_tags NULL instead of "" - self.denied_tags="" - return [''] - + mct = self.denied_tags or "" + return [t.strip() for t in mct.split(",")] def list_allowed_tags(self): - mct = self.allowed_tags.split(",") - return [t.strip() for t in mct] + mct = self.allowed_tags or "" + return [t.strip() for t in mct.split(",")] def list_denied_column_values(self): - mct = self.denied_column_value.split(",") - return [t.strip() for t in mct] + mct = self.denied_column_value or "" + return [t.strip() for t in mct.split(",")] def list_allowed_column_values(self): - mct = self.allowed_column_value.split(",") - return [t.strip() for t in mct] + mct = self.allowed_column_value or "" + return [t.strip() for t in mct.split(",")] def __repr__(self): return '' % self.nickname