Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
export: Post-process authentication_methods BitHandler field to list.
Anders Kaseorg03d2540899c1
diff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex 0eee874aed7..512492f28f4 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -298,6 +298,11 @@ DATE_FIELDS: Dict[TableName, List[Field]] = {'analytics_streamcount': ['end_time'],}+BITHANDLER_FIELDS: Dict[TableName, List[Field]] = {+ 'zerver_analytics': ['authentication_methods'],+ 'zerver_realm': ['authentication_methods'],+}+def sanity_check_output(data: TableData) -> None:# First, we verify that the export tool has a declared# configuration for every table declared in the `models.py` files.@@ -378,6 +383,11 @@ def floatify_datetime_fields(data: TableData, table: TableName) -> None:utc_naive = dt.replace(tzinfo=None) - dt.utcoffset()item[field] = (utc_naive - datetime.datetime(1970, 1, 1)).total_seconds()+def listify_bithandler_fields(data: TableData, table: TableName) -> None:+ for item in data[table]:+ for field in BITHANDLER_FIELDS[table]:+ item[field] = list(item[field])+class Config:'''A Config object configures a single table for exporting (and, maybesome day importing as well. This configuration defines what@@ -557,6 +567,8 @@ def export_from_config(response: TableData, config: Config, seed_object: Optionafor t in exported_tables:if t in DATE_FIELDS:floatify_datetime_fields(response, t)+ if table in BITHANDLER_FIELDS:+ listify_bithandler_fields(response, table)# Now walk our children. It's extremely important to respect# the order of children here.