From 8e7ce7cc7903681fec5f51d2d1405cbba73af905 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 14 Jan 2020 12:59:46 -0800 Subject: [PATCH] python: Sort migrations/management command imports with isort. This is a preparatory commit for using isort for sorting all of our imports, merging changes to files where we can easily review the changes as something we're happy with. These are also files with relatively little active development, which means we don't expect much merge conflict risk from these changes. --- analytics/management/commands/analyze_mit.py | 1 + .../management/commands/analyze_user_activity.py | 1 + .../management/commands/check_analytics_state.py | 14 ++++++-------- .../commands/clear_analytics_tables.py | 1 + .../management/commands/clear_single_stat.py | 1 + analytics/management/commands/client_activity.py | 1 + .../management/commands/populate_analytics_db.py | 16 ++++++++-------- analytics/management/commands/realm_stats.py | 4 ++-- analytics/management/commands/stream_stats.py | 5 +++-- .../commands/update_analytics_counts.py | 1 + analytics/management/commands/user_stats.py | 1 + analytics/migrations/0001_initial.py | 1 + analytics/migrations/0002_remove_huddlecount.py | 1 + analytics/migrations/0003_fillstate.py | 1 + analytics/migrations/0004_add_subgroup.py | 1 + analytics/migrations/0005_alter_field_size.py | 1 + .../0006_add_subgroup_to_unique_constraints.py | 1 + analytics/migrations/0007_remove_interval.py | 1 + analytics/migrations/0008_add_count_indexes.py | 1 + .../0009_remove_messages_to_stream_stat.py | 1 + .../0010_clear_messages_sent_values.py | 1 + .../migrations/0011_clear_analytics_tables.py | 1 + analytics/migrations/0012_add_on_delete.py | 2 +- corporate/migrations/0001_initial.py | 2 +- corporate/migrations/0003_customerplan.py | 2 +- corporate/migrations/0004_licenseledger.py | 2 +- .../migrations/0005_customerplan_invoicing.py | 2 +- pgroonga/migrations/0001_enable.py | 2 +- pgroonga/migrations/0002_html_escape_subject.py | 4 +++- pgroonga/migrations/0003_v2_api_upgrade.py | 2 +- .../commands/add_users_to_mailing_list.py | 1 + .../management/commands/add_users_to_streams.py | 1 + zerver/management/commands/archive_messages.py | 1 + zerver/management/commands/backup.py | 2 +- zerver/management/commands/bankrupt_users.py | 1 + .../management/commands/bulk_change_user_name.py | 1 + zerver/management/commands/change_user_email.py | 1 + zerver/management/commands/check_redis.py | 8 +++++--- zerver/management/commands/checkconfig.py | 1 + zerver/management/commands/compilemessages.py | 5 +++-- .../management/commands/convert_gitter_data.py | 4 +++- .../management/commands/convert_hipchat_data.py | 4 +++- .../commands/convert_mattermost_data.py | 4 +++- zerver/management/commands/convert_slack_data.py | 4 +++- .../commands/create_default_stream_groups.py | 1 + .../management/commands/create_large_indexes.py | 1 + .../commands/create_realm_internal_bots.py | 1 + zerver/management/commands/create_stream.py | 1 + zerver/management/commands/create_user.py | 1 + zerver/management/commands/deactivate_realm.py | 1 + zerver/management/commands/deactivate_user.py | 3 ++- .../commands/delete_old_unclaimed_attachments.py | 1 + zerver/management/commands/deliver_email.py | 1 - .../commands/deliver_scheduled_messages.py | 6 +++--- zerver/management/commands/dump_messages.py | 1 + zerver/management/commands/email_mirror.py | 2 -- zerver/management/commands/enqueue_file.py | 1 + zerver/management/commands/export.py | 3 ++- zerver/management/commands/export_single_user.py | 1 + .../commands/export_usermessage_batch.py | 1 + .../management/commands/fill_memcached_caches.py | 1 + zerver/management/commands/fix_unreads.py | 2 +- .../management/commands/generate_invite_links.py | 5 +++-- .../commands/generate_multiuse_invite_link.py | 5 +++-- .../commands/generate_realm_creation_link.py | 3 ++- .../management/commands/get_migration_status.py | 1 + zerver/management/commands/import.py | 6 ++++-- .../management/commands/initialize_voyager_db.py | 6 +++--- zerver/management/commands/knight.py | 1 + zerver/management/commands/list_realms.py | 1 + zerver/management/commands/logout_all_users.py | 1 + zerver/management/commands/makemessages.py | 1 - zerver/management/commands/merge_streams.py | 5 +++-- .../commands/print_email_delivery_backlog.py | 3 +-- zerver/management/commands/process_queue.py | 1 + zerver/management/commands/purge_queue.py | 1 + zerver/management/commands/query_ldap.py | 1 + zerver/management/commands/rate_limit.py | 7 ++++--- zerver/management/commands/reactivate_realm.py | 1 + zerver/management/commands/realm_domain.py | 3 ++- zerver/management/commands/realm_filters.py | 3 ++- zerver/management/commands/register_server.py | 4 ++-- .../commands/remove_users_from_stream.py | 1 + zerver/management/commands/rename_stream.py | 1 + zerver/management/commands/restore_messages.py | 5 +++-- zerver/management/commands/runtornado.py | 7 ++++--- zerver/management/commands/scrub_realm.py | 1 + zerver/management/commands/send_custom_email.py | 2 +- .../commands/send_password_reset_email.py | 1 + .../commands/send_realm_reactivation_email.py | 8 ++++---- zerver/management/commands/send_stats.py | 1 + zerver/management/commands/send_test_email.py | 1 + .../management/commands/send_to_email_mirror.py | 13 +++++-------- .../commands/send_webhook_fixture_message.py | 7 ++++--- zerver/management/commands/set_message_flags.py | 3 ++- zerver/management/commands/show_admins.py | 1 + zerver/management/commands/show_unreads.py | 1 + .../management/commands/soft_deactivate_users.py | 5 +++-- .../management/commands/sync_ldap_user_data.py | 3 +-- .../commands/transfer_uploads_to_s3.py | 4 +++- zerver/management/commands/turn_off_digests.py | 1 + zerver/migrations/0001_initial.py | 2 +- zerver/migrations/0029_realm_subdomain.py | 2 +- zerver/migrations/0030_realm_org_type.py | 2 +- .../0031_remove_system_avatar_source.py | 2 +- .../0032_verify_all_medium_avatar_images.py | 2 +- .../0033_migrate_domain_to_realmalias.py | 2 +- ...erprofile_enable_online_push_notifications.py | 2 +- .../0035_realm_message_retention_period_days.py | 2 +- .../0036_rename_subdomain_to_string_id.py | 2 +- .../migrations/0037_disallow_null_string_id.py | 1 + .../0038_realm_change_to_community_defaults.py | 2 +- .../0039_realmalias_drop_uniqueness.py | 2 +- .../0040_realm_authentication_methods.py | 2 +- .../0041_create_attachments_for_old_messages.py | 1 - .../0042_attachment_file_name_length.py | 2 +- .../migrations/0043_realm_filter_validators.py | 2 +- zerver/migrations/0044_reaction.py | 2 +- .../0045_realm_waiting_period_threshold.py | 2 +- zerver/migrations/0046_realmemoji_author.py | 2 +- .../0047_realm_add_emoji_by_admins_only.py | 2 +- .../0048_enter_sends_default_to_false.py | 2 +- ...rofile_pm_content_in_desktop_notifications.py | 2 +- .../0050_userprofile_avatar_version.py | 2 +- .../0051_realmalias_add_allow_subdomains.py | 2 +- .../0052_auto_fix_realmalias_realm_nullable.py | 2 +- zerver/migrations/0053_emailchangestatus.py | 2 +- zerver/migrations/0054_realm_icon.py | 2 +- zerver/migrations/0055_attachment_size.py | 2 +- .../0056_userprofile_emoji_alt_code.py | 2 +- zerver/migrations/0057_realmauditlog.py | 2 +- .../0058_realm_email_changes_disabled.py | 2 +- zerver/migrations/0059_userprofile_quota.py | 2 +- .../0060_move_avatars_to_be_uid_based.py | 2 +- zerver/migrations/0061_userprofile_timezone.py | 2 +- zerver/migrations/0062_default_timezone.py | 2 +- zerver/migrations/0063_realm_description.py | 2 +- .../0064_sync_uploads_filesize_with_db.py | 3 +-- .../0065_realm_inline_image_preview.py | 2 +- .../0066_realm_inline_url_embed_preview.py | 2 +- zerver/migrations/0067_archived_models.py | 2 +- zerver/migrations/0068_remove_realm_domain.py | 2 +- .../migrations/0069_realmauditlog_extra_data.py | 2 +- zerver/migrations/0070_userhotspot.py | 2 +- .../0071_rename_realmalias_to_realmdomain.py | 2 +- .../0072_realmauditlog_add_index_event_time.py | 2 +- zerver/migrations/0073_custom_profile_fields.py | 2 +- .../migrations/0074_fix_duplicate_attachments.py | 2 +- .../migrations/0075_attachment_path_id_unique.py | 2 +- zerver/migrations/0076_userprofile_emojiset.py | 2 +- .../0077_add_file_name_field_to_realm_emoji.py | 2 +- zerver/migrations/0078_service.py | 2 +- .../migrations/0079_remove_old_scheduled_jobs.py | 2 +- .../migrations/0080_realm_description_length.py | 2 +- zerver/migrations/0081_make_emoji_lowercase.py | 2 +- .../0082_index_starred_user_messages.py | 2 +- .../0083_index_mentioned_user_messages.py | 2 +- zerver/migrations/0084_realmemoji_deactivated.py | 2 +- .../0085_fix_bots_with_none_bot_type.py | 2 +- .../0086_realm_alter_default_org_type.py | 2 +- .../migrations/0087_remove_old_scheduled_jobs.py | 2 +- .../0088_remove_referral_and_invites.py | 2 +- zerver/migrations/0089_auto_20170710_1353.py | 2 +- .../0090_userprofile_high_contrast_mode.py | 2 +- .../migrations/0091_realm_allow_edit_history.py | 2 +- zerver/migrations/0092_create_scheduledemail.py | 2 +- .../0093_subscription_event_log_backfill.py | 2 +- .../0094_realm_filter_url_validator.py | 2 +- .../0095_index_unread_user_messages.py | 2 +- zerver/migrations/0096_add_password_required.py | 2 +- zerver/migrations/0097_reactions_emoji_code.py | 2 +- .../0098_index_has_alert_word_user_messages.py | 2 +- ...099_index_wildcard_mentioned_user_messages.py | 2 +- .../0100_usermessage_remove_is_me_message.py | 2 +- zerver/migrations/0101_muted_topic.py | 2 +- zerver/migrations/0102_convert_muted_topic.py | 2 +- .../0103_remove_userprofile_muted_topics.py | 2 +- zerver/migrations/0104_fix_unreads.py | 2 +- ...erprofile_enable_stream_push_notifications.py | 2 +- .../0106_subscription_push_notifications.py | 2 +- zerver/migrations/0107_multiuseinvite.py | 2 +- zerver/migrations/0108_fix_default_string_id.py | 2 +- .../0109_mark_tutorial_status_finished.py | 1 + .../migrations/0110_stream_is_in_zephyr_realm.py | 1 + zerver/migrations/0111_botuserstatedata.py | 1 + zerver/migrations/0112_index_muted_topics.py | 2 +- zerver/migrations/0113_default_stream_group.py | 1 + .../0114_preregistrationuser_invited_as_admin.py | 1 + zerver/migrations/0115_user_groups.py | 1 + .../0116_realm_allow_message_deleting.py | 1 + zerver/migrations/0117_add_desc_to_user_group.py | 1 + .../0118_defaultstreamgroup_description.py | 1 + zerver/migrations/0120_botuserconfigdata.py | 2 +- .../0121_realm_signup_notifications_stream.py | 3 ++- .../0126_prereg_remove_users_without_realm.py | 1 + ...127_disallow_chars_in_stream_and_user_name.py | 1 + zerver/migrations/0128_scheduledemail_realm.py | 3 ++- .../migrations/0130_text_choice_in_emojiset.py | 1 + zerver/migrations/0134_scheduledmessage.py | 2 +- ..._fill_last_message_id_in_subscription_logs.py | 1 + .../migrations/0143_realm_bot_creation_policy.py | 1 + .../0145_reactions_realm_emoji_name_to_id.py | 5 +++-- .../0149_realm_emoji_drop_unique_constraint.py | 1 + zerver/migrations/0154_fix_invalid_bot_owner.py | 1 + .../0167_custom_profile_fields_sort_order.py | 3 ++- zerver/migrations/0170_submessage.py | 2 +- .../0174_userprofile_delivery_email.py | 4 ++-- ...75_change_realm_audit_log_event_type_tense.py | 2 +- ...user_message_add_and_index_is_private_flag.py | 2 ++ .../0181_userprofile_change_emojiset.py | 1 + .../0182_set_initial_value_is_private_flag.py | 1 + .../0189_userprofile_add_some_emojisets.py | 1 + .../0198_preregistrationuser_invited_as.py | 1 + zerver/migrations/0199_userstatus.py | 2 +- .../0206_stream_rendered_description.py | 4 ++-- .../0209_user_profile_no_empty_password.py | 8 ++++---- .../migrations/0210_stream_first_message_id.py | 1 + .../0211_add_users_field_to_scheduled_email.py | 1 + .../0212_make_stream_email_token_unique.py | 1 + .../0214_realm_invite_to_stream_policy.py | 2 +- .../migrations/0216_add_create_stream_policy.py | 1 + .../0217_migrate_create_stream_policy.py | 2 +- .../0218_remove_create_stream_by_admins_only.py | 1 + ...toggle_realm_digest_emails_enabled_default.py | 1 + .../0220_subscription_notification_settings.py | 1 + zerver/migrations/0223_rename_to_is_muted.py | 1 + ...0224_alter_field_realm_video_chat_provider.py | 3 ++- .../migrations/0225_archived_reaction_model.py | 4 ++-- .../migrations/0226_archived_submessage_model.py | 4 ++-- .../0231_add_archive_transaction_model.py | 2 +- ...ake_archive_transaction_field_not_nullable.py | 3 ++- .../0236_remove_illegal_characters_email_full.py | 3 ++- .../0237_rename_zulip_realm_to_zulipinternal.py | 1 + zerver/migrations/0242_fix_bot_email_property.py | 1 + zerver/migrations/0254_merge_0209_0253.py | 4 +++- ...55_userprofile_stream_add_recipient_column.py | 2 +- ...profile_stream_set_recipient_column_values.py | 1 + zerver/migrations/0257_fix_has_link_attribute.py | 5 +++-- .../migrations/0259_missedmessageemailaddress.py | 4 ++-- ..._missed_message_addresses_from_redis_to_db.py | 1 + .../management/commands/add_mock_conversation.py | 8 ++++---- zilencer/management/commands/add_new_realm.py | 5 +++-- zilencer/management/commands/add_new_user.py | 1 + .../management/commands/add_remote_server.py | 1 + zilencer/management/commands/compare_messages.py | 1 + zilencer/management/commands/invoice_plans.py | 1 + .../commands/mark_all_messages_unread.py | 1 + .../commands/migrate_stream_notifications.py | 1 + .../commands/print_initial_password.py | 1 + zilencer/management/commands/render_messages.py | 1 + zilencer/management/commands/sync_api_key.py | 1 + zilencer/migrations/0001_initial.py | 1 + zilencer/migrations/0002_remote_zulip_server.py | 1 + ...t_for_remotezulipserver_last_updated_field.py | 1 + .../migrations/0004_remove_deployment_model.py | 1 + .../0005_remotepushdevicetoken_fix_uniqueness.py | 1 + zilencer/migrations/0006_customer.py | 2 +- .../migrations/0008_customer_billing_user.py | 2 +- zilencer/migrations/0010_billingprocessor.py | 2 +- zilencer/migrations/0016_remote_counts.py | 2 +- zilencer/migrations/0018_remoterealmauditlog.py | 2 +- 261 files changed, 356 insertions(+), 223 deletions(-) diff --git a/analytics/management/commands/analyze_mit.py b/analytics/management/commands/analyze_mit.py index 4bfce825cc..63b207b890 100644 --- a/analytics/management/commands/analyze_mit.py +++ b/analytics/management/commands/analyze_mit.py @@ -8,6 +8,7 @@ from django.core.management.base import BaseCommand, CommandParser from zerver.lib.timestamp import timestamp_to_datetime from zerver.models import Message, Recipient + def compute_stats(log_level: int) -> None: logger = logging.getLogger() logger.setLevel(log_level) diff --git a/analytics/management/commands/analyze_user_activity.py b/analytics/management/commands/analyze_user_activity.py index 4508409483..4b72fe3163 100644 --- a/analytics/management/commands/analyze_user_activity.py +++ b/analytics/management/commands/analyze_user_activity.py @@ -7,6 +7,7 @@ from django.utils.timezone import utc from zerver.lib.statistics import seconds_usage_between from zerver.models import UserProfile + def analyze_activity(options: Dict[str, Any]) -> None: day_start = datetime.datetime.strptime(options["date"], "%Y-%m-%d").replace(tzinfo=utc) day_end = day_start + datetime.timedelta(days=options["duration"]) diff --git a/analytics/management/commands/check_analytics_state.py b/analytics/management/commands/check_analytics_state.py index c9639c6dd2..8e7d903163 100644 --- a/analytics/management/commands/check_analytics_state.py +++ b/analytics/management/commands/check_analytics_state.py @@ -1,19 +1,17 @@ +import os +import time from datetime import timedelta +from typing import Any, Dict from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now -from analytics.models import installation_epoch, \ - last_successful_fill from analytics.lib.counts import COUNT_STATS, CountStat -from zerver.lib.timestamp import floor_to_hour, floor_to_day, verify_UTC, \ - TimezoneNotUTCException +from analytics.models import installation_epoch, last_successful_fill +from zerver.lib.timestamp import TimezoneNotUTCException, floor_to_day, \ + floor_to_hour, verify_UTC from zerver.models import Realm -import os -import time -from typing import Any, Dict - states = { 0: "OK", 1: "WARNING", diff --git a/analytics/management/commands/clear_analytics_tables.py b/analytics/management/commands/clear_analytics_tables.py index 57c9ce0f2f..e668d156ce 100644 --- a/analytics/management/commands/clear_analytics_tables.py +++ b/analytics/management/commands/clear_analytics_tables.py @@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand, CommandError from analytics.lib.counts import do_drop_all_analytics_tables + class Command(BaseCommand): help = """Clear analytics tables.""" diff --git a/analytics/management/commands/clear_single_stat.py b/analytics/management/commands/clear_single_stat.py index f3a52c15ed..cc004bc444 100644 --- a/analytics/management/commands/clear_single_stat.py +++ b/analytics/management/commands/clear_single_stat.py @@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand, CommandError from analytics.lib.counts import COUNT_STATS, do_drop_single_stat + class Command(BaseCommand): help = """Clear analytics tables.""" diff --git a/analytics/management/commands/client_activity.py b/analytics/management/commands/client_activity.py index 9ba4356de9..b28eefb14a 100644 --- a/analytics/management/commands/client_activity.py +++ b/analytics/management/commands/client_activity.py @@ -8,6 +8,7 @@ from django.utils.timezone import now as timezone_now from zerver.lib.management import ZulipBaseCommand from zerver.models import UserActivity + class Command(ZulipBaseCommand): help = """Report rough client activity globally, for a realm, or for a user diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.py index bdca88c5e2..8e81e1ff57 100644 --- a/analytics/management/commands/populate_analytics_db.py +++ b/analytics/management/commands/populate_analytics_db.py @@ -1,21 +1,21 @@ from datetime import timedelta from typing import Any, Dict, List, Mapping, Optional, Type -import mock +import mock from django.core.management.base import BaseCommand from django.utils.timezone import now as timezone_now -from analytics.lib.counts import COUNT_STATS, \ - CountStat, do_drop_all_analytics_tables +from analytics.lib.counts import COUNT_STATS, CountStat, \ + do_drop_all_analytics_tables from analytics.lib.fixtures import generate_time_series_data from analytics.lib.time_utils import time_range -from analytics.models import BaseCount, FillState, RealmCount, UserCount, \ - StreamCount, InstallationCount -from zerver.lib.actions import do_change_is_admin, STREAM_ASSIGNMENT_COLORS +from analytics.models import BaseCount, FillState, InstallationCount, \ + RealmCount, StreamCount, UserCount +from zerver.lib.actions import STREAM_ASSIGNMENT_COLORS, do_change_is_admin from zerver.lib.create_user import create_user from zerver.lib.timestamp import floor_to_day -from zerver.models import Realm, Stream, Client, \ - Recipient, Subscription +from zerver.models import Client, Realm, Recipient, Stream, Subscription + class Command(BaseCommand): help = """Populates analytics tables with randomly generated data.""" diff --git a/analytics/management/commands/realm_stats.py b/analytics/management/commands/realm_stats.py index 6593c201b4..fb8cf2a0cf 100644 --- a/analytics/management/commands/realm_stats.py +++ b/analytics/management/commands/realm_stats.py @@ -6,8 +6,8 @@ from django.core.management.base import BaseCommand, CommandError from django.db.models import Count from django.utils.timezone import now as timezone_now -from zerver.models import Message, Realm, Recipient, Stream, \ - Subscription, UserActivity, UserMessage, UserProfile, get_realm +from zerver.models import Message, Realm, Recipient, Stream, Subscription, \ + UserActivity, UserMessage, UserProfile, get_realm MOBILE_CLIENT_LIST = ["Android", "ios"] HUMAN_CLIENT_LIST = MOBILE_CLIENT_LIST + ["website"] diff --git a/analytics/management/commands/stream_stats.py b/analytics/management/commands/stream_stats.py index d868bdbe78..d96efbbcb7 100644 --- a/analytics/management/commands/stream_stats.py +++ b/analytics/management/commands/stream_stats.py @@ -4,8 +4,9 @@ from typing import Any from django.core.management.base import BaseCommand, CommandError from django.db.models import Q -from zerver.models import Message, Realm, \ - Recipient, Stream, Subscription, get_realm +from zerver.models import Message, Realm, Recipient, Stream, Subscription, \ + get_realm + class Command(BaseCommand): help = "Generate statistics on the streams for a realm." diff --git a/analytics/management/commands/update_analytics_counts.py b/analytics/management/commands/update_analytics_counts.py index fa4e89a1da..61d603e9b9 100644 --- a/analytics/management/commands/update_analytics_counts.py +++ b/analytics/management/commands/update_analytics_counts.py @@ -15,6 +15,7 @@ from zerver.lib.remote_server import send_analytics_to_remote_server from zerver.lib.timestamp import floor_to_hour from zerver.models import Realm + class Command(BaseCommand): help = """Fills Analytics tables. diff --git a/analytics/management/commands/user_stats.py b/analytics/management/commands/user_stats.py index 34c0ac4bd7..2b023db0e4 100644 --- a/analytics/management/commands/user_stats.py +++ b/analytics/management/commands/user_stats.py @@ -7,6 +7,7 @@ from django.utils.timezone import now as timezone_now from zerver.models import Message, Realm, Stream, UserProfile, get_realm + class Command(BaseCommand): help = "Generate statistics on user activity." diff --git a/analytics/migrations/0001_initial.py b/analytics/migrations/0001_initial.py index 1c17d474c9..3d528988e0 100644 --- a/analytics/migrations/0001_initial.py +++ b/analytics/migrations/0001_initial.py @@ -3,6 +3,7 @@ import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0002_remove_huddlecount.py b/analytics/migrations/0002_remove_huddlecount.py index a13004a5c0..9bc8e28c27 100644 --- a/analytics/migrations/0002_remove_huddlecount.py +++ b/analytics/migrations/0002_remove_huddlecount.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0003_fillstate.py b/analytics/migrations/0003_fillstate.py index 962bd2b943..da49772d6e 100644 --- a/analytics/migrations/0003_fillstate.py +++ b/analytics/migrations/0003_fillstate.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0004_add_subgroup.py b/analytics/migrations/0004_add_subgroup.py index a80c7561d4..e16e7733f0 100644 --- a/analytics/migrations/0004_add_subgroup.py +++ b/analytics/migrations/0004_add_subgroup.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0005_alter_field_size.py b/analytics/migrations/0005_alter_field_size.py index 7bcf4dccab..eed94b35db 100644 --- a/analytics/migrations/0005_alter_field_size.py +++ b/analytics/migrations/0005_alter_field_size.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0006_add_subgroup_to_unique_constraints.py b/analytics/migrations/0006_add_subgroup_to_unique_constraints.py index 98316b9b43..aa2e105e5e 100644 --- a/analytics/migrations/0006_add_subgroup_to_unique_constraints.py +++ b/analytics/migrations/0006_add_subgroup_to_unique_constraints.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0007_remove_interval.py b/analytics/migrations/0007_remove_interval.py index 9e7db43dae..9fceb71042 100644 --- a/analytics/migrations/0007_remove_interval.py +++ b/analytics/migrations/0007_remove_interval.py @@ -2,6 +2,7 @@ # Generated by Django 1.10.4 on 2017-01-16 20:50 from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0008_add_count_indexes.py b/analytics/migrations/0008_add_count_indexes.py index d91b3a6545..7d95671840 100644 --- a/analytics/migrations/0008_add_count_indexes.py +++ b/analytics/migrations/0008_add_count_indexes.py @@ -2,6 +2,7 @@ # Generated by Django 1.10.5 on 2017-02-01 22:28 from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/analytics/migrations/0009_remove_messages_to_stream_stat.py b/analytics/migrations/0009_remove_messages_to_stream_stat.py index 2973ba9af0..67bb4ba7e2 100644 --- a/analytics/migrations/0009_remove_messages_to_stream_stat.py +++ b/analytics/migrations/0009_remove_messages_to_stream_stat.py @@ -3,6 +3,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def delete_messages_sent_to_stream_stat(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserCount = apps.get_model('analytics', 'UserCount') StreamCount = apps.get_model('analytics', 'StreamCount') diff --git a/analytics/migrations/0010_clear_messages_sent_values.py b/analytics/migrations/0010_clear_messages_sent_values.py index 68cb5fce64..7a3da15b26 100644 --- a/analytics/migrations/0010_clear_messages_sent_values.py +++ b/analytics/migrations/0010_clear_messages_sent_values.py @@ -3,6 +3,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def clear_message_sent_by_message_type_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserCount = apps.get_model('analytics', 'UserCount') StreamCount = apps.get_model('analytics', 'StreamCount') diff --git a/analytics/migrations/0011_clear_analytics_tables.py b/analytics/migrations/0011_clear_analytics_tables.py index 1fb73ea8fc..e493274802 100644 --- a/analytics/migrations/0011_clear_analytics_tables.py +++ b/analytics/migrations/0011_clear_analytics_tables.py @@ -3,6 +3,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def clear_analytics_tables(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserCount = apps.get_model('analytics', 'UserCount') StreamCount = apps.get_model('analytics', 'StreamCount') diff --git a/analytics/migrations/0012_add_on_delete.py b/analytics/migrations/0012_add_on_delete.py index ee298af860..32b7d61b1f 100644 --- a/analytics/migrations/0012_add_on_delete.py +++ b/analytics/migrations/0012_add_on_delete.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.6 on 2018-01-29 08:14 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/corporate/migrations/0001_initial.py b/corporate/migrations/0001_initial.py index 5c34d7406c..6995460dde 100644 --- a/corporate/migrations/0001_initial.py +++ b/corporate/migrations/0001_initial.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.14 on 2018-09-25 12:02 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/corporate/migrations/0003_customerplan.py b/corporate/migrations/0003_customerplan.py index 6fd93d43ea..ecbc6bf6ef 100644 --- a/corporate/migrations/0003_customerplan.py +++ b/corporate/migrations/0003_customerplan.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.16 on 2018-12-22 21:05 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/corporate/migrations/0004_licenseledger.py b/corporate/migrations/0004_licenseledger.py index 4df372682d..691671edb6 100644 --- a/corporate/migrations/0004_licenseledger.py +++ b/corporate/migrations/0004_licenseledger.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.18 on 2019-01-19 05:01 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/corporate/migrations/0005_customerplan_invoicing.py b/corporate/migrations/0005_customerplan_invoicing.py index d0e95ce591..ef2a7a444f 100644 --- a/corporate/migrations/0005_customerplan_invoicing.py +++ b/corporate/migrations/0005_customerplan_invoicing.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.18 on 2019-01-28 13:04 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/pgroonga/migrations/0001_enable.py b/pgroonga/migrations/0001_enable.py index ab427cf1c2..50ac86fff6 100644 --- a/pgroonga/migrations/0001_enable.py +++ b/pgroonga/migrations/0001_enable.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from django.db import migrations from django.conf import settings +from django.db import migrations class Migration(migrations.Migration): diff --git a/pgroonga/migrations/0002_html_escape_subject.py b/pgroonga/migrations/0002_html_escape_subject.py index cd23a89e67..144023f7c4 100644 --- a/pgroonga/migrations/0002_html_escape_subject.py +++ b/pgroonga/migrations/0002_html_escape_subject.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- -from django.db import migrations, connection +from django.db import connection, migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + from zerver.lib.migrate import do_batch_update + def rebuild_pgroonga_index(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: with connection.cursor() as cursor: do_batch_update(cursor, 'zerver_message', ['search_pgroonga'], diff --git a/pgroonga/migrations/0003_v2_api_upgrade.py b/pgroonga/migrations/0003_v2_api_upgrade.py index ea5066d224..f52c4b1daf 100644 --- a/pgroonga/migrations/0003_v2_api_upgrade.py +++ b/pgroonga/migrations/0003_v2_api_upgrade.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from django.db import migrations from django.conf import settings +from django.db import migrations class Migration(migrations.Migration): diff --git a/zerver/management/commands/add_users_to_mailing_list.py b/zerver/management/commands/add_users_to_mailing_list.py index 81c7ae2042..77826ca27a 100644 --- a/zerver/management/commands/add_users_to_mailing_list.py +++ b/zerver/management/commands/add_users_to_mailing_list.py @@ -10,6 +10,7 @@ from django.utils.timezone import now as timezone_now from zerver.models import UserProfile + class Command(BaseCommand): help = """Add users to a MailChimp mailing list.""" diff --git a/zerver/management/commands/add_users_to_streams.py b/zerver/management/commands/add_users_to_streams.py index b35ddd4ab6..3061e76765 100644 --- a/zerver/management/commands/add_users_to_streams.py +++ b/zerver/management/commands/add_users_to_streams.py @@ -5,6 +5,7 @@ from django.core.management.base import CommandParser from zerver.lib.actions import bulk_add_subscriptions, ensure_stream from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Add some or all users in a realm to a set of streams.""" diff --git a/zerver/management/commands/archive_messages.py b/zerver/management/commands/archive_messages.py index fcfdd62b16..46d214c11e 100644 --- a/zerver/management/commands/archive_messages.py +++ b/zerver/management/commands/archive_messages.py @@ -3,6 +3,7 @@ from __future__ import absolute_import from typing import Any from django.core.management.base import BaseCommand + from zerver.lib.retention import archive_messages, clean_archived_data diff --git a/zerver/management/commands/backup.py b/zerver/management/commands/backup.py index 3c6cc5adec..376dbba02f 100644 --- a/zerver/management/commands/backup.py +++ b/zerver/management/commands/backup.py @@ -8,7 +8,7 @@ from django.conf import settings from django.db import connection from django.utils.timezone import now as timezone_now -from scripts.lib.zulip_tools import parse_os_release, run, TIMESTAMP_FORMAT +from scripts.lib.zulip_tools import TIMESTAMP_FORMAT, parse_os_release, run from version import ZULIP_VERSION from zerver.lib.management import ZulipBaseCommand from zerver.logging_handlers import try_git_describe diff --git a/zerver/management/commands/bankrupt_users.py b/zerver/management/commands/bankrupt_users.py index f81fd11add..ae67c66c61 100644 --- a/zerver/management/commands/bankrupt_users.py +++ b/zerver/management/commands/bankrupt_users.py @@ -7,6 +7,7 @@ from zerver.lib.actions import do_mark_all_as_read from zerver.lib.management import ZulipBaseCommand from zerver.models import Message + class Command(ZulipBaseCommand): help = """Bankrupt one or many users.""" diff --git a/zerver/management/commands/bulk_change_user_name.py b/zerver/management/commands/bulk_change_user_name.py index b4c7d1b0a2..59743ca0eb 100644 --- a/zerver/management/commands/bulk_change_user_name.py +++ b/zerver/management/commands/bulk_change_user_name.py @@ -6,6 +6,7 @@ from django.core.management.base import CommandError from zerver.lib.actions import do_change_full_name from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Change the names for many users.""" diff --git a/zerver/management/commands/change_user_email.py b/zerver/management/commands/change_user_email.py index fd27c9fb1d..3741901629 100644 --- a/zerver/management/commands/change_user_email.py +++ b/zerver/management/commands/change_user_email.py @@ -4,6 +4,7 @@ from typing import Any from zerver.lib.actions import do_change_user_delivery_email from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Change the email address for a user.""" diff --git a/zerver/management/commands/check_redis.py b/zerver/management/commands/check_redis.py index b7bd86be06..5feb8803e3 100644 --- a/zerver/management/commands/check_redis.py +++ b/zerver/management/commands/check_redis.py @@ -3,12 +3,14 @@ import time from typing import Any, Callable, Optional from django.conf import settings -from django.core.management.base import BaseCommand, CommandParser, CommandError +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser -from zerver.lib.rate_limiter import RateLimitedUser, \ - client, max_api_calls, max_api_window +from zerver.lib.rate_limiter import RateLimitedUser, client, max_api_calls, \ + max_api_window from zerver.models import get_user_profile_by_id + class Command(BaseCommand): help = """Checks redis to make sure our rate limiting system hasn't grown a bug and left redis with a bunch of data diff --git a/zerver/management/commands/checkconfig.py b/zerver/management/commands/checkconfig.py index be9eaec8ad..47f6474436 100644 --- a/zerver/management/commands/checkconfig.py +++ b/zerver/management/commands/checkconfig.py @@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand from zerver.lib.management import check_config + class Command(BaseCommand): help = """Checks your Zulip Voyager Django configuration for issues.""" diff --git a/zerver/management/commands/compilemessages.py b/zerver/management/commands/compilemessages.py index 321bea92e1..5ea4c724a4 100644 --- a/zerver/management/commands/compilemessages.py +++ b/zerver/management/commands/compilemessages.py @@ -1,11 +1,11 @@ import json import os -import polib import re -import ujson from subprocess import CalledProcessError, check_output from typing import Any, Dict, List +import polib +import ujson from django.conf import settings from django.conf.locale import LANG_INFO from django.core.management.base import CommandParser @@ -14,6 +14,7 @@ from django.utils.translation.trans_real import to_language from zerver.lib.i18n import with_language + class Command(compilemessages.Command): def add_arguments(self, parser: CommandParser) -> None: diff --git a/zerver/management/commands/convert_gitter_data.py b/zerver/management/commands/convert_gitter_data.py index a4cd5766dd..a4fb54d8d2 100644 --- a/zerver/management/commands/convert_gitter_data.py +++ b/zerver/management/commands/convert_gitter_data.py @@ -3,10 +3,12 @@ import os import tempfile from typing import Any -from django.core.management.base import BaseCommand, CommandParser, CommandError +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser from zerver.data_import.gitter import do_convert_data + class Command(BaseCommand): help = """Convert the Gitter data into Zulip data format.""" diff --git a/zerver/management/commands/convert_hipchat_data.py b/zerver/management/commands/convert_hipchat_data.py index 44f448a9b1..8182666337 100644 --- a/zerver/management/commands/convert_hipchat_data.py +++ b/zerver/management/commands/convert_hipchat_data.py @@ -21,10 +21,12 @@ spec: exporting-from-hipchat-server-or-data-center-for-data-portability-950821555.html ''' -from django.core.management.base import BaseCommand, CommandParser, CommandError +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser from zerver.data_import.hipchat import do_convert_data + class Command(BaseCommand): help = """Convert the Hipchat data into Zulip data format.""" diff --git a/zerver/management/commands/convert_mattermost_data.py b/zerver/management/commands/convert_mattermost_data.py index 9d2906b144..43ea478113 100644 --- a/zerver/management/commands/convert_mattermost_data.py +++ b/zerver/management/commands/convert_mattermost_data.py @@ -14,10 +14,12 @@ Test out the realm: go to browser and use your dev url ''' -from django.core.management.base import BaseCommand, CommandParser, CommandError +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser from zerver.data_import.mattermost import do_convert_data + class Command(BaseCommand): help = """Convert the mattermost data into Zulip data format.""" diff --git a/zerver/management/commands/convert_slack_data.py b/zerver/management/commands/convert_slack_data.py index 1e9bdf8d87..1cc9e21d83 100644 --- a/zerver/management/commands/convert_slack_data.py +++ b/zerver/management/commands/convert_slack_data.py @@ -3,10 +3,12 @@ import os import tempfile from typing import Any -from django.core.management.base import BaseCommand, CommandParser, CommandError +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser from zerver.data_import.slack import do_convert_data + class Command(BaseCommand): help = """Convert the Slack data into Zulip data format.""" diff --git a/zerver/management/commands/create_default_stream_groups.py b/zerver/management/commands/create_default_stream_groups.py index be0f2e163f..3cf42fbd1b 100644 --- a/zerver/management/commands/create_default_stream_groups.py +++ b/zerver/management/commands/create_default_stream_groups.py @@ -5,6 +5,7 @@ from zerver.lib.actions import ensure_stream from zerver.lib.management import ZulipBaseCommand from zerver.models import DefaultStreamGroup + class Command(ZulipBaseCommand): help = """ Create default stream groups which the users can choose during sign up. diff --git a/zerver/management/commands/create_large_indexes.py b/zerver/management/commands/create_large_indexes.py index b633e148fb..a77dd24419 100644 --- a/zerver/management/commands/create_large_indexes.py +++ b/zerver/management/commands/create_large_indexes.py @@ -4,6 +4,7 @@ from django.db import connection from zerver.lib.management import ZulipBaseCommand + def create_indexes() -> None: # Creating concurrent indexes is kind of a pain with current versions # of Django/postgres, because you will get this error with seemingly diff --git a/zerver/management/commands/create_realm_internal_bots.py b/zerver/management/commands/create_realm_internal_bots.py index c7c8ae5eb1..c2cdd23ff0 100644 --- a/zerver/management/commands/create_realm_internal_bots.py +++ b/zerver/management/commands/create_realm_internal_bots.py @@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand from zerver.lib.onboarding import create_if_missing_realm_internal_bots + class Command(BaseCommand): help = """\ Create realm internal bots if absent, in all realms. diff --git a/zerver/management/commands/create_stream.py b/zerver/management/commands/create_stream.py index bd04d8eb42..5c6058c38f 100644 --- a/zerver/management/commands/create_stream.py +++ b/zerver/management/commands/create_stream.py @@ -4,6 +4,7 @@ from typing import Any from zerver.lib.actions import create_stream_if_needed from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Create a stream, and subscribe all active users (excluding bots). diff --git a/zerver/management/commands/create_user.py b/zerver/management/commands/create_user.py index 72e8c11497..fc776ab48e 100644 --- a/zerver/management/commands/create_user.py +++ b/zerver/management/commands/create_user.py @@ -12,6 +12,7 @@ from zerver.lib.initial_password import initial_password from zerver.lib.management import ZulipBaseCommand from zerver.models import email_to_username + class Command(ZulipBaseCommand): help = """Create the specified user with a default initial password. diff --git a/zerver/management/commands/deactivate_realm.py b/zerver/management/commands/deactivate_realm.py index 480fa5061d..16d68a4748 100644 --- a/zerver/management/commands/deactivate_realm.py +++ b/zerver/management/commands/deactivate_realm.py @@ -4,6 +4,7 @@ from typing import Any from zerver.lib.actions import do_deactivate_realm from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Script to deactivate a realm.""" diff --git a/zerver/management/commands/deactivate_user.py b/zerver/management/commands/deactivate_user.py index 75874d9ed0..d981a696d7 100644 --- a/zerver/management/commands/deactivate_user.py +++ b/zerver/management/commands/deactivate_user.py @@ -2,10 +2,11 @@ from argparse import ArgumentParser from typing import Any from zerver.lib.actions import do_deactivate_user -from zerver.lib.management import ZulipBaseCommand, CommandError +from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.lib.sessions import user_sessions from zerver.models import UserProfile + class Command(ZulipBaseCommand): help = "Deactivate a user, including forcibly logging them out." diff --git a/zerver/management/commands/delete_old_unclaimed_attachments.py b/zerver/management/commands/delete_old_unclaimed_attachments.py index 42f8330910..f188240c5d 100644 --- a/zerver/management/commands/delete_old_unclaimed_attachments.py +++ b/zerver/management/commands/delete_old_unclaimed_attachments.py @@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand, CommandError from zerver.lib.actions import do_delete_old_unclaimed_attachments from zerver.models import get_old_unclaimed_attachments + class Command(BaseCommand): help = """Remove unclaimed attachments from storage older than a supplied numerical value indicating the limit of how old the attachment can be. diff --git a/zerver/management/commands/deliver_email.py b/zerver/management/commands/deliver_email.py index 595b4b911b..a352090ebd 100644 --- a/zerver/management/commands/deliver_email.py +++ b/zerver/management/commands/deliver_email.py @@ -7,7 +7,6 @@ machines, as you may encounter multiple sends in a specific race condition. (Alternatively, you can set `EMAIL_DELIVERER_DISABLED=True` on all but one machine to make the command have no effect.) """ - import logging import time from typing import Any diff --git a/zerver/management/commands/deliver_scheduled_messages.py b/zerver/management/commands/deliver_scheduled_messages.py index 3bf3ad207e..f98a9ff9ef 100644 --- a/zerver/management/commands/deliver_scheduled_messages.py +++ b/zerver/management/commands/deliver_scheduled_messages.py @@ -1,17 +1,17 @@ import logging import time -from typing import Any, Dict from datetime import timedelta +from typing import Any, Dict from django.conf import settings from django.core.management.base import BaseCommand from django.db import transaction from django.utils.timezone import now as timezone_now +from zerver.lib.actions import do_send_messages from zerver.lib.logging_util import log_to_file from zerver.lib.management import sleep_forever -from zerver.models import ScheduledMessage, Message, get_user_by_delivery_email -from zerver.lib.actions import do_send_messages +from zerver.models import Message, ScheduledMessage, get_user_by_delivery_email ## Setup ## logger = logging.getLogger(__name__) diff --git a/zerver/management/commands/dump_messages.py b/zerver/management/commands/dump_messages.py index c4b8a23d72..d337ba14af 100644 --- a/zerver/management/commands/dump_messages.py +++ b/zerver/management/commands/dump_messages.py @@ -8,6 +8,7 @@ from django.utils.timezone import utc as timezone_utc from zerver.lib.management import ZulipBaseCommand from zerver.models import Message, Recipient, Stream + class Command(ZulipBaseCommand): help = "Dump messages from public streams of a realm" diff --git a/zerver/management/commands/email_mirror.py b/zerver/management/commands/email_mirror.py index 2a1afaceb6..85028e8427 100644 --- a/zerver/management/commands/email_mirror.py +++ b/zerver/management/commands/email_mirror.py @@ -19,8 +19,6 @@ We extract and validate the target stream from information in the recipient address and retrieve, forward, and archive the message. """ - - import email import logging from email.message import Message diff --git a/zerver/management/commands/enqueue_file.py b/zerver/management/commands/enqueue_file.py index e0ebc8dd0e..6ed136fa71 100644 --- a/zerver/management/commands/enqueue_file.py +++ b/zerver/management/commands/enqueue_file.py @@ -7,6 +7,7 @@ from django.core.management.base import BaseCommand from zerver.lib.queue import queue_json_publish + def error(*args: Any) -> None: raise Exception('We cannot enqueue because settings.USING_RABBITMQ is False.') diff --git a/zerver/management/commands/export.py b/zerver/management/commands/export.py index e5ae775faf..4f3ed462ba 100644 --- a/zerver/management/commands/export.py +++ b/zerver/management/commands/export.py @@ -5,10 +5,11 @@ from typing import Any from django.core.management.base import CommandError -from zerver.lib.management import ZulipBaseCommand from zerver.lib.export import export_realm_wrapper +from zerver.lib.management import ZulipBaseCommand from zerver.models import Message, Reaction + class Command(ZulipBaseCommand): help = """Exports all data from a Zulip realm diff --git a/zerver/management/commands/export_single_user.py b/zerver/management/commands/export_single_user.py index dda9842c24..6f19a22a41 100644 --- a/zerver/management/commands/export_single_user.py +++ b/zerver/management/commands/export_single_user.py @@ -8,6 +8,7 @@ from typing import Any from zerver.lib.export import do_export_user from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Exports message data from a Zulip user diff --git a/zerver/management/commands/export_usermessage_batch.py b/zerver/management/commands/export_usermessage_batch.py index 5fadb8da54..72c70d31c8 100644 --- a/zerver/management/commands/export_usermessage_batch.py +++ b/zerver/management/commands/export_usermessage_batch.py @@ -9,6 +9,7 @@ from django.core.management.base import BaseCommand from zerver.lib.export import export_usermessages_batch + class Command(BaseCommand): help = """UserMessage fetching helper for export.py""" diff --git a/zerver/management/commands/fill_memcached_caches.py b/zerver/management/commands/fill_memcached_caches.py index 7bcc7deef5..933a17004e 100644 --- a/zerver/management/commands/fill_memcached_caches.py +++ b/zerver/management/commands/fill_memcached_caches.py @@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand from zerver.lib.cache_helpers import cache_fillers, fill_remote_cache + class Command(BaseCommand): def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument('--cache', dest="cache", default=None, diff --git a/zerver/management/commands/fix_unreads.py b/zerver/management/commands/fix_unreads.py index 6f66ab8e2c..0ad250ab64 100644 --- a/zerver/management/commands/fix_unreads.py +++ b/zerver/management/commands/fix_unreads.py @@ -5,7 +5,7 @@ from typing import Any, List, Optional from django.db import connection from zerver.lib.fix_unreads import fix -from zerver.lib.management import ZulipBaseCommand, CommandError +from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.models import Realm, UserProfile logging.getLogger('zulip.fix_unreads').setLevel(logging.INFO) diff --git a/zerver/management/commands/generate_invite_links.py b/zerver/management/commands/generate_invite_links.py index bf5e79da5d..9a0cf74657 100644 --- a/zerver/management/commands/generate_invite_links.py +++ b/zerver/management/commands/generate_invite_links.py @@ -5,8 +5,9 @@ from django.core.management.base import CommandError from confirmation.models import Confirmation, create_confirmation_link from zerver.lib.management import ZulipBaseCommand -from zerver.models import PreregistrationUser, email_allowed_for_realm, \ - DomainNotAllowedForRealmError +from zerver.models import DomainNotAllowedForRealmError, PreregistrationUser, \ + email_allowed_for_realm + class Command(ZulipBaseCommand): help = "Generate activation links for users and print them to stdout." diff --git a/zerver/management/commands/generate_multiuse_invite_link.py b/zerver/management/commands/generate_multiuse_invite_link.py index 67616cae27..a6100d63c0 100644 --- a/zerver/management/commands/generate_multiuse_invite_link.py +++ b/zerver/management/commands/generate_multiuse_invite_link.py @@ -1,9 +1,10 @@ from argparse import ArgumentParser from typing import Any, List -from zerver.lib.actions import ensure_stream, do_create_multiuse_invite_link +from zerver.lib.actions import do_create_multiuse_invite_link, ensure_stream from zerver.lib.management import ZulipBaseCommand -from zerver.models import Stream, PreregistrationUser +from zerver.models import PreregistrationUser, Stream + class Command(ZulipBaseCommand): help = "Generates invite link that can be used for inviting multiple users" diff --git a/zerver/management/commands/generate_realm_creation_link.py b/zerver/management/commands/generate_realm_creation_link.py index dc72eb25e3..e5ee6366ad 100644 --- a/zerver/management/commands/generate_realm_creation_link.py +++ b/zerver/management/commands/generate_realm_creation_link.py @@ -3,9 +3,10 @@ from typing import Any from django.db import ProgrammingError from confirmation.models import generate_realm_creation_url -from zerver.lib.management import ZulipBaseCommand, CommandError +from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.models import Realm + class Command(ZulipBaseCommand): help = """ Outputs a randomly generated, 1-time-use link for Organization creation. diff --git a/zerver/management/commands/get_migration_status.py b/zerver/management/commands/get_migration_status.py index ba18395d6e..e80371cb89 100644 --- a/zerver/management/commands/get_migration_status.py +++ b/zerver/management/commands/get_migration_status.py @@ -9,6 +9,7 @@ from django.db import DEFAULT_DB_ALIAS from scripts.lib.zulip_tools import get_dev_uuid_var_path from zerver.lib.test_fixtures import get_migration_status + class Command(BaseCommand): help = "Get status of migrations." diff --git a/zerver/management/commands/import.py b/zerver/management/commands/import.py index af4f275436..5e77852e9d 100644 --- a/zerver/management/commands/import.py +++ b/zerver/management/commands/import.py @@ -5,10 +5,12 @@ from typing import Any from django.conf import settings from django.core.management import call_command -from django.core.management.base import BaseCommand, CommandParser, CommandError +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser -from zerver.lib.import_realm import do_import_realm, do_import_system_bots from zerver.forms import check_subdomain_available +from zerver.lib.import_realm import do_import_realm, do_import_system_bots + class Command(BaseCommand): help = """Import extracted Zulip database dump directories into a fresh Zulip instance. diff --git a/zerver/management/commands/initialize_voyager_db.py b/zerver/management/commands/initialize_voyager_db.py index 0e7d8ff2b3..24e8d4cef7 100644 --- a/zerver/management/commands/initialize_voyager_db.py +++ b/zerver/management/commands/initialize_voyager_db.py @@ -1,13 +1,13 @@ from argparse import ArgumentParser -from typing import Any, Iterable, Tuple, Optional +from typing import Any, Iterable, Optional, Tuple from django.conf import settings from django.core.management.base import BaseCommand from zerver.lib.actions import do_change_is_admin from zerver.lib.bulk_create import bulk_create_users -from zerver.models import Realm, UserProfile, \ - email_to_username, get_client, get_system_bot +from zerver.models import Realm, UserProfile, email_to_username, get_client, \ + get_system_bot settings.TORNADO_SERVER = None diff --git a/zerver/management/commands/knight.py b/zerver/management/commands/knight.py index 2be6d10990..bbb61c5b17 100644 --- a/zerver/management/commands/knight.py +++ b/zerver/management/commands/knight.py @@ -6,6 +6,7 @@ from django.core.management.base import CommandError from zerver.lib.actions import do_change_is_admin from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Give an existing user administrative permissions over their (own) Realm. diff --git a/zerver/management/commands/list_realms.py b/zerver/management/commands/list_realms.py index 03ceefc04e..c1a0912008 100644 --- a/zerver/management/commands/list_realms.py +++ b/zerver/management/commands/list_realms.py @@ -5,6 +5,7 @@ from typing import Any from zerver.lib.management import ZulipBaseCommand from zerver.models import Realm + class Command(ZulipBaseCommand): help = """List realms in the server and it's configuration settings(optional). diff --git a/zerver/management/commands/logout_all_users.py b/zerver/management/commands/logout_all_users.py index 22f80a3719..6108643a58 100644 --- a/zerver/management/commands/logout_all_users.py +++ b/zerver/management/commands/logout_all_users.py @@ -5,6 +5,7 @@ from zerver.lib.management import ZulipBaseCommand from zerver.lib.sessions import delete_all_deactivated_user_sessions, \ delete_all_user_sessions, delete_realm_user_sessions + class Command(ZulipBaseCommand): help = "Log out all users." diff --git a/zerver/management/commands/makemessages.py b/zerver/management/commands/makemessages.py index 3151d07969..6ff654ebaa 100644 --- a/zerver/management/commands/makemessages.py +++ b/zerver/management/commands/makemessages.py @@ -28,7 +28,6 @@ Credit for the approach goes to: http://stackoverflow.com/questions/2090717 """ - import glob import json import os diff --git a/zerver/management/commands/merge_streams.py b/zerver/management/commands/merge_streams.py index 69e895ea93..927fa06f33 100644 --- a/zerver/management/commands/merge_streams.py +++ b/zerver/management/commands/merge_streams.py @@ -5,8 +5,9 @@ from zerver.lib.actions import bulk_add_subscriptions, \ bulk_remove_subscriptions, do_deactivate_stream from zerver.lib.cache import cache_delete_many, to_dict_cache_key_id from zerver.lib.management import ZulipBaseCommand -from zerver.models import Message, Subscription, \ - get_stream, get_stream_recipient +from zerver.models import Message, Subscription, get_stream, \ + get_stream_recipient + def bulk_delete_cache_keys(message_ids_to_clear: List[int]) -> None: while len(message_ids_to_clear) > 0: diff --git a/zerver/management/commands/print_email_delivery_backlog.py b/zerver/management/commands/print_email_delivery_backlog.py index f58de5b1ae..b8f9934c54 100644 --- a/zerver/management/commands/print_email_delivery_backlog.py +++ b/zerver/management/commands/print_email_delivery_backlog.py @@ -1,8 +1,6 @@ """ Shows backlog count of ScheduledEmail """ - - from datetime import timedelta from typing import Any @@ -11,6 +9,7 @@ from django.utils.timezone import now as timezone_now from zerver.models import ScheduledEmail + class Command(BaseCommand): help = """Shows backlog count of ScheduledEmail (The number of currently overdue (by at least a minute) email jobs) diff --git a/zerver/management/commands/process_queue.py b/zerver/management/commands/process_queue.py index 2fe419ae4e..ad92ffd5bc 100644 --- a/zerver/management/commands/process_queue.py +++ b/zerver/management/commands/process_queue.py @@ -12,6 +12,7 @@ from django.utils import autoreload from zerver.worker.queue_processors import get_active_worker_queues, get_worker + class Command(BaseCommand): def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument('--queue_name', metavar='', type=str, diff --git a/zerver/management/commands/purge_queue.py b/zerver/management/commands/purge_queue.py index edc596b4c4..fe594a531f 100644 --- a/zerver/management/commands/purge_queue.py +++ b/zerver/management/commands/purge_queue.py @@ -7,6 +7,7 @@ from django.core.management.base import BaseCommand from zerver.lib.queue import SimpleQueueClient from zerver.worker.queue_processors import get_active_worker_queues + class Command(BaseCommand): def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument(dest="queue_name", type=str, nargs='?', diff --git a/zerver/management/commands/query_ldap.py b/zerver/management/commands/query_ldap.py index 358117391e..ac32410b7d 100644 --- a/zerver/management/commands/query_ldap.py +++ b/zerver/management/commands/query_ldap.py @@ -5,6 +5,7 @@ from django.core.management.base import BaseCommand from zproject.backends import query_ldap + class Command(BaseCommand): def add_arguments(self, parser: ArgumentParser) -> None: parser.add_argument('email', metavar='', type=str, diff --git a/zerver/management/commands/rate_limit.py b/zerver/management/commands/rate_limit.py index 09de510cf3..0a5b986b5b 100644 --- a/zerver/management/commands/rate_limit.py +++ b/zerver/management/commands/rate_limit.py @@ -1,11 +1,12 @@ from argparse import ArgumentParser from typing import Any -from zerver.lib.management import ZulipBaseCommand, CommandError -from zerver.lib.rate_limiter import RateLimitedUser, \ - block_access, unblock_access +from zerver.lib.management import CommandError, ZulipBaseCommand +from zerver.lib.rate_limiter import RateLimitedUser, block_access, \ + unblock_access from zerver.models import UserProfile, get_user_profile_by_api_key + class Command(ZulipBaseCommand): help = """Manually block or unblock a user from accessing the API""" diff --git a/zerver/management/commands/reactivate_realm.py b/zerver/management/commands/reactivate_realm.py index 67a731747b..3ce0b4349f 100644 --- a/zerver/management/commands/reactivate_realm.py +++ b/zerver/management/commands/reactivate_realm.py @@ -4,6 +4,7 @@ from typing import Any from zerver.lib.actions import do_reactivate_realm from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Script to reactivate a deactivated realm.""" diff --git a/zerver/management/commands/realm_domain.py b/zerver/management/commands/realm_domain.py index 040aaf24ff..77a5090f74 100644 --- a/zerver/management/commands/realm_domain.py +++ b/zerver/management/commands/realm_domain.py @@ -6,9 +6,10 @@ from django.core.exceptions import ValidationError from django.db.utils import IntegrityError from zerver.lib.domains import validate_domain -from zerver.lib.management import ZulipBaseCommand, CommandError +from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.models import RealmDomain, get_realm_domains + class Command(ZulipBaseCommand): help = """Manage domains for the specified realm""" diff --git a/zerver/management/commands/realm_filters.py b/zerver/management/commands/realm_filters.py index c259ccb5fb..c34fe55658 100644 --- a/zerver/management/commands/realm_filters.py +++ b/zerver/management/commands/realm_filters.py @@ -3,9 +3,10 @@ from argparse import ArgumentParser from typing import Any from zerver.lib.actions import do_add_realm_filter, do_remove_realm_filter -from zerver.lib.management import ZulipBaseCommand, CommandError +from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.models import all_realm_filters + class Command(ZulipBaseCommand): help = """Create a link filter rule for the specified realm. diff --git a/zerver/management/commands/register_server.py b/zerver/management/commands/register_server.py index d6c05b9210..cca99a55bb 100644 --- a/zerver/management/commands/register_server.py +++ b/zerver/management/commands/register_server.py @@ -1,9 +1,9 @@ -from argparse import ArgumentParser import json -import requests import subprocess +from argparse import ArgumentParser from typing import Any +import requests from django.conf import settings from django.core.management.base import CommandError from django.utils.crypto import get_random_string diff --git a/zerver/management/commands/remove_users_from_stream.py b/zerver/management/commands/remove_users_from_stream.py index 52e8334065..743eb97e34 100644 --- a/zerver/management/commands/remove_users_from_stream.py +++ b/zerver/management/commands/remove_users_from_stream.py @@ -6,6 +6,7 @@ from zerver.lib.actions import bulk_remove_subscriptions from zerver.lib.management import ZulipBaseCommand from zerver.models import get_stream + class Command(ZulipBaseCommand): help = """Remove some or all users in a realm from a stream.""" diff --git a/zerver/management/commands/rename_stream.py b/zerver/management/commands/rename_stream.py index a7456a02d9..798de1c3c0 100644 --- a/zerver/management/commands/rename_stream.py +++ b/zerver/management/commands/rename_stream.py @@ -5,6 +5,7 @@ from zerver.lib.actions import do_rename_stream from zerver.lib.management import ZulipBaseCommand from zerver.models import get_stream + class Command(ZulipBaseCommand): help = """Change the stream name for a realm.""" diff --git a/zerver/management/commands/restore_messages.py b/zerver/management/commands/restore_messages.py index b0a0757378..eca14dc4ab 100644 --- a/zerver/management/commands/restore_messages.py +++ b/zerver/management/commands/restore_messages.py @@ -1,11 +1,12 @@ +from typing import Any + from django.core.management.base import CommandParser from zerver.lib.management import ZulipBaseCommand from zerver.lib.retention import restore_all_data_from_archive, \ - restore_data_from_archive_by_realm, restore_data_from_archive + restore_data_from_archive, restore_data_from_archive_by_realm from zerver.models import ArchiveTransaction -from typing import Any class Command(ZulipBaseCommand): help = """ diff --git a/zerver/management/commands/runtornado.py b/zerver/management/commands/runtornado.py index fb241a2d2b..6479a6bd04 100644 --- a/zerver/management/commands/runtornado.py +++ b/zerver/management/commands/runtornado.py @@ -3,8 +3,8 @@ import sys from typing import Any, Callable from django.conf import settings -from django.core.management.base import BaseCommand, \ - CommandError, CommandParser +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser from tornado import ioloop from tornado.log import app_log @@ -24,7 +24,8 @@ from zerver.tornado.application import create_tornado_application, \ from zerver.tornado.autoreload import start as zulip_autoreload_start from zerver.tornado.event_queue import add_client_gc_hook, \ missedmessage_hook, process_notification, setup_event_queue -from zerver.tornado.sharding import notify_tornado_queue_name, tornado_return_queue_name +from zerver.tornado.sharding import notify_tornado_queue_name, \ + tornado_return_queue_name from zerver.tornado.socket import respond_send_message if settings.USING_RABBITMQ: diff --git a/zerver/management/commands/scrub_realm.py b/zerver/management/commands/scrub_realm.py index 7d4d24f235..2052abb633 100644 --- a/zerver/management/commands/scrub_realm.py +++ b/zerver/management/commands/scrub_realm.py @@ -4,6 +4,7 @@ from typing import Any from zerver.lib.actions import do_scrub_realm from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Script to scrub a deactivated realm.""" diff --git a/zerver/management/commands/send_custom_email.py b/zerver/management/commands/send_custom_email.py index cb90e9f698..33ddd51c11 100644 --- a/zerver/management/commands/send_custom_email.py +++ b/zerver/management/commands/send_custom_email.py @@ -1,7 +1,6 @@ import hashlib import shutil import subprocess - from argparse import ArgumentParser from typing import Any, Dict, List @@ -10,6 +9,7 @@ from zerver.lib.send_email import FromAddress, send_email from zerver.models import UserProfile from zerver.templatetags.app_filters import render_markdown_path + def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None: """ Can be used directly with from a management shell with diff --git a/zerver/management/commands/send_password_reset_email.py b/zerver/management/commands/send_password_reset_email.py index 51750ed325..17cf93a257 100644 --- a/zerver/management/commands/send_password_reset_email.py +++ b/zerver/management/commands/send_password_reset_email.py @@ -8,6 +8,7 @@ from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.lib.send_email import FromAddress, send_email from zerver.models import UserProfile + class Command(ZulipBaseCommand): help = """Send email to specified email address.""" diff --git a/zerver/management/commands/send_realm_reactivation_email.py b/zerver/management/commands/send_realm_reactivation_email.py index 637df538a3..5ff1f60015 100644 --- a/zerver/management/commands/send_realm_reactivation_email.py +++ b/zerver/management/commands/send_realm_reactivation_email.py @@ -1,10 +1,10 @@ from argparse import ArgumentParser - -from zerver.lib.management import ZulipBaseCommand, CommandError -from zerver.lib.actions import do_send_realm_reactivation_email - from typing import Any +from zerver.lib.actions import do_send_realm_reactivation_email +from zerver.lib.management import CommandError, ZulipBaseCommand + + class Command(ZulipBaseCommand): help = """Sends realm reactivation email to admins""" diff --git a/zerver/management/commands/send_stats.py b/zerver/management/commands/send_stats.py index 1484ded486..7986235768 100644 --- a/zerver/management/commands/send_stats.py +++ b/zerver/management/commands/send_stats.py @@ -4,6 +4,7 @@ from typing import Any from django.conf import settings from django.core.management.base import BaseCommand + class Command(BaseCommand): help = """Send some stats to statsd.""" diff --git a/zerver/management/commands/send_test_email.py b/zerver/management/commands/send_test_email.py index 996616093d..ce512afcdb 100644 --- a/zerver/management/commands/send_test_email.py +++ b/zerver/management/commands/send_test_email.py @@ -7,6 +7,7 @@ from django.core.management.commands import sendtestemail from zerver.lib.send_email import FromAddress + class Command(sendtestemail.Command): def handle(self, *args: Any, **kwargs: str) -> None: if settings.WARN_NO_EMAIL: diff --git a/zerver/management/commands/send_to_email_mirror.py b/zerver/management/commands/send_to_email_mirror.py index 97900eaed8..d93c527af1 100644 --- a/zerver/management/commands/send_to_email_mirror.py +++ b/zerver/management/commands/send_to_email_mirror.py @@ -1,20 +1,17 @@ -import os import email -import ujson - +import os from email.message import Message from email.mime.text import MIMEText +from typing import Dict, Optional +import ujson from django.conf import settings from django.core.management.base import CommandParser from zerver.lib.email_mirror import mirror_email_message from zerver.lib.email_mirror_helpers import encode_email_address -from zerver.lib.management import ZulipBaseCommand, CommandError - -from zerver.models import Realm, get_stream, get_realm - -from typing import Dict, Optional +from zerver.lib.management import CommandError, ZulipBaseCommand +from zerver.models import Realm, get_realm, get_stream # This command loads an email from a specified file and sends it # to the email mirror. Simple emails can be passed in a JSON file, diff --git a/zerver/management/commands/send_webhook_fixture_message.py b/zerver/management/commands/send_webhook_fixture_message.py index b201aa7a23..2389e77401 100644 --- a/zerver/management/commands/send_webhook_fixture_message.py +++ b/zerver/management/commands/send_webhook_fixture_message.py @@ -1,15 +1,16 @@ import os -import ujson -from typing import Union, Dict, Optional +from typing import Dict, Optional, Union +import ujson from django.conf import settings from django.core.management.base import CommandParser from django.test import Client -from zerver.lib.management import ZulipBaseCommand, CommandError +from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.lib.webhooks.common import standardize_headers from zerver.models import get_realm + class Command(ZulipBaseCommand): help = """ Create webhook message based on given fixture diff --git a/zerver/management/commands/set_message_flags.py b/zerver/management/commands/set_message_flags.py index 7a6893c104..596d0a60a5 100644 --- a/zerver/management/commands/set_message_flags.py +++ b/zerver/management/commands/set_message_flags.py @@ -6,9 +6,10 @@ from django.core.management.base import CommandParser from django.db import models from zerver.lib import utils -from zerver.lib.management import ZulipBaseCommand, CommandError +from zerver.lib.management import CommandError, ZulipBaseCommand from zerver.models import UserMessage + class Command(ZulipBaseCommand): help = """Sets user message flags. Used internally by actions.py. Marks all Expects a comma-delimited list of user message ids via stdin, and an EOF to terminate.""" diff --git a/zerver/management/commands/show_admins.py b/zerver/management/commands/show_admins.py index 3d6a781fda..92b2c1d6f3 100644 --- a/zerver/management/commands/show_admins.py +++ b/zerver/management/commands/show_admins.py @@ -3,6 +3,7 @@ from typing import Any from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Show the admins in a realm.""" diff --git a/zerver/management/commands/show_unreads.py b/zerver/management/commands/show_unreads.py index 304d07216e..f897475c7b 100644 --- a/zerver/management/commands/show_unreads.py +++ b/zerver/management/commands/show_unreads.py @@ -7,6 +7,7 @@ from zerver.lib.management import ZulipBaseCommand from zerver.lib.topic_mutes import build_topic_mute_checker from zerver.models import Recipient, Subscription, UserMessage, UserProfile + def get_unread_messages(user_profile: UserProfile) -> List[Dict[str, Any]]: user_msgs = UserMessage.objects.filter( user_profile=user_profile, diff --git a/zerver/management/commands/soft_deactivate_users.py b/zerver/management/commands/soft_deactivate_users.py index c1b18e8bb7..fc4619ee48 100644 --- a/zerver/management/commands/soft_deactivate_users.py +++ b/zerver/management/commands/soft_deactivate_users.py @@ -6,10 +6,11 @@ from django.conf import settings from django.core.management.base import CommandError from zerver.lib.management import ZulipBaseCommand -from zerver.lib.soft_deactivation import do_soft_activate_users, \ - do_soft_deactivate_users, do_auto_soft_deactivate_users, logger +from zerver.lib.soft_deactivation import do_auto_soft_deactivate_users, \ + do_soft_activate_users, do_soft_deactivate_users, logger from zerver.models import Realm, UserProfile + def get_users_from_emails(emails: List[str], filter_kwargs: Dict[str, Realm]) -> List[UserProfile]: # Bug: Ideally, this would be case-insensitive like our other email queries. diff --git a/zerver/management/commands/sync_ldap_user_data.py b/zerver/management/commands/sync_ldap_user_data.py index 87c6e54270..078c09a271 100644 --- a/zerver/management/commands/sync_ldap_user_data.py +++ b/zerver/management/commands/sync_ldap_user_data.py @@ -1,10 +1,9 @@ import logging - from argparse import ArgumentParser from typing import Any, List -from django.db import transaction from django.conf import settings +from django.db import transaction from zerver.lib.logging_util import log_to_file from zerver.lib.management import ZulipBaseCommand diff --git a/zerver/management/commands/transfer_uploads_to_s3.py b/zerver/management/commands/transfer_uploads_to_s3.py index 60d211b031..d2c70f9f38 100644 --- a/zerver/management/commands/transfer_uploads_to_s3.py +++ b/zerver/management/commands/transfer_uploads_to_s3.py @@ -1,10 +1,12 @@ from typing import Any -from django.core.management.base import BaseCommand, CommandParser, CommandError from django.conf import settings +from django.core.management.base import BaseCommand, CommandError, \ + CommandParser from zerver.lib.transfer import transfer_uploads_to_s3 + class Command(BaseCommand): help = """Transfer uploads to S3 """ diff --git a/zerver/management/commands/turn_off_digests.py b/zerver/management/commands/turn_off_digests.py index 76b50c3489..a7d7716c38 100644 --- a/zerver/management/commands/turn_off_digests.py +++ b/zerver/management/commands/turn_off_digests.py @@ -3,6 +3,7 @@ from django.core.management.base import CommandParser from zerver.lib.actions import do_change_notification_settings from zerver.lib.management import ZulipBaseCommand + class Command(ZulipBaseCommand): help = """Turn off digests for a subdomain/string_id or specified set of email addresses.""" diff --git a/zerver/migrations/0001_initial.py b/zerver/migrations/0001_initial.py index 6e534a0180..dfb9ce4ecf 100644 --- a/zerver/migrations/0001_initial.py +++ b/zerver/migrations/0001_initial.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-22 10:22 - import bitfield.models import django.contrib.auth.models import django.core.validators @@ -13,6 +12,7 @@ from django.db.migrations.state import StateApps import zerver.models + def migrate_existing_attachment_data(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Attachment = apps.get_model('zerver', 'Attachment') diff --git a/zerver/migrations/0029_realm_subdomain.py b/zerver/migrations/0029_realm_subdomain.py index 14e6f79696..75d058d188 100644 --- a/zerver/migrations/0029_realm_subdomain.py +++ b/zerver/migrations/0029_realm_subdomain.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- - from django.conf import settings from django.core.exceptions import ObjectDoesNotExist from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def set_subdomain_of_default_realm(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: if settings.DEVELOPMENT: Realm = apps.get_model('zerver', 'Realm') diff --git a/zerver/migrations/0030_realm_org_type.py b/zerver/migrations/0030_realm_org_type.py index 4911562433..6ae74ab530 100644 --- a/zerver/migrations/0030_realm_org_type.py +++ b/zerver/migrations/0030_realm_org_type.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0031_remove_system_avatar_source.py b/zerver/migrations/0031_remove_system_avatar_source.py index 6eaad0ed5c..1f19c92d89 100644 --- a/zerver/migrations/0031_remove_system_avatar_source.py +++ b/zerver/migrations/0031_remove_system_avatar_source.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0032_verify_all_medium_avatar_images.py b/zerver/migrations/0032_verify_all_medium_avatar_images.py index 4e6521bcd1..4019a04304 100644 --- a/zerver/migrations/0032_verify_all_medium_avatar_images.py +++ b/zerver/migrations/0032_verify_all_medium_avatar_images.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - import hashlib from typing import Text @@ -13,6 +12,7 @@ from zerver.lib.upload import upload_backend from zerver.lib.utils import make_safe_digest from zerver.models import UserProfile + # We hackishly patch this function in order to revert it to the state # it had when this migration was first written. This is a balance # between copying in a historical version of hundreds of lines of code diff --git a/zerver/migrations/0033_migrate_domain_to_realmalias.py b/zerver/migrations/0033_migrate_domain_to_realmalias.py index 20e6f2f300..3aa8f556e1 100644 --- a/zerver/migrations/0033_migrate_domain_to_realmalias.py +++ b/zerver/migrations/0033_migrate_domain_to_realmalias.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def add_domain_to_realm_alias_if_needed(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') RealmAlias = apps.get_model('zerver', 'RealmAlias') diff --git a/zerver/migrations/0034_userprofile_enable_online_push_notifications.py b/zerver/migrations/0034_userprofile_enable_online_push_notifications.py index 8c902b3b3c..5666f13feb 100644 --- a/zerver/migrations/0034_userprofile_enable_online_push_notifications.py +++ b/zerver/migrations/0034_userprofile_enable_online_push_notifications.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0035_realm_message_retention_period_days.py b/zerver/migrations/0035_realm_message_retention_period_days.py index 0cd8cf90b0..fe5e015e20 100644 --- a/zerver/migrations/0035_realm_message_retention_period_days.py +++ b/zerver/migrations/0035_realm_message_retention_period_days.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0036_rename_subdomain_to_string_id.py b/zerver/migrations/0036_rename_subdomain_to_string_id.py index b7c3a002a2..75d08f2ffa 100644 --- a/zerver/migrations/0036_rename_subdomain_to_string_id.py +++ b/zerver/migrations/0036_rename_subdomain_to_string_id.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0037_disallow_null_string_id.py b/zerver/migrations/0037_disallow_null_string_id.py index d7fad8e42a..4549def203 100644 --- a/zerver/migrations/0037_disallow_null_string_id.py +++ b/zerver/migrations/0037_disallow_null_string_id.py @@ -4,6 +4,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db.utils import IntegrityError + def set_string_id_using_domain(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') for realm in Realm.objects.all(): diff --git a/zerver/migrations/0038_realm_change_to_community_defaults.py b/zerver/migrations/0038_realm_change_to_community_defaults.py index 852cf637cc..c02af64018 100644 --- a/zerver/migrations/0038_realm_change_to_community_defaults.py +++ b/zerver/migrations/0038_realm_change_to_community_defaults.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0039_realmalias_drop_uniqueness.py b/zerver/migrations/0039_realmalias_drop_uniqueness.py index a3361478b3..e3df757c19 100644 --- a/zerver/migrations/0039_realmalias_drop_uniqueness.py +++ b/zerver/migrations/0039_realmalias_drop_uniqueness.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0040_realm_authentication_methods.py b/zerver/migrations/0040_realm_authentication_methods.py index 3e453b16af..1adb82f9e0 100644 --- a/zerver/migrations/0040_realm_authentication_methods.py +++ b/zerver/migrations/0040_realm_authentication_methods.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- - import bitfield.models from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0041_create_attachments_for_old_messages.py b/zerver/migrations/0041_create_attachments_for_old_messages.py index 5bbdf84643..b38b557b69 100644 --- a/zerver/migrations/0041_create_attachments_for_old_messages.py +++ b/zerver/migrations/0041_create_attachments_for_old_messages.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - import os import re diff --git a/zerver/migrations/0042_attachment_file_name_length.py b/zerver/migrations/0042_attachment_file_name_length.py index 1de866eea1..f53740ee35 100644 --- a/zerver/migrations/0042_attachment_file_name_length.py +++ b/zerver/migrations/0042_attachment_file_name_length.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0043_realm_filter_validators.py b/zerver/migrations/0043_realm_filter_validators.py index 33b836288b..1243619b29 100644 --- a/zerver/migrations/0043_realm_filter_validators.py +++ b/zerver/migrations/0043_realm_filter_validators.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- - import django.core.validators from django.db import migrations, models import zerver.models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0044_reaction.py b/zerver/migrations/0044_reaction.py index 4ed6234f3d..ff4d9b6cf9 100644 --- a/zerver/migrations/0044_reaction.py +++ b/zerver/migrations/0044_reaction.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0045_realm_waiting_period_threshold.py b/zerver/migrations/0045_realm_waiting_period_threshold.py index baa3bd611f..85ce3b5705 100644 --- a/zerver/migrations/0045_realm_waiting_period_threshold.py +++ b/zerver/migrations/0045_realm_waiting_period_threshold.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0046_realmemoji_author.py b/zerver/migrations/0046_realmemoji_author.py index 121516991e..41fa608ecb 100644 --- a/zerver/migrations/0046_realmemoji_author.py +++ b/zerver/migrations/0046_realmemoji_author.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2016-12-20 07:02 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0047_realm_add_emoji_by_admins_only.py b/zerver/migrations/0047_realm_add_emoji_by_admins_only.py index d9c1214b73..9abbc041de 100644 --- a/zerver/migrations/0047_realm_add_emoji_by_admins_only.py +++ b/zerver/migrations/0047_realm_add_emoji_by_admins_only.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2016-12-20 13:45 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0048_enter_sends_default_to_false.py b/zerver/migrations/0048_enter_sends_default_to_false.py index f9496e41a4..3a35960cf9 100644 --- a/zerver/migrations/0048_enter_sends_default_to_false.py +++ b/zerver/migrations/0048_enter_sends_default_to_false.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.4 on 2016-12-29 02:18 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py b/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py index 4887627c00..81cf745ba9 100644 --- a/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py +++ b/zerver/migrations/0049_userprofile_pm_content_in_desktop_notifications.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0050_userprofile_avatar_version.py b/zerver/migrations/0050_userprofile_avatar_version.py index 83f2fc752f..7b3ed3896e 100644 --- a/zerver/migrations/0050_userprofile_avatar_version.py +++ b/zerver/migrations/0050_userprofile_avatar_version.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-01-23 17:44 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0051_realmalias_add_allow_subdomains.py b/zerver/migrations/0051_realmalias_add_allow_subdomains.py index 1eb7bf8886..14e8f89665 100644 --- a/zerver/migrations/0051_realmalias_add_allow_subdomains.py +++ b/zerver/migrations/0051_realmalias_add_allow_subdomains.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-01-25 20:55 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py b/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py index a7f4d484bc..3603ff9ea4 100644 --- a/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py +++ b/zerver/migrations/0052_auto_fix_realmalias_realm_nullable.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-11 03:07 - import django.db.models.deletion from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0053_emailchangestatus.py b/zerver/migrations/0053_emailchangestatus.py index 4db3a4ff9c..84ad324323 100644 --- a/zerver/migrations/0053_emailchangestatus.py +++ b/zerver/migrations/0053_emailchangestatus.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-23 05:37 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0054_realm_icon.py b/zerver/migrations/0054_realm_icon.py index a68893f7e2..d648772cd8 100644 --- a/zerver/migrations/0054_realm_icon.py +++ b/zerver/migrations/0054_realm_icon.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-15 06:18 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0055_attachment_size.py b/zerver/migrations/0055_attachment_size.py index 90e9334ea4..d1e703b298 100644 --- a/zerver/migrations/0055_attachment_size.py +++ b/zerver/migrations/0055_attachment_size.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-01 06:28 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0056_userprofile_emoji_alt_code.py b/zerver/migrations/0056_userprofile_emoji_alt_code.py index e6370dd4da..b1b632c34a 100644 --- a/zerver/migrations/0056_userprofile_emoji_alt_code.py +++ b/zerver/migrations/0056_userprofile_emoji_alt_code.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-02 07:28 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0057_realmauditlog.py b/zerver/migrations/0057_realmauditlog.py index 9843bf1141..07fd2755fb 100644 --- a/zerver/migrations/0057_realmauditlog.py +++ b/zerver/migrations/0057_realmauditlog.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-04 07:33 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models @@ -8,6 +7,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.utils.timezone import now as timezone_now + def backfill_user_activations_and_deactivations(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: migration_time = timezone_now() RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') diff --git a/zerver/migrations/0058_realm_email_changes_disabled.py b/zerver/migrations/0058_realm_email_changes_disabled.py index 4bab541b3a..d5ded2b5f8 100644 --- a/zerver/migrations/0058_realm_email_changes_disabled.py +++ b/zerver/migrations/0058_realm_email_changes_disabled.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-27 14:34 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0059_userprofile_quota.py b/zerver/migrations/0059_userprofile_quota.py index ab0953575e..c5f7ecad29 100644 --- a/zerver/migrations/0059_userprofile_quota.py +++ b/zerver/migrations/0059_userprofile_quota.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-04 07:40 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0060_move_avatars_to_be_uid_based.py b/zerver/migrations/0060_move_avatars_to_be_uid_based.py index db265984d5..1fcfcd97ec 100644 --- a/zerver/migrations/0060_move_avatars_to_be_uid_based.py +++ b/zerver/migrations/0060_move_avatars_to_be_uid_based.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-27 17:03 - import os from typing import Text @@ -12,6 +11,7 @@ from django.db.migrations.state import StateApps from zerver.lib.avatar_hash import user_avatar_hash, user_avatar_path + def mkdirs(path: Text) -> None: dirname = os.path.dirname(path) if not os.path.isdir(dirname): diff --git a/zerver/migrations/0061_userprofile_timezone.py b/zerver/migrations/0061_userprofile_timezone.py index 829b9a67bc..d91685a863 100644 --- a/zerver/migrations/0061_userprofile_timezone.py +++ b/zerver/migrations/0061_userprofile_timezone.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-15 11:43 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0062_default_timezone.py b/zerver/migrations/0062_default_timezone.py index 8a1945ef33..66cf989678 100644 --- a/zerver/migrations/0062_default_timezone.py +++ b/zerver/migrations/0062_default_timezone.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-16 12:22 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0063_realm_description.py b/zerver/migrations/0063_realm_description.py index 30b6836b5d..7ddeec1e59 100644 --- a/zerver/migrations/0063_realm_description.py +++ b/zerver/migrations/0063_realm_description.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-19 19:06 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0064_sync_uploads_filesize_with_db.py b/zerver/migrations/0064_sync_uploads_filesize_with_db.py index 927a49fa02..663e4da861 100644 --- a/zerver/migrations/0064_sync_uploads_filesize_with_db.py +++ b/zerver/migrations/0064_sync_uploads_filesize_with_db.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-18 12:38 - import os +from typing import Optional from boto.s3.connection import S3Connection from boto.s3.key import Key @@ -10,7 +10,6 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -from typing import Optional class MissingUploadFileException(Exception): pass diff --git a/zerver/migrations/0065_realm_inline_image_preview.py b/zerver/migrations/0065_realm_inline_image_preview.py index 5af9b15520..7c018d1d3a 100644 --- a/zerver/migrations/0065_realm_inline_image_preview.py +++ b/zerver/migrations/0065_realm_inline_image_preview.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-21 15:56 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0066_realm_inline_url_embed_preview.py b/zerver/migrations/0066_realm_inline_url_embed_preview.py index 7aa3e4e48b..c8bb4ea6a4 100644 --- a/zerver/migrations/0066_realm_inline_url_embed_preview.py +++ b/zerver/migrations/0066_realm_inline_url_embed_preview.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-21 15:58 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0067_archived_models.py b/zerver/migrations/0067_archived_models.py index 083dc2141e..57bb4dafd9 100644 --- a/zerver/migrations/0067_archived_models.py +++ b/zerver/migrations/0067_archived_models.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-26 01:10 - import bitfield.models import django.db.models.deletion import django.utils.timezone from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0068_remove_realm_domain.py b/zerver/migrations/0068_remove_realm_domain.py index ba9f689b54..ee5ef6d0ad 100644 --- a/zerver/migrations/0068_remove_realm_domain.py +++ b/zerver/migrations/0068_remove_realm_domain.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-13 23:32 - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0069_realmauditlog_extra_data.py b/zerver/migrations/0069_realmauditlog_extra_data.py index 924ba7af25..a8b32e0db6 100644 --- a/zerver/migrations/0069_realmauditlog_extra_data.py +++ b/zerver/migrations/0069_realmauditlog_extra_data.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-27 20:00 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0070_userhotspot.py b/zerver/migrations/0070_userhotspot.py index f157deafa1..1986ea9574 100644 --- a/zerver/migrations/0070_userhotspot.py +++ b/zerver/migrations/0070_userhotspot.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-28 00:22 - import django.db.models.deletion import django.utils.timezone from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0071_rename_realmalias_to_realmdomain.py b/zerver/migrations/0071_rename_realmalias_to_realmdomain.py index b7bd72ee33..560233ebb6 100644 --- a/zerver/migrations/0071_rename_realmalias_to_realmdomain.py +++ b/zerver/migrations/0071_rename_realmalias_to_realmdomain.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-31 14:21 - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0072_realmauditlog_add_index_event_time.py b/zerver/migrations/0072_realmauditlog_add_index_event_time.py index 9e4b9e3d1a..f5b7a20664 100644 --- a/zerver/migrations/0072_realmauditlog_add_index_event_time.py +++ b/zerver/migrations/0072_realmauditlog_add_index_event_time.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-31 05:51 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0073_custom_profile_fields.py b/zerver/migrations/0073_custom_profile_fields.py index b5a88c4d29..e7a923ee36 100644 --- a/zerver/migrations/0073_custom_profile_fields.py +++ b/zerver/migrations/0073_custom_profile_fields.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-17 06:49 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0074_fix_duplicate_attachments.py b/zerver/migrations/0074_fix_duplicate_attachments.py index 91edc0847c..d1ed9c50f1 100644 --- a/zerver/migrations/0074_fix_duplicate_attachments.py +++ b/zerver/migrations/0074_fix_duplicate_attachments.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-13 22:12 - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db.models import Count + def fix_duplicate_attachments(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object diff --git a/zerver/migrations/0075_attachment_path_id_unique.py b/zerver/migrations/0075_attachment_path_id_unique.py index 58def985b0..445447f82f 100644 --- a/zerver/migrations/0075_attachment_path_id_unique.py +++ b/zerver/migrations/0075_attachment_path_id_unique.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-13 22:29 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0076_userprofile_emojiset.py b/zerver/migrations/0076_userprofile_emojiset.py index f5b28f9455..27db75e580 100644 --- a/zerver/migrations/0076_userprofile_emojiset.py +++ b/zerver/migrations/0076_userprofile_emojiset.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-23 19:51 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py b/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py index 25be955ba4..3b774b65d4 100644 --- a/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py +++ b/zerver/migrations/0077_add_file_name_field_to_realm_emoji.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-09 05:23 - import io import logging import os @@ -18,6 +17,7 @@ from django.db.migrations.state import StateApps from PIL import Image, ImageOps from requests import ConnectionError, Response + def force_str(s: Union[str, bytes], encoding: str = 'utf-8') -> str: """converts a bytes type to a string""" if isinstance(s, str): diff --git a/zerver/migrations/0078_service.py b/zerver/migrations/0078_service.py index edc10f5a66..dcdf42a8dd 100644 --- a/zerver/migrations/0078_service.py +++ b/zerver/migrations/0078_service.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-04-27 16:55 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0079_remove_old_scheduled_jobs.py b/zerver/migrations/0079_remove_old_scheduled_jobs.py index 26947b2dfc..d0ce68f515 100644 --- a/zerver/migrations/0079_remove_old_scheduled_jobs.py +++ b/zerver/migrations/0079_remove_old_scheduled_jobs.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-10 05:59 - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Delete any old scheduled jobs, to handle changes in the format of that table. Ideally, we'd translate the jobs, but it's not really diff --git a/zerver/migrations/0080_realm_description_length.py b/zerver/migrations/0080_realm_description_length.py index e18de20d22..46b4eb056b 100644 --- a/zerver/migrations/0080_realm_description_length.py +++ b/zerver/migrations/0080_realm_description_length.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-11 20:27 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0081_make_emoji_lowercase.py b/zerver/migrations/0081_make_emoji_lowercase.py index a80adc93ff..2c6fb4c37f 100644 --- a/zerver/migrations/0081_make_emoji_lowercase.py +++ b/zerver/migrations/0081_make_emoji_lowercase.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-02 21:44 - import django.core.validators from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0082_index_starred_user_messages.py b/zerver/migrations/0082_index_starred_user_messages.py index 2de67892bd..1ce3ce3ba9 100644 --- a/zerver/migrations/0082_index_starred_user_messages.py +++ b/zerver/migrations/0082_index_starred_user_messages.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0083_index_mentioned_user_messages.py b/zerver/migrations/0083_index_mentioned_user_messages.py index 89bace1193..ace5287312 100644 --- a/zerver/migrations/0083_index_mentioned_user_messages.py +++ b/zerver/migrations/0083_index_mentioned_user_messages.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0084_realmemoji_deactivated.py b/zerver/migrations/0084_realmemoji_deactivated.py index c46e3b4a76..c811d7e762 100644 --- a/zerver/migrations/0084_realmemoji_deactivated.py +++ b/zerver/migrations/0084_realmemoji_deactivated.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-22 14:49 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0085_fix_bots_with_none_bot_type.py b/zerver/migrations/0085_fix_bots_with_none_bot_type.py index af230f79e3..193887b886 100644 --- a/zerver/migrations/0085_fix_bots_with_none_bot_type.py +++ b/zerver/migrations/0085_fix_bots_with_none_bot_type.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-20 10:31 - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def fix_bot_type(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model("zerver", "UserProfile") bots = UserProfile.objects.filter(is_bot=True, bot_type=None) diff --git a/zerver/migrations/0086_realm_alter_default_org_type.py b/zerver/migrations/0086_realm_alter_default_org_type.py index 825d79bbfe..578c4d4a41 100644 --- a/zerver/migrations/0086_realm_alter_default_org_type.py +++ b/zerver/migrations/0086_realm_alter_default_org_type.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-26 21:56 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0087_remove_old_scheduled_jobs.py b/zerver/migrations/0087_remove_old_scheduled_jobs.py index 71c95003b8..147c28189d 100644 --- a/zerver/migrations/0087_remove_old_scheduled_jobs.py +++ b/zerver/migrations/0087_remove_old_scheduled_jobs.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-05-10 05:59 - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Delete any old scheduled jobs, to handle changes in the format of send_email. Ideally, we'd translate the jobs, but it's not really diff --git a/zerver/migrations/0088_remove_referral_and_invites.py b/zerver/migrations/0088_remove_referral_and_invites.py index dba8afebf6..206dd81fc9 100644 --- a/zerver/migrations/0088_remove_referral_and_invites.py +++ b/zerver/migrations/0088_remove_referral_and_invites.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-07 08:34 - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0089_auto_20170710_1353.py b/zerver/migrations/0089_auto_20170710_1353.py index aa05e8687e..1f948358c9 100644 --- a/zerver/migrations/0089_auto_20170710_1353.py +++ b/zerver/migrations/0089_auto_20170710_1353.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-10 13:53 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0090_userprofile_high_contrast_mode.py b/zerver/migrations/0090_userprofile_high_contrast_mode.py index 04deeca4e6..33a0b1e244 100644 --- a/zerver/migrations/0090_userprofile_high_contrast_mode.py +++ b/zerver/migrations/0090_userprofile_high_contrast_mode.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-07 15:58 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0091_realm_allow_edit_history.py b/zerver/migrations/0091_realm_allow_edit_history.py index 18bd2180e6..dd6607cf47 100644 --- a/zerver/migrations/0091_realm_allow_edit_history.py +++ b/zerver/migrations/0091_realm_allow_edit_history.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-16 08:57 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0092_create_scheduledemail.py b/zerver/migrations/0092_create_scheduledemail.py index 31748c2151..8f2875257d 100644 --- a/zerver/migrations/0092_create_scheduledemail.py +++ b/zerver/migrations/0092_create_scheduledemail.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-11 23:41 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0093_subscription_event_log_backfill.py b/zerver/migrations/0093_subscription_event_log_backfill.py index 7bb27b98fd..bde817cdd3 100644 --- a/zerver/migrations/0093_subscription_event_log_backfill.py +++ b/zerver/migrations/0093_subscription_event_log_backfill.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- - from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db.models import Max from django.utils.timezone import now as timezone_now + def backfill_subscription_log_events(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: migration_time = timezone_now() RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') diff --git a/zerver/migrations/0094_realm_filter_url_validator.py b/zerver/migrations/0094_realm_filter_url_validator.py index 151882a0b1..60a1608fc7 100644 --- a/zerver/migrations/0094_realm_filter_url_validator.py +++ b/zerver/migrations/0094_realm_filter_url_validator.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-22 13:44 - import django.core.validators from django.db import migrations, models import zerver.models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0095_index_unread_user_messages.py b/zerver/migrations/0095_index_unread_user_messages.py index d49edd6ed6..344c42b5a6 100644 --- a/zerver/migrations/0095_index_unread_user_messages.py +++ b/zerver/migrations/0095_index_unread_user_messages.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0096_add_password_required.py b/zerver/migrations/0096_add_password_required.py index 50737b9ebf..e4b808153f 100644 --- a/zerver/migrations/0096_add_password_required.py +++ b/zerver/migrations/0096_add_password_required.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-08-09 04:21 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0097_reactions_emoji_code.py b/zerver/migrations/0097_reactions_emoji_code.py index aa319d6efd..7314fe009f 100644 --- a/zerver/migrations/0097_reactions_emoji_code.py +++ b/zerver/migrations/0097_reactions_emoji_code.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-06-18 21:26 - import os import ujson @@ -8,6 +7,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def populate_new_fields(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: # Open the JSON file which contains the data to be used for migration. MIGRATION_DATA_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "management", "data") diff --git a/zerver/migrations/0098_index_has_alert_word_user_messages.py b/zerver/migrations/0098_index_has_alert_word_user_messages.py index cd3cc63170..0b83e2b99c 100644 --- a/zerver/migrations/0098_index_has_alert_word_user_messages.py +++ b/zerver/migrations/0098_index_has_alert_word_user_messages.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py b/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py index 095b1cfe61..050f4b56a2 100644 --- a/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py +++ b/zerver/migrations/0099_index_wildcard_mentioned_user_messages.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0100_usermessage_remove_is_me_message.py b/zerver/migrations/0100_usermessage_remove_is_me_message.py index 751afbef95..699cf7ca85 100644 --- a/zerver/migrations/0100_usermessage_remove_is_me_message.py +++ b/zerver/migrations/0100_usermessage_remove_is_me_message.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-27 17:08 - import bitfield.models from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0101_muted_topic.py b/zerver/migrations/0101_muted_topic.py index 28cbf94169..e57f24433a 100644 --- a/zerver/migrations/0101_muted_topic.py +++ b/zerver/migrations/0101_muted_topic.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-30 00:26 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0102_convert_muted_topic.py b/zerver/migrations/0102_convert_muted_topic.py index b8c54fddac..8090ed3283 100644 --- a/zerver/migrations/0102_convert_muted_topic.py +++ b/zerver/migrations/0102_convert_muted_topic.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-30 00:26 - import ujson from django.db import connection, migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def convert_muted_topics(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: stream_query = ''' SELECT diff --git a/zerver/migrations/0103_remove_userprofile_muted_topics.py b/zerver/migrations/0103_remove_userprofile_muted_topics.py index 3bae44ee04..a6efb6a170 100644 --- a/zerver/migrations/0103_remove_userprofile_muted_topics.py +++ b/zerver/migrations/0103_remove_userprofile_muted_topics.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-31 00:13 - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0104_fix_unreads.py b/zerver/migrations/0104_fix_unreads.py index de6581cb6e..ab95505ad4 100644 --- a/zerver/migrations/0104_fix_unreads.py +++ b/zerver/migrations/0104_fix_unreads.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-30 00:26 - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from zerver.lib.fix_unreads import fix + def fix_unreads(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model("zerver", "UserProfile") user_profiles = list(UserProfile.objects.filter(is_bot=False)) diff --git a/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py b/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py index 892572e0f3..8e91185b24 100644 --- a/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py +++ b/zerver/migrations/0105_userprofile_enable_stream_push_notifications.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-09-08 17:52 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0106_subscription_push_notifications.py b/zerver/migrations/0106_subscription_push_notifications.py index d532131de4..4979b93de6 100644 --- a/zerver/migrations/0106_subscription_push_notifications.py +++ b/zerver/migrations/0106_subscription_push_notifications.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-09-08 17:52 - from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0107_multiuseinvite.py b/zerver/migrations/0107_multiuseinvite.py index 3818e088b6..35b8b05f30 100644 --- a/zerver/migrations/0107_multiuseinvite.py +++ b/zerver/migrations/0107_multiuseinvite.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-09-04 22:48 - import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0108_fix_default_string_id.py b/zerver/migrations/0108_fix_default_string_id.py index e8e488cadc..21a0968998 100644 --- a/zerver/migrations/0108_fix_default_string_id.py +++ b/zerver/migrations/0108_fix_default_string_id.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-08-24 02:39 - from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def fix_realm_string_ids(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') if Realm.objects.filter(deactivated=False).count() != 2: diff --git a/zerver/migrations/0109_mark_tutorial_status_finished.py b/zerver/migrations/0109_mark_tutorial_status_finished.py index 61e5a5ba4c..a6f63775e9 100644 --- a/zerver/migrations/0109_mark_tutorial_status_finished.py +++ b/zerver/migrations/0109_mark_tutorial_status_finished.py @@ -3,6 +3,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def set_tutorial_status_to_finished(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model('zerver', 'UserProfile') UserProfile.objects.update(tutorial_status='F') diff --git a/zerver/migrations/0110_stream_is_in_zephyr_realm.py b/zerver/migrations/0110_stream_is_in_zephyr_realm.py index 5c8f4d468e..3518c46814 100644 --- a/zerver/migrations/0110_stream_is_in_zephyr_realm.py +++ b/zerver/migrations/0110_stream_is_in_zephyr_realm.py @@ -4,6 +4,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def populate_is_zephyr(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model("zerver", "Realm") Stream = apps.get_model("zerver", "Stream") diff --git a/zerver/migrations/0111_botuserstatedata.py b/zerver/migrations/0111_botuserstatedata.py index 930333b302..de9e171276 100644 --- a/zerver/migrations/0111_botuserstatedata.py +++ b/zerver/migrations/0111_botuserstatedata.py @@ -6,6 +6,7 @@ import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0112_index_muted_topics.py b/zerver/migrations/0112_index_muted_topics.py index f48610087b..945e492ecd 100644 --- a/zerver/migrations/0112_index_muted_topics.py +++ b/zerver/migrations/0112_index_muted_topics.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- - from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0113_default_stream_group.py b/zerver/migrations/0113_default_stream_group.py index c196639a6d..b5c327952b 100644 --- a/zerver/migrations/0113_default_stream_group.py +++ b/zerver/migrations/0113_default_stream_group.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import django.db.models.deletion from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0114_preregistrationuser_invited_as_admin.py b/zerver/migrations/0114_preregistrationuser_invited_as_admin.py index 75dd2e73e0..9563daf0ee 100644 --- a/zerver/migrations/0114_preregistrationuser_invited_as_admin.py +++ b/zerver/migrations/0114_preregistrationuser_invited_as_admin.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0115_user_groups.py b/zerver/migrations/0115_user_groups.py index 79859b5829..d513febe4f 100644 --- a/zerver/migrations/0115_user_groups.py +++ b/zerver/migrations/0115_user_groups.py @@ -6,6 +6,7 @@ import django.db.models.deletion from django.conf import settings from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0116_realm_allow_message_deleting.py b/zerver/migrations/0116_realm_allow_message_deleting.py index 0b5097ecb6..60209a1641 100644 --- a/zerver/migrations/0116_realm_allow_message_deleting.py +++ b/zerver/migrations/0116_realm_allow_message_deleting.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0117_add_desc_to_user_group.py b/zerver/migrations/0117_add_desc_to_user_group.py index f4481eaa68..24564849fa 100644 --- a/zerver/migrations/0117_add_desc_to_user_group.py +++ b/zerver/migrations/0117_add_desc_to_user_group.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0118_defaultstreamgroup_description.py b/zerver/migrations/0118_defaultstreamgroup_description.py index 76421f806c..0a577b4f37 100644 --- a/zerver/migrations/0118_defaultstreamgroup_description.py +++ b/zerver/migrations/0118_defaultstreamgroup_description.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0120_botuserconfigdata.py b/zerver/migrations/0120_botuserconfigdata.py index 2bee32168e..2e40aad7b8 100644 --- a/zerver/migrations/0120_botuserconfigdata.py +++ b/zerver/migrations/0120_botuserconfigdata.py @@ -2,9 +2,9 @@ # Generated by Django 1.11.6 on 2017-11-01 19:12 from __future__ import unicode_literals +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/zerver/migrations/0121_realm_signup_notifications_stream.py b/zerver/migrations/0121_realm_signup_notifications_stream.py index 0cc7ff4d69..2697fd9979 100644 --- a/zerver/migrations/0121_realm_signup_notifications_stream.py +++ b/zerver/migrations/0121_realm_signup_notifications_stream.py @@ -2,11 +2,12 @@ # Generated by Django 1.11.5 on 2017-10-19 22:01 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def set_initial_value_for_signup_notifications_stream( apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: realm_model = apps.get_model("zerver", "Realm") diff --git a/zerver/migrations/0126_prereg_remove_users_without_realm.py b/zerver/migrations/0126_prereg_remove_users_without_realm.py index de62892eb6..7414cef77a 100644 --- a/zerver/migrations/0126_prereg_remove_users_without_realm.py +++ b/zerver/migrations/0126_prereg_remove_users_without_realm.py @@ -6,6 +6,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def remove_prereg_users_without_realm( apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: prereg_model = apps.get_model("zerver", "PreregistrationUser") diff --git a/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py b/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py index d7e05629de..0f56d753e0 100644 --- a/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py +++ b/zerver/migrations/0127_disallow_chars_in_stream_and_user_name.py @@ -3,6 +3,7 @@ from typing import Any, List from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0128_scheduledemail_realm.py b/zerver/migrations/0128_scheduledemail_realm.py index 1ff8e3fda3..b05e607d26 100644 --- a/zerver/migrations/0128_scheduledemail_realm.py +++ b/zerver/migrations/0128_scheduledemail_realm.py @@ -2,11 +2,12 @@ # Generated by Django 1.11.6 on 2017-12-05 01:08 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def set_realm_for_existing_scheduledemails( apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: scheduledemail_model = apps.get_model("zerver", "ScheduledEmail") diff --git a/zerver/migrations/0130_text_choice_in_emojiset.py b/zerver/migrations/0130_text_choice_in_emojiset.py index 1171ad98ba..f53033bd17 100644 --- a/zerver/migrations/0130_text_choice_in_emojiset.py +++ b/zerver/migrations/0130_text_choice_in_emojiset.py @@ -2,6 +2,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + # change emojiset to text if emoji_alt_code is true. def change_emojiset(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model("zerver", "UserProfile") diff --git a/zerver/migrations/0134_scheduledmessage.py b/zerver/migrations/0134_scheduledmessage.py index b47cba0beb..d0fa608c03 100644 --- a/zerver/migrations/0134_scheduledmessage.py +++ b/zerver/migrations/0134_scheduledmessage.py @@ -2,9 +2,9 @@ # Generated by Django 1.11.6 on 2018-01-10 01:11 from __future__ import unicode_literals +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py b/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py index 3af9990daf..769a7e680e 100644 --- a/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py +++ b/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py @@ -5,6 +5,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def backfill_last_message_id(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: event_type = ['subscription_created', 'subscription_deactivated', 'subscription_activated'] RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') diff --git a/zerver/migrations/0143_realm_bot_creation_policy.py b/zerver/migrations/0143_realm_bot_creation_policy.py index 0ba1744dd4..1b843c6efa 100644 --- a/zerver/migrations/0143_realm_bot_creation_policy.py +++ b/zerver/migrations/0143_realm_bot_creation_policy.py @@ -6,6 +6,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def set_initial_value_for_bot_creation_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model("zerver", "Realm") for realm in Realm.objects.all(): diff --git a/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py b/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py index bd3efc75c4..689c71c934 100644 --- a/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py +++ b/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- - from collections import defaultdict +from typing import Any, Dict + from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -from typing import Any, Dict + def realm_emoji_name_to_id(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Reaction = apps.get_model('zerver', 'Reaction') diff --git a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py index 0d0016dd99..90b6e432eb 100644 --- a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py +++ b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py @@ -8,6 +8,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + class Uploader: def __init__(self) -> None: self.old_orig_image_path_template = "{realm_id}/emoji/{emoji_file_name}.original" diff --git a/zerver/migrations/0154_fix_invalid_bot_owner.py b/zerver/migrations/0154_fix_invalid_bot_owner.py index a40132a65c..831dd1298d 100644 --- a/zerver/migrations/0154_fix_invalid_bot_owner.py +++ b/zerver/migrations/0154_fix_invalid_bot_owner.py @@ -6,6 +6,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def migrate_fix_invalid_bot_owner_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Fixes UserProfile objects that incorrectly had a bot_owner set""" UserProfile = apps.get_model('zerver', 'UserProfile') diff --git a/zerver/migrations/0167_custom_profile_fields_sort_order.py b/zerver/migrations/0167_custom_profile_fields_sort_order.py index 52864deddc..bf9b71067a 100644 --- a/zerver/migrations/0167_custom_profile_fields_sort_order.py +++ b/zerver/migrations/0167_custom_profile_fields_sort_order.py @@ -3,9 +3,10 @@ from __future__ import unicode_literals from django.db import migrations, models -from django.db.models import F from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps +from django.db.models import F + def migrate_set_order_value(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: CustomProfileField = apps.get_model('zerver', 'CustomProfileField') diff --git a/zerver/migrations/0170_submessage.py b/zerver/migrations/0170_submessage.py index 10c0817e5e..751932249a 100644 --- a/zerver/migrations/0170_submessage.py +++ b/zerver/migrations/0170_submessage.py @@ -2,9 +2,9 @@ # Generated by Django 1.11.6 on 2018-01-26 21:54 from __future__ import unicode_literals +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/zerver/migrations/0174_userprofile_delivery_email.py b/zerver/migrations/0174_userprofile_delivery_email.py index b3d4ec8ea0..f1031e3ba7 100644 --- a/zerver/migrations/0174_userprofile_delivery_email.py +++ b/zerver/migrations/0174_userprofile_delivery_email.py @@ -3,10 +3,10 @@ from __future__ import unicode_literals from django.db import migrations, models -from django.db.models import F - from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps +from django.db.models import F + def copy_email_field(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model('zerver', 'UserProfile') diff --git a/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py b/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py index fe350b0048..2f68b6c915 100644 --- a/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py +++ b/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py @@ -2,10 +2,10 @@ from __future__ import unicode_literals from django.db import migrations - from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def change_realm_audit_log_event_type_tense(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: RealmAuditLog = apps.get_model('zerver', 'RealmAuditLog') RealmAuditLog.objects.filter(event_type="user_change_password").update(event_type="user_password_changed") diff --git a/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py b/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py index 38cccdaafb..296752c41a 100644 --- a/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py +++ b/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py @@ -3,12 +3,14 @@ from __future__ import unicode_literals import sys + import bitfield.models from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db.models import F + def reset_is_private_flag( apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserMessage = apps.get_model("zerver", "UserMessage") diff --git a/zerver/migrations/0181_userprofile_change_emojiset.py b/zerver/migrations/0181_userprofile_change_emojiset.py index 7e3052752a..12e627eb4b 100644 --- a/zerver/migrations/0181_userprofile_change_emojiset.py +++ b/zerver/migrations/0181_userprofile_change_emojiset.py @@ -3,6 +3,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def change_emojiset_choice(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model('zerver', 'UserProfile') UserProfile.objects.exclude(emojiset__in=['google', 'text']).update(emojiset='google') diff --git a/zerver/migrations/0182_set_initial_value_is_private_flag.py b/zerver/migrations/0182_set_initial_value_is_private_flag.py index 91d125ce6d..1ec308e8dc 100644 --- a/zerver/migrations/0182_set_initial_value_is_private_flag.py +++ b/zerver/migrations/0182_set_initial_value_is_private_flag.py @@ -6,6 +6,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db.models import F + def set_initial_value_of_is_private_flag( apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserMessage = apps.get_model("zerver", "UserMessage") diff --git a/zerver/migrations/0189_userprofile_add_some_emojisets.py b/zerver/migrations/0189_userprofile_add_some_emojisets.py index 59f88a8a4a..e1c51dc159 100644 --- a/zerver/migrations/0189_userprofile_add_some_emojisets.py +++ b/zerver/migrations/0189_userprofile_add_some_emojisets.py @@ -6,6 +6,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def change_emojiset_choice(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model('zerver', 'UserProfile') UserProfile.objects.filter(emojiset='google').update(emojiset='google-blob') diff --git a/zerver/migrations/0198_preregistrationuser_invited_as.py b/zerver/migrations/0198_preregistrationuser_invited_as.py index 9220c43919..c2d2284053 100644 --- a/zerver/migrations/0198_preregistrationuser_invited_as.py +++ b/zerver/migrations/0198_preregistrationuser_invited_as.py @@ -6,6 +6,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def set_initial_value_for_invited_as(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: PreregistrationUser = apps.get_model("zerver", "PreregistrationUser") for user in PreregistrationUser.objects.all(): diff --git a/zerver/migrations/0199_userstatus.py b/zerver/migrations/0199_userstatus.py index 6a8072037f..d436fdee26 100644 --- a/zerver/migrations/0199_userstatus.py +++ b/zerver/migrations/0199_userstatus.py @@ -2,9 +2,9 @@ # Generated by Django 1.11.16 on 2018-12-17 18:49 from __future__ import unicode_literals +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/zerver/migrations/0206_stream_rendered_description.py b/zerver/migrations/0206_stream_rendered_description.py index d363bc1997..a6f901ae63 100644 --- a/zerver/migrations/0206_stream_rendered_description.py +++ b/zerver/migrations/0206_stream_rendered_description.py @@ -2,12 +2,12 @@ from __future__ import unicode_literals from django.db import migrations, models - -from django.db.migrations.state import StateApps from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor +from django.db.migrations.state import StateApps from zerver.lib.actions import render_stream_description + def render_all_stream_descriptions(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Stream = apps.get_model('zerver', 'Stream') all_streams = Stream.objects.exclude(description='') diff --git a/zerver/migrations/0209_user_profile_no_empty_password.py b/zerver/migrations/0209_user_profile_no_empty_password.py index 561b4a8641..2efda7f9cd 100644 --- a/zerver/migrations/0209_user_profile_no_empty_password.py +++ b/zerver/migrations/0209_user_profile_no_empty_password.py @@ -2,20 +2,20 @@ # Generated by Django 1.11.24 on 2019-10-16 22:48 from __future__ import unicode_literals +from typing import Any, Set, Union + +import ujson from django.conf import settings +from django.contrib.auth.hashers import check_password, make_password from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -from django.contrib.auth.hashers import check_password, make_password from django.utils.timezone import now as timezone_now from zerver.lib.cache import cache_delete, user_profile_by_api_key_cache_key from zerver.lib.queue import queue_json_publish from zerver.lib.utils import generate_api_key -from typing import Any, Set, Union - -import ujson def ensure_no_empty_passwords(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """With CVE-2019-18933, it was possible for certain users created diff --git a/zerver/migrations/0210_stream_first_message_id.py b/zerver/migrations/0210_stream_first_message_id.py index eb6045af0e..64bc958ab5 100644 --- a/zerver/migrations/0210_stream_first_message_id.py +++ b/zerver/migrations/0210_stream_first_message_id.py @@ -6,6 +6,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def backfill_first_message_id(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Stream = apps.get_model('zerver', 'Stream') Message = apps.get_model('zerver', 'Message') diff --git a/zerver/migrations/0211_add_users_field_to_scheduled_email.py b/zerver/migrations/0211_add_users_field_to_scheduled_email.py index 6750bee9ca..90b33dfa78 100644 --- a/zerver/migrations/0211_add_users_field_to_scheduled_email.py +++ b/zerver/migrations/0211_add_users_field_to_scheduled_email.py @@ -7,6 +7,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def set_users_for_existing_scheduledemails( apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: ScheduledEmail = apps.get_model("zerver", "ScheduledEmail") diff --git a/zerver/migrations/0212_make_stream_email_token_unique.py b/zerver/migrations/0212_make_stream_email_token_unique.py index 019a156457..67561fae74 100644 --- a/zerver/migrations/0212_make_stream_email_token_unique.py +++ b/zerver/migrations/0212_make_stream_email_token_unique.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from django.db import migrations, models + import zerver.models diff --git a/zerver/migrations/0214_realm_invite_to_stream_policy.py b/zerver/migrations/0214_realm_invite_to_stream_policy.py index 4dddddefa0..84df3d78ab 100644 --- a/zerver/migrations/0214_realm_invite_to_stream_policy.py +++ b/zerver/migrations/0214_realm_invite_to_stream_policy.py @@ -3,10 +3,10 @@ from __future__ import unicode_literals from django.db import migrations, models - from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def handle_waiting_period(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') Realm.objects.filter(waiting_period_threshold__gt=0).update( diff --git a/zerver/migrations/0216_add_create_stream_policy.py b/zerver/migrations/0216_add_create_stream_policy.py index 527b975b0d..59fc604dfc 100644 --- a/zerver/migrations/0216_add_create_stream_policy.py +++ b/zerver/migrations/0216_add_create_stream_policy.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0217_migrate_create_stream_policy.py b/zerver/migrations/0217_migrate_create_stream_policy.py index 650d4d4a76..bf738e74a4 100644 --- a/zerver/migrations/0217_migrate_create_stream_policy.py +++ b/zerver/migrations/0217_migrate_create_stream_policy.py @@ -3,10 +3,10 @@ from __future__ import unicode_literals from django.db import migrations - from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def upgrade_create_stream_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model('zerver', 'Realm') Realm.objects.filter(waiting_period_threshold__exact=0) \ diff --git a/zerver/migrations/0218_remove_create_stream_by_admins_only.py b/zerver/migrations/0218_remove_create_stream_by_admins_only.py index 26f2b52642..4a840203e4 100644 --- a/zerver/migrations/0218_remove_create_stream_by_admins_only.py +++ b/zerver/migrations/0218_remove_create_stream_by_admins_only.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py b/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py index 13817df7a5..90590c36f1 100644 --- a/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py +++ b/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py @@ -6,6 +6,7 @@ from django.db import migrations, models from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def disable_realm_digest_emails_enabled(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Realm = apps.get_model("zerver", "Realm") realms = Realm.objects.filter(digest_emails_enabled=True) diff --git a/zerver/migrations/0220_subscription_notification_settings.py b/zerver/migrations/0220_subscription_notification_settings.py index 1139d1ca48..8ff91849ee 100644 --- a/zerver/migrations/0220_subscription_notification_settings.py +++ b/zerver/migrations/0220_subscription_notification_settings.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0223_rename_to_is_muted.py b/zerver/migrations/0223_rename_to_is_muted.py index 23dcbd554c..a03e598dab 100644 --- a/zerver/migrations/0223_rename_to_is_muted.py +++ b/zerver/migrations/0223_rename_to_is_muted.py @@ -7,6 +7,7 @@ from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps from django.db.models import Case, Value, When + def set_initial_value_for_is_muted(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Subscription = apps.get_model("zerver", "Subscription") Subscription.objects.update(is_muted=Case( diff --git a/zerver/migrations/0224_alter_field_realm_video_chat_provider.py b/zerver/migrations/0224_alter_field_realm_video_chat_provider.py index 248e56852b..ca8e3fca2c 100644 --- a/zerver/migrations/0224_alter_field_realm_video_chat_provider.py +++ b/zerver/migrations/0224_alter_field_realm_video_chat_provider.py @@ -2,8 +2,9 @@ # Generated by Django 1.11.20 on 2019-05-09 06:54 from __future__ import unicode_literals +from typing import Any, Dict, Optional + from django.db import migrations, models -from typing import Dict, Any, Optional from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps diff --git a/zerver/migrations/0225_archived_reaction_model.py b/zerver/migrations/0225_archived_reaction_model.py index 0595960c21..7befd380b5 100644 --- a/zerver/migrations/0225_archived_reaction_model.py +++ b/zerver/migrations/0225_archived_reaction_model.py @@ -2,10 +2,10 @@ # Generated by Django 1.11.20 on 2019-05-29 13:28 from __future__ import unicode_literals -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zerver/migrations/0226_archived_submessage_model.py b/zerver/migrations/0226_archived_submessage_model.py index 0f0cef6d56..c6d320e1f2 100644 --- a/zerver/migrations/0226_archived_submessage_model.py +++ b/zerver/migrations/0226_archived_submessage_model.py @@ -2,10 +2,10 @@ # Generated by Django 1.11.20 on 2019-05-29 13:57 from __future__ import unicode_literals -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zerver/migrations/0231_add_archive_transaction_model.py b/zerver/migrations/0231_add_archive_transaction_model.py index e08ada7fa8..03e093677b 100644 --- a/zerver/migrations/0231_add_archive_transaction_model.py +++ b/zerver/migrations/0231_add_archive_transaction_model.py @@ -2,9 +2,9 @@ # Generated by Django 1.11.20 on 2019-06-23 21:20 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py b/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py index 2891637705..36c4ab005c 100644 --- a/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py +++ b/zerver/migrations/0232_make_archive_transaction_field_not_nullable.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models + class Migration(migrations.Migration): """ diff --git a/zerver/migrations/0236_remove_illegal_characters_email_full.py b/zerver/migrations/0236_remove_illegal_characters_email_full.py index 0c3063936e..5d04572756 100644 --- a/zerver/migrations/0236_remove_illegal_characters_email_full.py +++ b/zerver/migrations/0236_remove_illegal_characters_email_full.py @@ -2,10 +2,11 @@ # Generated by Django 1.11.20 on 2019-06-28 21:45 from __future__ import unicode_literals +from unicodedata import category + from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -from unicodedata import category NAME_INVALID_CHARS = ['*', '`', "\\", '>', '"', '@'] diff --git a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py index 02910c1121..2734253173 100644 --- a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py +++ b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py @@ -4,6 +4,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def rename_zulip_realm_to_zulipinternal(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: if not settings.PRODUCTION: return diff --git a/zerver/migrations/0242_fix_bot_email_property.py b/zerver/migrations/0242_fix_bot_email_property.py index a48227a7a1..c4dba99dd6 100644 --- a/zerver/migrations/0242_fix_bot_email_property.py +++ b/zerver/migrations/0242_fix_bot_email_property.py @@ -6,6 +6,7 @@ from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps + def fix_bot_email_property(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: UserProfile = apps.get_model('zerver', 'UserProfile') for user_profile in UserProfile.objects.filter(is_bot=True): diff --git a/zerver/migrations/0254_merge_0209_0253.py b/zerver/migrations/0254_merge_0209_0253.py index 915aadd95f..eefcc7d54d 100644 --- a/zerver/migrations/0254_merge_0209_0253.py +++ b/zerver/migrations/0254_merge_0209_0253.py @@ -2,9 +2,11 @@ # Generated by Django 1.11.26 on 2019-11-21 01:47 from __future__ import unicode_literals -from django.db import migrations from typing import Any, List +from django.db import migrations + + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0255_userprofile_stream_add_recipient_column.py b/zerver/migrations/0255_userprofile_stream_add_recipient_column.py index a3e5f8cee3..881c5d49e9 100644 --- a/zerver/migrations/0255_userprofile_stream_add_recipient_column.py +++ b/zerver/migrations/0255_userprofile_stream_add_recipient_column.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.26 on 2019-11-27 21:15 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py b/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py index 2d393a6f06..90c6a963d9 100644 --- a/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py +++ b/zerver/migrations/0256_userprofile_stream_set_recipient_column_values.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zerver/migrations/0257_fix_has_link_attribute.py b/zerver/migrations/0257_fix_has_link_attribute.py index a1be13c728..06304b997f 100644 --- a/zerver/migrations/0257_fix_has_link_attribute.py +++ b/zerver/migrations/0257_fix_has_link_attribute.py @@ -2,12 +2,13 @@ # Generated by Django 1.11.24 on 2019-10-07 05:25 from __future__ import unicode_literals +import time + +import lxml from django.db import migrations from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps -import lxml -import time BATCH_SIZE = 1000 def process_batch(apps: StateApps, id_start: int, id_end: int, last_id: int) -> None: diff --git a/zerver/migrations/0259_missedmessageemailaddress.py b/zerver/migrations/0259_missedmessageemailaddress.py index a1fd4a932a..706864c6c8 100644 --- a/zerver/migrations/0259_missedmessageemailaddress.py +++ b/zerver/migrations/0259_missedmessageemailaddress.py @@ -2,10 +2,10 @@ # Generated by Django 1.11.26 on 2020-01-06 01:23 from __future__ import unicode_literals -from django.conf import settings -from django.db import migrations, models import django.db.models.deletion import django.utils.timezone +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py b/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py index dc49fdbc1a..f782cd08e8 100644 --- a/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py +++ b/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py @@ -8,6 +8,7 @@ from django.db.migrations.state import StateApps from zerver.lib.redis_utils import get_redis_client from zerver.lib.utils import generate_random_token + def generate_missed_message_token() -> str: return 'mm' + generate_random_token(32) diff --git a/zilencer/management/commands/add_mock_conversation.py b/zilencer/management/commands/add_mock_conversation.py index f7974a58f6..e63a5813ea 100644 --- a/zilencer/management/commands/add_mock_conversation.py +++ b/zilencer/management/commands/add_mock_conversation.py @@ -1,16 +1,16 @@ # -*- coding: utf-8 -*- - from typing import Any, Dict, List from django.core.management.base import BaseCommand -from zerver.lib.actions import bulk_add_subscriptions, \ - ensure_stream, do_add_reaction, do_change_avatar_fields, \ - do_create_user, do_send_messages, internal_prep_stream_message +from zerver.lib.actions import bulk_add_subscriptions, do_add_reaction, \ + do_change_avatar_fields, do_create_user, do_send_messages, ensure_stream, \ + internal_prep_stream_message from zerver.lib.emoji import emoji_name_to_emoji_code from zerver.lib.upload import upload_avatar_image from zerver.models import Message, UserProfile, get_realm + class Command(BaseCommand): help = """Add a mock conversation to the development environment. diff --git a/zilencer/management/commands/add_new_realm.py b/zilencer/management/commands/add_new_realm.py index 20f2428551..1037f4f5b5 100644 --- a/zilencer/management/commands/add_new_realm.py +++ b/zilencer/management/commands/add_new_realm.py @@ -1,11 +1,12 @@ from typing import Any -from zerver.lib.actions import do_create_realm, do_create_user, \ - bulk_add_subscriptions +from zerver.lib.actions import bulk_add_subscriptions, do_create_realm, \ + do_create_user from zerver.lib.management import ZulipBaseCommand from zerver.lib.onboarding import send_initial_realm_messages from zerver.models import Realm, UserProfile + class Command(ZulipBaseCommand): help = """Add a new realm and initial user for manual testing of the onboarding process.""" diff --git a/zilencer/management/commands/add_new_user.py b/zilencer/management/commands/add_new_user.py index fb29f972e2..1ed1e179af 100644 --- a/zilencer/management/commands/add_new_user.py +++ b/zilencer/management/commands/add_new_user.py @@ -6,6 +6,7 @@ from zerver.lib.actions import do_create_user from zerver.lib.management import ZulipBaseCommand from zerver.models import Realm, UserProfile + class Command(ZulipBaseCommand): help = """Add a new user for manual testing of the onboarding process. If realm is unspecified, will try to use a realm created by add_new_realm, diff --git a/zilencer/management/commands/add_remote_server.py b/zilencer/management/commands/add_remote_server.py index 7cfb3775cb..cace945c10 100644 --- a/zilencer/management/commands/add_remote_server.py +++ b/zilencer/management/commands/add_remote_server.py @@ -4,6 +4,7 @@ from typing import Any from zerver.lib.management import ZulipBaseCommand from zilencer.models import RemoteZulipServer + class Command(ZulipBaseCommand): help = """Add a remote Zulip server for push notifications.""" diff --git a/zilencer/management/commands/compare_messages.py b/zilencer/management/commands/compare_messages.py index 36d3764066..bb941fdb89 100644 --- a/zilencer/management/commands/compare_messages.py +++ b/zilencer/management/commands/compare_messages.py @@ -3,6 +3,7 @@ from typing import Any import ijson from django.core.management.base import BaseCommand, CommandParser + class Command(BaseCommand): help = """ Render messages to a file. diff --git a/zilencer/management/commands/invoice_plans.py b/zilencer/management/commands/invoice_plans.py index 8ecd9e5dc2..ade071ec29 100644 --- a/zilencer/management/commands/invoice_plans.py +++ b/zilencer/management/commands/invoice_plans.py @@ -3,6 +3,7 @@ from typing import Any from django.conf import settings from zerver.lib.management import ZulipBaseCommand + if settings.BILLING_ENABLED: from corporate.lib.stripe import invoice_plans_as_needed diff --git a/zilencer/management/commands/mark_all_messages_unread.py b/zilencer/management/commands/mark_all_messages_unread.py index fe5f9da373..bb5f0c4cb6 100644 --- a/zilencer/management/commands/mark_all_messages_unread.py +++ b/zilencer/management/commands/mark_all_messages_unread.py @@ -7,6 +7,7 @@ from django.db.models import F from zerver.models import UserMessage, UserProfile + class Command(BaseCommand): help = """Script to mark all messages as unread.""" diff --git a/zilencer/management/commands/migrate_stream_notifications.py b/zilencer/management/commands/migrate_stream_notifications.py index ccde7ee936..d462394c04 100644 --- a/zilencer/management/commands/migrate_stream_notifications.py +++ b/zilencer/management/commands/migrate_stream_notifications.py @@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand from zerver.models import Subscription + class Command(BaseCommand): help = """One-off script to migration users' stream notification settings.""" diff --git a/zilencer/management/commands/print_initial_password.py b/zilencer/management/commands/print_initial_password.py index df0cbb3dbf..3c728a5f33 100644 --- a/zilencer/management/commands/print_initial_password.py +++ b/zilencer/management/commands/print_initial_password.py @@ -5,6 +5,7 @@ from zerver.lib.initial_password import initial_password from zerver.lib.management import ZulipBaseCommand from zerver.lib.users import get_api_key + class Command(ZulipBaseCommand): help = "Print the initial password and API key for accounts as created by populate_db" diff --git a/zilencer/management/commands/render_messages.py b/zilencer/management/commands/render_messages.py index eff27cfaca..fafaa89707 100644 --- a/zilencer/management/commands/render_messages.py +++ b/zilencer/management/commands/render_messages.py @@ -8,6 +8,7 @@ from django.db.models import QuerySet from zerver.lib.message import render_markdown from zerver.models import Message + def queryset_iterator(queryset: QuerySet, chunksize: int=5000) -> Iterator[Any]: queryset = queryset.order_by('id') while queryset.exists(): diff --git a/zilencer/management/commands/sync_api_key.py b/zilencer/management/commands/sync_api_key.py index c58991c357..0fa70f2183 100644 --- a/zilencer/management/commands/sync_api_key.py +++ b/zilencer/management/commands/sync_api_key.py @@ -6,6 +6,7 @@ from django.core.management.base import BaseCommand from zerver.models import UserProfile, get_realm, get_user_by_delivery_email + class Command(BaseCommand): help = """Sync your API key from ~/.zuliprc into your development instance""" diff --git a/zilencer/migrations/0001_initial.py b/zilencer/migrations/0001_initial.py index 120ceffc8e..4927dab49e 100644 --- a/zilencer/migrations/0001_initial.py +++ b/zilencer/migrations/0001_initial.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zilencer/migrations/0002_remote_zulip_server.py b/zilencer/migrations/0002_remote_zulip_server.py index 3d83a22a22..ad0c971274 100644 --- a/zilencer/migrations/0002_remote_zulip_server.py +++ b/zilencer/migrations/0002_remote_zulip_server.py @@ -2,6 +2,7 @@ import django.db.models.deletion from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py b/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py index f38e94e847..8d96d6bab8 100644 --- a/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py +++ b/zilencer/migrations/0003_add_default_for_remotezulipserver_last_updated_field.py @@ -2,6 +2,7 @@ # Generated by Django 1.10.5 on 2017-05-16 00:03 from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zilencer/migrations/0004_remove_deployment_model.py b/zilencer/migrations/0004_remove_deployment_model.py index 4c14e92503..90c5bccf89 100644 --- a/zilencer/migrations/0004_remove_deployment_model.py +++ b/zilencer/migrations/0004_remove_deployment_model.py @@ -2,6 +2,7 @@ # Generated by Django 1.11.5 on 2017-10-12 06:27 from django.db import migrations + class Migration(migrations.Migration): dependencies = [ diff --git a/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py b/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py index 3a4c71e9c5..9a4051ee0d 100644 --- a/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py +++ b/zilencer/migrations/0005_remotepushdevicetoken_fix_uniqueness.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals from django.db import migrations, models + class Migration(migrations.Migration): dependencies = [ diff --git a/zilencer/migrations/0006_customer.py b/zilencer/migrations/0006_customer.py index 0c3c3e37a6..366104d349 100644 --- a/zilencer/migrations/0006_customer.py +++ b/zilencer/migrations/0006_customer.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.6 on 2018-01-13 11:54 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zilencer/migrations/0008_customer_billing_user.py b/zilencer/migrations/0008_customer_billing_user.py index f4df52d16f..e50467d911 100644 --- a/zilencer/migrations/0008_customer_billing_user.py +++ b/zilencer/migrations/0008_customer_billing_user.py @@ -2,9 +2,9 @@ # Generated by Django 1.11.11 on 2018-04-12 01:14 from __future__ import unicode_literals +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/zilencer/migrations/0010_billingprocessor.py b/zilencer/migrations/0010_billingprocessor.py index 9f2b02d3eb..8d03877112 100644 --- a/zilencer/migrations/0010_billingprocessor.py +++ b/zilencer/migrations/0010_billingprocessor.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.14 on 2018-08-13 23:15 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zilencer/migrations/0016_remote_counts.py b/zilencer/migrations/0016_remote_counts.py index 24eb04daa6..512cb4035c 100644 --- a/zilencer/migrations/0016_remote_counts.py +++ b/zilencer/migrations/0016_remote_counts.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.18 on 2019-02-02 06:02 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/zilencer/migrations/0018_remoterealmauditlog.py b/zilencer/migrations/0018_remoterealmauditlog.py index e0b36a872e..0d8e23cb3d 100644 --- a/zilencer/migrations/0018_remoterealmauditlog.py +++ b/zilencer/migrations/0018_remoterealmauditlog.py @@ -2,8 +2,8 @@ # Generated by Django 1.11.24 on 2019-10-03 00:10 from __future__ import unicode_literals -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration):