Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
export: Make --deactivate-realm exports be imported as active.
Alex Vandiver113a8c4782bc
diff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex 764ee5a8978..6f908a1256e 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -1833,6 +1833,7 @@ def do_export_realm(exportable_user_ids: Optional[Set[int]] = None,public_only: bool = False,consent_message_id: Optional[int] = None,+ export_as_active: Optional[bool] = None,) -> str:response: TableData = {}@@ -1877,6 +1878,10 @@ def do_export_realm(fetch_reaction_data(response=zerver_reaction, message_ids=message_ids)response.update(zerver_reaction)+ # Override the "deactivated" flag on the realm+ if export_as_active is not None:+ response["zerver_realm"][0]["deactivated"] = not export_as_active+# Write realm dataexport_file = os.path.join(output_dir, "realm.json")write_table_data(output_file=export_file, data=response)@@ -2267,6 +2272,7 @@ def export_realm_wrapper(public_only: bool,percent_callback: Optional[Callable[[Any], None]] = None,consent_message_id: Optional[int] = None,+ export_as_active: Optional[bool] = None,) -> Optional[str]:tarball_path = do_export_realm(realm=realm,@@ -2274,6 +2280,7 @@ def export_realm_wrapper(threads=threads,public_only=public_only,consent_message_id=consent_message_id,+ export_as_active=export_as_active,)shutil.rmtree(output_dir)print(f"Tarball written to {tarball_path}")diff --git a/zerver/management/commands/export.py b/zerver/management/commands/export.pyindex 4811a7a72bd..b508b7ac978 100644--- a/zerver/management/commands/export.py+++ b/zerver/management/commands/export.py@@ -60,9 +60,6 @@ class Command(ZulipBaseCommand):* Use `./manage.py import` to import the realm- * Use `./manage.py reactivate_realm` to reactivate the realm, so- users can log in again.-* Inform the users about the things broken above.We recommend testing by exporting without `--deactivate` first, to@@ -92,7 +89,10 @@ class Command(ZulipBaseCommand):parser.add_argument("--deactivate-realm",action="store_true",- help="Deactivate the realm immediately before exporting",+ help=(+ "Deactivate the realm immediately before exporting; the exported data "+ "will show the realm as active"+ ),)parser.add_argument("--consent-message-id",@@ -212,4 +212,5 @@ class Command(ZulipBaseCommand):public_only=public_only,percent_callback=percent_callback,consent_message_id=consent_message_id,+ export_as_active=True if options["deactivate_realm"] else None,)diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.pyindex 73c6c18827c..c759cc3b3ae 100644--- a/zerver/tests/test_management_commands.py+++ b/zerver/tests/test_management_commands.py@@ -541,6 +541,7 @@ class TestExport(ZulipTestCase):output_dir=mock.ANY,percent_callback=mock.ANY,upload=False,+ export_as_active=None,)mock_input.assert_called_once_with("Continue? [y/N] ")