Now importing saved searches so that smart group works
This commit is contained in:
parent
a341654334
commit
107f10f704
12
confdump.py
12
confdump.py
@ -39,7 +39,8 @@ DUMP_TRIVIAL = ["FinancialType",
|
||||
"CustomGroup",
|
||||
"OptionGroup",
|
||||
"OptionValue",
|
||||
"Domain"]
|
||||
"Domain",
|
||||
"SavedSearch"]
|
||||
|
||||
|
||||
# "ContributionPage", needs payment processors & payment_processor column formatted correctly.
|
||||
@ -64,7 +65,8 @@ LOAD_TRIVIAL = ["FinancialType",
|
||||
"OptionGroup",
|
||||
"OptionValue",
|
||||
"Domain",
|
||||
"Contact"]
|
||||
"Contact",
|
||||
"SavedSearch"]
|
||||
|
||||
# This is a payment processor we can assign contribution pages to in order for them to work.
|
||||
# FIXME this seems to produce a non-working setup.
|
||||
@ -111,6 +113,8 @@ def object_to_table(instr: str) -> str:
|
||||
def array_to_weird_array(val: List) -> str:
|
||||
return '"\x01' + ('\x01'.join([str(x) for x in val])) + '\x01"'
|
||||
|
||||
def value_to_php_serialized(val: Any) -> str:
|
||||
return "'{}'".format(mysql.escape_string(phpserialize.dumps(val).decode()).decode())
|
||||
|
||||
def python_value_to_sql(val: Any) -> str:
|
||||
"""
|
||||
@ -127,7 +131,7 @@ def python_value_to_sql(val: Any) -> str:
|
||||
# weird list serialization
|
||||
return "'" + ','.join([str(x) for x in val]) + "'"
|
||||
if (type(val) == dict):
|
||||
return "'{}'".format(mysql.escape_string(phpserialize.dumps(val).decode()).decode())
|
||||
return value_to_php_serialized(val)
|
||||
return "'{}'".format(mysql.escape_string(val).decode())
|
||||
|
||||
|
||||
@ -141,6 +145,8 @@ def dict_to_insert(table: str, objdict: Dict) -> str:
|
||||
# any weird array we have to process here if there are others
|
||||
if table == "civicrm_contact" and col == "contact_sub_type":
|
||||
values.append(array_to_weird_array(objdict[col]))
|
||||
elif table == "civicrm_saved_search" and col == "form_values":
|
||||
values.append(value_to_php_serialized(objdict[col]))
|
||||
else:
|
||||
values.append(python_value_to_sql(objdict[col]))
|
||||
return "REPLACE INTO {} ({}) VALUES ({});".format(table, ",".join(columns), ",".join(values))
|
||||
|
Loading…
Reference in New Issue
Block a user