mirror of https://github.com/zulip/zulip.git
import: import RealmAuditLog.
This commit is contained in:
parent
c182a0c7a0
commit
70b4794816
|
@ -24,7 +24,7 @@ from zerver.models import UserProfile, Realm, Client, Huddle, Stream, \
|
|||
UserMessage, Subscription, Message, RealmEmoji, \
|
||||
RealmDomain, Recipient, get_user_profile_by_id, \
|
||||
UserPresence, UserActivity, UserActivityInterval, Reaction, \
|
||||
CustomProfileField, CustomProfileFieldValue, \
|
||||
CustomProfileField, CustomProfileFieldValue, RealmAuditLog, \
|
||||
Attachment, get_system_bot, email_to_username
|
||||
|
||||
# Code from here is the realm import code path
|
||||
|
@ -58,6 +58,7 @@ id_maps = {
|
|||
'customprofilefield': {},
|
||||
'customprofilefieldvalue': {},
|
||||
'attachment': {},
|
||||
'realmauditlog': {},
|
||||
} # type: Dict[str, Dict[int, int]]
|
||||
|
||||
path_maps = {
|
||||
|
@ -542,6 +543,18 @@ def do_import_realm(import_dir: Path, subdomain: str) -> Realm:
|
|||
related_table="customprofilefieldvalue")
|
||||
bulk_import_model(data, CustomProfileFieldValue, 'zerver_customprofilefieldvalue')
|
||||
|
||||
fix_datetime_fields(data, 'zerver_realmauditlog')
|
||||
re_map_foreign_keys(data, 'zerver_realmauditlog', 'realm', related_table="realm")
|
||||
re_map_foreign_keys(data, 'zerver_realmauditlog', 'modified_user',
|
||||
related_table='user_profile')
|
||||
re_map_foreign_keys(data, 'zerver_realmauditlog', 'acting_user',
|
||||
related_table='user_profile')
|
||||
re_map_foreign_keys(data, 'zerver_realmauditlog', 'modified_stream',
|
||||
related_table="stream")
|
||||
update_model_ids(RealmAuditLog, data, 'zerver_realmauditlog',
|
||||
related_table="realmauditlog")
|
||||
bulk_import_model(data, RealmAuditLog, 'zerver_realmauditlog')
|
||||
|
||||
# Import uploaded files and avatars
|
||||
import_uploads(os.path.join(import_dir, "avatars"), processing_avatars=True)
|
||||
import_uploads(os.path.join(import_dir, "uploads"))
|
||||
|
|
|
@ -54,6 +54,7 @@ from zerver.models import (
|
|||
UserMessage,
|
||||
CustomProfileField,
|
||||
CustomProfileFieldValue,
|
||||
RealmAuditLog,
|
||||
get_active_streams,
|
||||
get_stream_recipient,
|
||||
get_personal_recipient,
|
||||
|
@ -535,6 +536,15 @@ class ImportExportTest(ZulipTestCase):
|
|||
for realm_custom_profile_field in custom_profile_field]
|
||||
self.assertEqual(custom_profile_field_name[0], custom_profile_field_name[1])
|
||||
|
||||
# test realmauditlog
|
||||
realmauditlogs = [
|
||||
RealmAuditLog.objects.filter(realm=realm)
|
||||
for realm in realms]
|
||||
realmauditlog_event_type = [
|
||||
{log.event_type for log in realmauditlog}
|
||||
for realmauditlog in realmauditlogs]
|
||||
self.assertEqual(realmauditlog_event_type[0], realmauditlog_event_type[1])
|
||||
|
||||
# test messages
|
||||
stream_message = [
|
||||
Message.objects.filter(recipient=recipient)
|
||||
|
|
Loading…
Reference in New Issue