diff --git a/corporate/views.py b/corporate/views.py index 2d8df45566..bd29cf5ef2 100644 --- a/corporate/views.py +++ b/corporate/views.py @@ -1,12 +1,12 @@ import logging import stripe -from typing import Any, Dict, Optional, Tuple, cast +from typing import Any, Dict, cast from django.core import signing from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.utils.timezone import now as timezone_now -from django.utils.translation import ugettext as _, ugettext as err_ -from django.shortcuts import redirect, render +from django.utils.translation import ugettext as _ +from django.shortcuts import render from django.urls import reverse from django.conf import settings @@ -14,9 +14,8 @@ from zerver.decorator import zulip_login_required, require_billing_access from zerver.lib.json_encoder_for_html import JSONEncoderForHTML from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_error, json_success -from zerver.lib.validator import check_string, check_int, check_bool -from zerver.lib.timestamp import timestamp_to_datetime -from zerver.models import UserProfile, Realm +from zerver.lib.validator import check_string, check_int +from zerver.models import UserProfile from corporate.lib.stripe import STRIPE_PUBLISHABLE_KEY, \ stripe_get_customer, get_seat_count, \ process_initial_upgrade, sign_string, \ @@ -24,7 +23,7 @@ from corporate.lib.stripe import STRIPE_PUBLISHABLE_KEY, \ MIN_INVOICED_LICENSES, DEFAULT_INVOICE_DAYS_UNTIL_DUE, \ next_renewal_date, renewal_amount, \ add_plan_renewal_to_license_ledger_if_needed -from corporate.models import Customer, CustomerPlan, LicenseLedger, \ +from corporate.models import Customer, CustomerPlan, \ get_active_plan billing_logger = logging.getLogger('corporate.stripe') diff --git a/zerver/views/archive.py b/zerver/views/archive.py index 1144f99757..4516afc1c2 100644 --- a/zerver/views/archive.py +++ b/zerver/views/archive.py @@ -5,7 +5,7 @@ from django.shortcuts import render from django.template import loader from zerver.lib.streams import get_stream_by_id -from zerver.models import Message, UserProfile, get_stream_recipient +from zerver.models import Message, get_stream_recipient from zerver.lib.avatar import get_gravatar_url from zerver.lib.response import json_success from zerver.lib.timestamp import datetime_to_timestamp diff --git a/zerver/views/attachments.py b/zerver/views/attachments.py index 07d1a77517..4d138b90a8 100644 --- a/zerver/views/attachments.py +++ b/zerver/views/attachments.py @@ -2,7 +2,6 @@ from django.http import HttpRequest, HttpResponse from zerver.models import UserProfile from zerver.lib.actions import notify_attachment_update -from zerver.lib.validator import check_int from zerver.lib.response import json_success from zerver.lib.attachments import user_attachments, remove_attachment, \ access_attachment_by_id diff --git a/zerver/views/auth.py b/zerver/views/auth.py index 97410bde7c..76233bee1b 100644 --- a/zerver/views/auth.py +++ b/zerver/views/auth.py @@ -1,16 +1,13 @@ from django.forms import Form from django.conf import settings -from django.core.exceptions import ValidationError -from django.core.validators import validate_email -from django.contrib.auth import authenticate, get_backends +from django.contrib.auth import authenticate from django.contrib.auth.views import login as django_login_page, \ logout_then_login as django_logout_then_login from django.contrib.auth.views import password_reset as django_password_reset from django.urls import reverse -from zerver.decorator import authenticated_json_post_view, require_post, \ +from zerver.decorator import require_post, \ process_client, do_login, log_view_func -from django.http import HttpRequest, HttpResponse, HttpResponseRedirect, \ - HttpResponseNotFound +from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.template.response import SimpleTemplateResponse from django.middleware.csrf import get_token from django.shortcuts import redirect, render @@ -48,7 +45,6 @@ import jwt import logging import requests import time -import ujson from two_factor.forms import BackupTokenForm from two_factor.views import LoginView as BaseTwoFactorLoginView diff --git a/zerver/views/compatibility.py b/zerver/views/compatibility.py index 56ebde4850..185b51c917 100644 --- a/zerver/views/compatibility.py +++ b/zerver/views/compatibility.py @@ -1,7 +1,7 @@ from django.http import HttpResponse, HttpRequest import re -from typing import Any, List, Dict, Optional, Tuple, Union +from typing import List, Optional, Tuple from django.utils.translation import ugettext as _ diff --git a/zerver/views/custom_profile_fields.py b/zerver/views/custom_profile_fields.py index 2ce184768c..a8a07f9075 100644 --- a/zerver/views/custom_profile_fields.py +++ b/zerver/views/custom_profile_fields.py @@ -1,10 +1,7 @@ - -from typing import Union, List, Dict, Optional, cast -import logging +from typing import Union, List, Dict import ujson -from django.core.exceptions import ValidationError -from django.db import IntegrityError, connection +from django.db import IntegrityError from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ @@ -15,14 +12,13 @@ from zerver.lib.actions import (try_add_realm_custom_profile_field, try_update_realm_custom_profile_field, do_update_user_custom_profile_data, try_reorder_realm_custom_profile_fields, - check_remove_custom_profile_field_value, - notify_user_update_custom_profile_data) + check_remove_custom_profile_field_value) from zerver.lib.response import json_success, json_error from zerver.lib.types import ProfileFieldData from zerver.lib.validator import (check_dict, check_list, check_int, validate_field_data, check_capped_string) -from zerver.models import (custom_profile_fields_for_realm, UserProfile, CustomProfileFieldValue, +from zerver.models import (UserProfile, CustomProfileField, custom_profile_fields_for_realm) from zerver.lib.exceptions import JsonableError from zerver.lib.users import validate_user_custom_profile_data diff --git a/zerver/views/development/email_log.py b/zerver/views/development/email_log.py index c76394bec6..a38e2cdff3 100755 --- a/zerver/views/development/email_log.py +++ b/zerver/views/development/email_log.py @@ -2,7 +2,6 @@ from django.conf import settings from django.http import HttpRequest, HttpResponse from django.shortcuts import render, redirect from django.views.decorators.http import require_GET -from django.views.decorators.csrf import csrf_exempt from zerver.models import ( get_realm, get_user_by_delivery_email, get_realm_stream, Realm, @@ -19,8 +18,6 @@ import urllib from confirmation.models import Confirmation, confirmation_url import os -from typing import List, Dict, Any, Optional -import datetime import subprocess import ujson diff --git a/zerver/views/home.py b/zerver/views/home.py index 5dcaa44805..3a9863cebd 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -1,4 +1,4 @@ -from typing import Any, List, Dict, Optional, Iterator +from typing import List, Dict, Optional from django.conf import settings from django.urls import reverse @@ -6,20 +6,18 @@ from django.http import HttpResponseRedirect, HttpResponse, HttpRequest from django.shortcuts import redirect, render from django.utils import translation from django.utils.cache import patch_cache_control -from itertools import zip_longest from zerver.context_processors import get_realm_from_request -from zerver.decorator import zulip_login_required, process_client, \ +from zerver.decorator import zulip_login_required, \ redirect_to_login from zerver.forms import ToSForm -from zerver.lib.realm_icon import realm_icon_url -from zerver.models import Message, UserProfile, Stream, Subscription, Huddle, \ - Recipient, Realm, UserMessage, DefaultStream, RealmEmoji, RealmDomain, \ - RealmFilter, PreregistrationUser, UserActivity, \ - UserPresence, get_stream_recipient, name_changes_disabled, email_to_username, \ - get_realm_domains, get_usermessage_by_message_id +from zerver.models import Message, UserProfile, \ + Realm, UserMessage, \ + PreregistrationUser, \ + get_stream_recipient, \ + get_usermessage_by_message_id from zerver.lib.events import do_events_register -from zerver.lib.actions import update_user_presence, do_change_tos_version, \ +from zerver.lib.actions import do_change_tos_version, \ realm_user_count from zerver.lib.avatar import avatar_url from zerver.lib.i18n import get_language_list, get_language_name, \ @@ -32,10 +30,8 @@ from zerver.lib.utils import statsd, generate_random_token from two_factor.utils import default_device import calendar -import datetime import logging import os -import re import time @zulip_login_required diff --git a/zerver/views/integrations.py b/zerver/views/integrations.py index 77cb928980..38c72be7a2 100644 --- a/zerver/views/integrations.py +++ b/zerver/views/integrations.py @@ -1,18 +1,14 @@ -from typing import Optional, Any, Dict, Tuple +from typing import Any, Dict, Tuple from collections import OrderedDict from django.views.generic import TemplateView from django.conf import settings from django.http import HttpRequest, HttpResponse, HttpResponseNotFound from django.template import loader -from django.shortcuts import render -import lxml import os import random import re -import ujson -from zerver.lib import bugdown from zerver.lib.integrations import CATEGORIES, INTEGRATIONS, HubotIntegration, \ WebhookIntegration, EmailIntegration from zerver.lib.request import has_request_variables, REQ diff --git a/zerver/views/invite.py b/zerver/views/invite.py index 81159d34a8..04b272a4b7 100644 --- a/zerver/views/invite.py +++ b/zerver/views/invite.py @@ -1,19 +1,16 @@ - -from django.conf import settings -from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ from typing import List, Optional, Set -from zerver.decorator import require_realm_admin, to_non_negative_int, \ +from zerver.decorator import require_realm_admin, \ require_non_guest_human_user from zerver.lib.actions import do_invite_users, do_revoke_user_invite, do_resend_user_invite_email, \ - get_default_subs, do_get_user_invites, do_create_multiuse_invite_link + do_get_user_invites, do_create_multiuse_invite_link from zerver.lib.request import REQ, has_request_variables, JsonableError -from zerver.lib.response import json_success, json_error, json_response -from zerver.lib.streams import access_stream_by_name, access_stream_by_id -from zerver.lib.validator import check_string, check_list, check_bool, check_int +from zerver.lib.response import json_success, json_error +from zerver.lib.streams import access_stream_by_id +from zerver.lib.validator import check_list, check_int from zerver.models import PreregistrationUser, Stream, UserProfile import re diff --git a/zerver/views/messages.py b/zerver/views/messages.py index 61b6839f4d..a214327a26 100644 --- a/zerver/views/messages.py +++ b/zerver/views/messages.py @@ -5,7 +5,7 @@ from django.core import validators from django.core.exceptions import ValidationError from django.db import connection, IntegrityError from django.http import HttpRequest, HttpResponse -from typing import Dict, List, Set, Any, Callable, Iterable, \ +from typing import Dict, List, Set, Any, Iterable, \ Optional, Tuple, Union, Sequence, cast from zerver.lib.exceptions import JsonableError, ErrorCode from zerver.lib.html_diff import highlight_html_differences @@ -54,7 +54,7 @@ from zerver.models import Message, UserProfile, Stream, Subscription, Client,\ from sqlalchemy import func from sqlalchemy.sql import select, join, column, literal_column, literal, and_, \ - or_, not_, union_all, alias, Selectable, Select, ColumnElement, table + or_, not_, union_all, alias, Selectable, ColumnElement, table from dateutil.parser import parse as dateparser import re diff --git a/zerver/views/muting.py b/zerver/views/muting.py index 3745dfa28e..904ea25d03 100644 --- a/zerver/views/muting.py +++ b/zerver/views/muting.py @@ -2,8 +2,6 @@ from django.http import HttpResponse, HttpRequest from typing import Optional -import ujson - from django.utils.translation import ugettext as _ from zerver.lib.actions import do_mute_topic, do_unmute_topic from zerver.lib.request import has_request_variables, REQ @@ -17,7 +15,7 @@ from zerver.lib.streams import ( check_for_exactly_one_stream_arg, ) from zerver.lib.validator import check_int -from zerver.models import get_stream, Stream, UserProfile +from zerver.models import UserProfile def mute_topic(user_profile: UserProfile, stream_id: Optional[int], diff --git a/zerver/views/pointer.py b/zerver/views/pointer.py index 7f015f01e2..00a54b6d98 100644 --- a/zerver/views/pointer.py +++ b/zerver/views/pointer.py @@ -6,7 +6,7 @@ from zerver.decorator import to_non_negative_int from zerver.lib.actions import do_update_pointer from zerver.lib.request import has_request_variables, JsonableError, REQ from zerver.lib.response import json_success -from zerver.models import UserProfile, UserMessage, get_usermessage_by_message_id +from zerver.models import UserProfile, get_usermessage_by_message_id def get_pointer_backend(request: HttpRequest, user_profile: UserProfile) -> HttpResponse: return json_success({'pointer': user_profile.pointer}) diff --git a/zerver/views/push_notifications.py b/zerver/views/push_notifications.py index c7b0b7e5ce..f820e3186d 100644 --- a/zerver/views/push_notifications.py +++ b/zerver/views/push_notifications.py @@ -1,9 +1,3 @@ - -import requests -import json - -from typing import Optional - from django.conf import settings from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ @@ -12,8 +6,7 @@ from zerver.decorator import human_users_only from zerver.lib.push_notifications import add_push_device_token, \ b64_to_hex, remove_push_device_token from zerver.lib.request import has_request_variables, REQ, JsonableError -from zerver.lib.response import json_success, json_error -from zerver.lib.validator import check_string, check_list, check_bool +from zerver.lib.response import json_success from zerver.models import PushDeviceToken, UserProfile def validate_token(token_str: bytes, kind: int) -> None: diff --git a/zerver/views/reactions.py b/zerver/views/reactions.py index 59c0f74500..8da23b3978 100644 --- a/zerver/views/reactions.py +++ b/zerver/views/reactions.py @@ -2,7 +2,7 @@ from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ from zerver.decorator import \ - has_request_variables, REQ, to_non_negative_int + has_request_variables, REQ from zerver.lib.actions import do_add_reaction, do_add_reaction_legacy, \ do_remove_reaction, do_remove_reaction_legacy from zerver.lib.emoji import check_emoji_request, check_valid_emoji, \ diff --git a/zerver/views/realm.py b/zerver/views/realm.py index bcef1e7db1..7a646fcd14 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -1,9 +1,7 @@ - -from typing import Any, Dict, Optional, List +from typing import Any, Dict, Optional from django.http import HttpRequest, HttpResponse from django.shortcuts import render from django.utils.translation import ugettext as _ -from django.conf import settings from django.core.exceptions import ValidationError from django.views.decorators.http import require_GET diff --git a/zerver/views/realm_emoji.py b/zerver/views/realm_emoji.py index 8020653dc7..8c157809c5 100644 --- a/zerver/views/realm_emoji.py +++ b/zerver/views/realm_emoji.py @@ -1,10 +1,9 @@ from django.conf import settings -from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ from zerver.models import RealmEmoji, UserProfile -from zerver.lib.emoji import check_emoji_admin, check_valid_emoji_name, check_valid_emoji +from zerver.lib.emoji import check_emoji_admin, check_valid_emoji_name from zerver.lib.request import JsonableError, REQ, has_request_variables from zerver.lib.response import json_success, json_error from zerver.lib.actions import check_add_realm_emoji, do_remove_realm_emoji diff --git a/zerver/views/realm_filters.py b/zerver/views/realm_filters.py index 83cb1b47b9..b26360168a 100644 --- a/zerver/views/realm_filters.py +++ b/zerver/views/realm_filters.py @@ -1,14 +1,11 @@ from django.core.exceptions import ValidationError from django.http import HttpRequest, HttpResponse -from django.views.decorators.csrf import csrf_exempt from django.utils.translation import ugettext as _ from zerver.decorator import require_realm_admin from zerver.lib.actions import do_add_realm_filter, do_remove_realm_filter from zerver.lib.request import has_request_variables, REQ from zerver.lib.response import json_success, json_error -from zerver.lib.rest import rest_dispatch as _rest_dispatch -from zerver.lib.validator import check_string from zerver.models import realm_filters_for_realm, UserProfile, RealmFilter diff --git a/zerver/views/registration.py b/zerver/views/registration.py index fc94d08450..9c60fbed5f 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -1,14 +1,12 @@ # -*- coding: utf-8 -*- -from typing import Any, List, Dict, Mapping, Optional +from typing import List, Dict, Optional from django.utils.translation import ugettext as _ from django.conf import settings from django.contrib.auth import authenticate, get_backends from django.urls import reverse -from django.http import HttpResponseRedirect, HttpResponseForbidden, HttpResponse, HttpRequest +from django.http import HttpResponseRedirect, HttpResponse, HttpRequest from django.shortcuts import redirect, render -from django.template import RequestContext, loader -from django.utils.timezone import now from django.core.exceptions import ValidationError from django.core import validators from zerver.context_processors import get_realm_from_request @@ -18,19 +16,17 @@ from zerver.models import UserProfile, Realm, Stream, MultiuseInvite, \ DomainNotAllowedForRealmError, get_source_profile, EmailContainsPlusError, \ PreregistrationUser from zerver.lib.send_email import send_email, FromAddress -from zerver.lib.events import do_events_register -from zerver.lib.actions import do_change_password, do_change_full_name, do_change_is_admin, \ +from zerver.lib.actions import do_change_password, do_change_full_name, \ do_activate_user, do_create_user, do_create_realm, \ - email_not_system_bot, validate_email_for_realm, \ + validate_email_for_realm, \ do_set_user_display_setting, lookup_default_stream_groups, bulk_add_subscriptions from zerver.forms import RegistrationForm, HomepageForm, RealmCreationForm, \ - CreateUserForm, FindMyTeamForm, RealmRedirectForm + FindMyTeamForm, RealmRedirectForm from django_auth_ldap.backend import LDAPBackend, _LDAPUser -from zerver.decorator import require_post, has_request_variables, \ - JsonableError, REQ, do_login +from zerver.decorator import require_post, \ + do_login from zerver.lib.onboarding import setup_initial_streams, \ send_initial_realm_messages, setup_realm_internal_bots -from zerver.lib.response import json_success from zerver.lib.subdomains import get_subdomain, is_root_domain_available from zerver.lib.timezone import get_all_timezones from zerver.lib.users import get_accounts_for_email @@ -38,7 +34,7 @@ from zerver.lib.zephyr import compute_mit_user_fullname from zerver.views.auth import create_preregistration_user, redirect_and_log_into_subdomain, \ redirect_to_deactivation_notice, get_safe_redirect_to -from zproject.backends import ldap_auth_enabled, password_auth_enabled, ZulipLDAPAuthBackend, \ +from zproject.backends import ldap_auth_enabled, password_auth_enabled, \ ZulipLDAPExceptionOutsideDomain, email_auth_enabled from confirmation.models import Confirmation, RealmCreationKey, ConfirmationKeyException, \ @@ -46,9 +42,7 @@ from confirmation.models import Confirmation, RealmCreationKey, ConfirmationKeyE render_confirmation_key_error import logging -import requests import smtplib -import ujson import urllib diff --git a/zerver/views/report.py b/zerver/views/report.py index 285884f284..c02444f6ff 100644 --- a/zerver/views/report.py +++ b/zerver/views/report.py @@ -1,17 +1,16 @@ # System documented in https://zulip.readthedocs.io/en/latest/subsystems/logging.html -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, Optional from django.conf import settings from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from django.views.decorators.csrf import csrf_exempt from django.views.decorators.http import require_POST from zerver.decorator import human_users_only, \ to_non_negative_int from zerver.lib.bugdown import privacy_clean_markdown from zerver.lib.request import has_request_variables, REQ -from zerver.lib.response import json_success, json_error +from zerver.lib.response import json_success from zerver.lib.queue import queue_json_publish from zerver.lib.unminify import SourceMap from zerver.lib.utils import statsd, statsd_key @@ -21,7 +20,6 @@ from zerver.models import UserProfile import subprocess import os import logging -import ujson js_source_map = None # type: Optional[SourceMap] diff --git a/zerver/views/storage.py b/zerver/views/storage.py index 2f93204ba7..5fc4b6601b 100644 --- a/zerver/views/storage.py +++ b/zerver/views/storage.py @@ -1,11 +1,9 @@ from django.http import HttpRequest, HttpResponse -from django.utils.translation import ugettext as _ from zerver.lib.bot_storage import ( get_bot_storage, set_bot_storage, remove_bot_storage, get_keys_in_bot_storage, - is_key_in_bot_storage, StateError, ) from zerver.decorator import has_request_variables, REQ diff --git a/zerver/views/streams.py b/zerver/views/streams.py index 6904d1038e..4921ca7a4a 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -5,7 +5,6 @@ from django.utils.translation import ugettext as _ from django.conf import settings from django.db import transaction from django.http import HttpRequest, HttpResponse -from django.utils.timezone import now as timezone_now from zerver.lib.exceptions import JsonableError, ErrorCode from zerver.lib.request import REQ, has_request_variables @@ -14,7 +13,7 @@ from zerver.decorator import authenticated_json_post_view, \ from zerver.lib.actions import bulk_remove_subscriptions, \ do_change_subscription_property, internal_prep_private_message, \ internal_prep_stream_message, \ - gather_subscriptions, subscribed_to_stream, \ + gather_subscriptions, \ bulk_add_subscriptions, do_send_messages, get_subscriber_emails, do_rename_stream, \ do_deactivate_stream, do_change_stream_invite_only, do_add_default_stream, \ do_change_stream_description, do_get_streams, \ @@ -24,15 +23,15 @@ from zerver.lib.actions import bulk_remove_subscriptions, \ do_change_default_stream_group_description, do_change_default_stream_group_name, \ prep_stream_welcome_message, do_change_stream_announcement_only, \ do_delete_messages -from zerver.lib.response import json_success, json_error, json_response +from zerver.lib.response import json_success, json_error from zerver.lib.streams import access_stream_by_id, access_stream_by_name, \ check_stream_name, check_stream_name_available, filter_stream_authorization, \ list_to_streams, access_stream_for_delete_or_update, access_default_stream_group_by_id from zerver.lib.topic import get_topic_history_for_stream, messages_for_topic from zerver.lib.validator import check_string, check_int, check_list, check_dict, \ check_bool, check_variable_type, check_capped_string, check_color, check_dict_only -from zerver.models import UserProfile, Stream, Realm, Subscription, \ - Recipient, Message, UserMessage, get_recipient, get_stream, \ +from zerver.models import UserProfile, Stream, \ + UserMessage, \ get_system_bot, get_active_user from collections import defaultdict diff --git a/zerver/views/submessage.py b/zerver/views/submessage.py index 30a51ce1bd..879bc13a1b 100644 --- a/zerver/views/submessage.py +++ b/zerver/views/submessage.py @@ -1,9 +1,7 @@ -import logging import ujson from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ -from django.conf import settings from zerver.decorator import ( has_request_variables, diff --git a/zerver/views/thumbnail.py b/zerver/views/thumbnail.py index f327459482..787b545e60 100644 --- a/zerver/views/thumbnail.py +++ b/zerver/views/thumbnail.py @@ -3,12 +3,10 @@ from django.shortcuts import redirect from django.utils.translation import ugettext as _ from django.http import HttpRequest, HttpResponse, HttpResponseForbidden -from django.conf import settings from typing import Optional from zerver.models import UserProfile, validate_attachment_request from zerver.lib.request import has_request_variables, REQ from zerver.lib.thumbnail import generate_thumbnail_url -import urllib def validate_thumbnail_request(user_profile: UserProfile, path: str) -> Optional[bool]: # path here does not have a leading / as it is parsed from request hitting the diff --git a/zerver/views/typing.py b/zerver/views/typing.py index 6ef1bdcc4a..43da3a140d 100644 --- a/zerver/views/typing.py +++ b/zerver/views/typing.py @@ -2,7 +2,7 @@ from django.http import HttpRequest, HttpResponse from typing import List -from zerver.decorator import has_request_variables, REQ, JsonableError +from zerver.decorator import has_request_variables, REQ from zerver.lib.actions import check_send_typing_notification, \ extract_recipients from zerver.lib.response import json_success diff --git a/zerver/views/unsubscribe.py b/zerver/views/unsubscribe.py index 9a894e93d9..87545271b7 100644 --- a/zerver/views/unsubscribe.py +++ b/zerver/views/unsubscribe.py @@ -1,11 +1,9 @@ - -from django.conf import settings from django.http import HttpRequest, HttpResponse from django.shortcuts import render from typing import Callable from confirmation.models import Confirmation, get_object_from_key, \ - render_confirmation_key_error, ConfirmationKeyException + ConfirmationKeyException from zerver.lib.actions import do_change_notification_settings, clear_scheduled_emails from zerver.models import UserProfile, ScheduledEmail from zerver.context_processors import common_context diff --git a/zerver/views/upload.py b/zerver/views/upload.py index 2543cec795..affc06d437 100644 --- a/zerver/views/upload.py +++ b/zerver/views/upload.py @@ -1,15 +1,13 @@ # -*- coding: utf-8 -*- -from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, FileResponse, \ +from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, \ HttpResponseNotFound from django.shortcuts import redirect from django.utils.translation import ugettext as _ -from zerver.lib.request import has_request_variables, REQ from zerver.lib.response import json_success, json_error from zerver.lib.upload import upload_message_image_from_request, get_local_file_path, \ - get_signed_upload_url, get_realm_for_filename, check_upload_within_quota -from zerver.lib.validator import check_bool + get_signed_upload_url, check_upload_within_quota from zerver.models import UserProfile, validate_attachment_request from django.conf import settings from sendfile import sendfile diff --git a/zerver/views/user_groups.py b/zerver/views/user_groups.py index 8c9de99b1f..22ef31f1fc 100644 --- a/zerver/views/user_groups.py +++ b/zerver/views/user_groups.py @@ -4,7 +4,6 @@ from django.utils.translation import ugettext as _ from typing import List from zerver.decorator import require_non_guest_human_user -from zerver.context_processors import get_realm_from_request from zerver.lib.actions import check_add_user_group, do_update_user_group_name, \ do_update_user_group_description, bulk_add_members_to_user_group, \ remove_members_from_user_group, check_delete_user_group @@ -12,11 +11,10 @@ from zerver.lib.exceptions import JsonableError from zerver.lib.request import has_request_variables, REQ from zerver.lib.response import json_success, json_error from zerver.lib.users import user_ids_to_users -from zerver.lib.validator import check_list, check_string, check_int, \ - check_short_string +from zerver.lib.validator import check_list, check_int from zerver.lib.user_groups import access_user_group_by_id, get_memberships_of_users, \ get_user_group_members, user_groups_in_realm_serialized -from zerver.models import UserProfile, UserGroup, UserGroupMembership +from zerver.models import UserProfile from zerver.views.streams import compose_views, FuncKwargPair @require_non_guest_human_user diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py index 700d7c722b..e8d686d0ed 100644 --- a/zerver/views/user_settings.py +++ b/zerver/views/user_settings.py @@ -4,15 +4,14 @@ from django.utils.translation import ugettext as _ from django.conf import settings from django.contrib.auth import authenticate, update_session_auth_hash from django.http import HttpRequest, HttpResponse -from django.shortcuts import redirect, render -from django.urls import reverse +from django.shortcuts import render from zerver.decorator import has_request_variables, \ - zulip_login_required, REQ, human_users_only + REQ, human_users_only from zerver.lib.actions import do_change_password, do_change_notification_settings, \ do_change_enter_sends, do_regenerate_api_key, do_change_avatar_fields, \ do_set_user_display_setting, validate_email, do_change_user_delivery_email, \ - do_start_email_change_process, check_change_full_name, do_change_user_delivery_email, \ + do_start_email_change_process, check_change_full_name, \ get_available_notification_sounds from zerver.lib.avatar import avatar_url from zerver.lib.send_email import send_email, FromAddress @@ -22,8 +21,7 @@ from zerver.lib.upload import upload_avatar_image from zerver.lib.validator import check_bool, check_string from zerver.lib.request import JsonableError from zerver.lib.timezone import get_all_timezones -from zerver.models import UserProfile, Realm, name_changes_disabled, \ - EmailChangeStatus +from zerver.models import UserProfile, name_changes_disabled from confirmation.models import get_object_from_key, render_confirmation_key_error, \ ConfirmationKeyException, Confirmation from zproject.backends import email_belongs_to_ldap diff --git a/zerver/views/users.py b/zerver/views/users.py index 8fe529b80d..8ffdbf303f 100644 --- a/zerver/views/users.py +++ b/zerver/views/users.py @@ -1,6 +1,5 @@ -from typing import Callable, Union, Optional, Dict, Any, List, Tuple +from typing import Union, Optional, Dict, Any, List -import os import ujson from django.http import HttpRequest, HttpResponse @@ -8,9 +7,8 @@ from django.http import HttpRequest, HttpResponse from django.utils.translation import ugettext as _ from django.shortcuts import redirect, render from django.conf import settings -from django.core.exceptions import ValidationError -from zerver.decorator import require_realm_admin, zulip_login_required, \ +from zerver.decorator import require_realm_admin, \ require_non_guest_human_user from zerver.forms import CreateUserForm from zerver.lib.actions import do_change_avatar_fields, do_change_bot_owner, \ @@ -22,7 +20,7 @@ from zerver.lib.actions import do_change_avatar_fields, do_change_bot_owner, \ do_update_user_custom_profile_data, check_remove_custom_profile_field_value from zerver.lib.avatar import avatar_url, get_gravatar_url, get_avatar_field from zerver.lib.bot_config import set_bot_config -from zerver.lib.exceptions import JsonableError, CannotDeactivateLastUserError +from zerver.lib.exceptions import CannotDeactivateLastUserError from zerver.lib.integrations import EMBEDDED_BOTS from zerver.lib.request import has_request_variables, REQ from zerver.lib.response import json_error, json_success diff --git a/zerver/views/zephyr.py b/zerver/views/zephyr.py index c34330fee7..544ef93d83 100644 --- a/zerver/views/zephyr.py +++ b/zerver/views/zephyr.py @@ -1,11 +1,9 @@ -from typing import Any, List, Dict, Optional, Callable, Tuple, Iterable, Sequence - from django.conf import settings from django.http import HttpResponse, HttpRequest from django.utils.translation import ugettext as _ from zerver.decorator import authenticated_json_view from zerver.lib.ccache import make_ccache -from zerver.lib.request import has_request_variables, REQ, JsonableError +from zerver.lib.request import has_request_variables, REQ from zerver.lib.response import json_success, json_error from zerver.lib.users import get_api_key from zerver.models import UserProfile diff --git a/zilencer/views.py b/zilencer/views.py index 95e6554cad..6d3962c6be 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -1,13 +1,12 @@ from typing import Any, Dict, List, Optional, Union, cast import datetime -import logging from django.core.exceptions import ValidationError from django.core.validators import validate_email, URLValidator from django.db import IntegrityError, transaction from django.http import HttpRequest, HttpResponse from django.utils import timezone -from django.utils.timezone import utc as timezone_utc, now as timezone_now +from django.utils.timezone import utc as timezone_utc from django.utils.translation import ugettext as _, ugettext as err_ from django.views.decorators.csrf import csrf_exempt @@ -20,7 +19,7 @@ from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_error, json_success from zerver.lib.validator import check_int, check_string, \ check_capped_string, check_string_fixed_length, check_float, check_none_or, \ - check_dict, check_dict_only, check_list + check_dict_only, check_list from zerver.models import UserProfile from zerver.views.push_notifications import validate_token from zilencer.models import RemotePushDeviceToken, RemoteZulipServer, \