views: Fix imports of REQ/has_request_variables from the wrong place.

These were never in zerver/decorator.py, and so it makes sense to
import them zerver/lib/request.py, mostly for ease of finding things.
This commit is contained in:
Tim Abbott 2017-10-27 15:07:31 -07:00
parent 25251e0216
commit 1cd017288d
14 changed files with 27 additions and 21 deletions

View File

@ -16,9 +16,10 @@ from analytics.lib.time_utils import time_range
from analytics.models import BaseCount, InstallationCount, RealmCount, \
UserCount, StreamCount, last_successful_fill
from zerver.decorator import has_request_variables, REQ, require_server_admin, \
zulip_login_required, to_non_negative_int, to_utc_datetime
from zerver.lib.request import JsonableError
from zerver.decorator import require_server_admin, zulip_login_required, \
to_non_negative_int, to_utc_datetime
from zerver.lib.exceptions import JsonableError
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.response import json_success
from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, \
timestamp_to_datetime, convert_to_UTC

View File

@ -150,8 +150,8 @@ arguments for.
Here's an example:
``` py
from zerver.decorator import has_request_variables, REQ, JsonableError, \
require_realm_admin
from zerver.decorator import require_realm_admin
from zerver.lib.request import has_request_variables, REQ
@require_realm_admin
@has_request_variables

View File

@ -13,6 +13,7 @@ from django.conf import settings
from zerver.forms import OurAuthenticationForm
from zerver.lib.actions import do_deactivate_realm, do_deactivate_user, \
do_reactivate_user, do_reactivate_realm
from zerver.lib.exceptions import JsonableError
from zerver.lib.initial_password import initial_password
from zerver.lib.test_helpers import (
HostRequestMock,
@ -25,7 +26,7 @@ from zerver.lib.response import json_response
from zerver.lib.user_agent import parse_user_agent
from zerver.lib.request import \
REQ, has_request_variables, RequestVariableMissingError, \
RequestVariableConversionError, JsonableError
RequestVariableConversionError
from zerver.decorator import (
api_key_only_webhook_view,
authenticated_json_post_view, authenticated_json_view,

View File

@ -4,7 +4,7 @@ from django.http import HttpResponse, HttpRequest
from typing import List, Text
from zerver.models import UserProfile
from zerver.decorator import has_request_variables, REQ
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.response import json_success
from zerver.lib.validator import check_list, check_string

View File

@ -1,9 +1,9 @@
from django.http import HttpRequest, HttpResponse
from zerver.decorator import REQ
from zerver.models import UserProfile
from zerver.lib.validator import check_int
from zerver.lib.response import json_success
from zerver.lib.request import REQ
from zerver.lib.attachments import user_attachments, remove_attachment, \
access_attachment_by_id

View File

@ -7,8 +7,8 @@ from django.db import IntegrityError, connection
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import has_request_variables, REQ, require_realm_admin, \
human_users_only
from zerver.decorator import require_realm_admin, human_users_only
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.actions import (try_add_realm_custom_profile_field,
do_remove_realm_custom_profile_field,
try_update_realm_custom_profile_field,

View File

@ -1,9 +1,10 @@
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import has_request_variables, REQ, human_users_only
from zerver.decorator import human_users_only
from zerver.lib.actions import do_mark_hotspot_as_read
from zerver.lib.hotspots import ALL_HOTSPOTS
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.response import json_error, json_success
from zerver.lib.validator import check_string
from zerver.models import UserProfile

View File

@ -9,9 +9,9 @@ from django.shortcuts import render
import os
import ujson
from zerver.decorator import has_request_variables, REQ
from zerver.lib import bugdown
from zerver.lib.integrations import CATEGORIES, INTEGRATIONS, HUBOT_LOZENGES
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.subdomains import get_subdomain
from zerver.models import Realm
from zerver.templatetags.app_filters import render_markdown_path

View File

@ -3,10 +3,11 @@ from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from zerver.decorator import has_request_variables, require_realm_admin, REQ
from zerver.decorator import require_realm_admin
from zerver.lib.actions import do_add_realm_domain, do_change_realm_domain, \
do_remove_realm_domain
from zerver.lib.domains import validate_domain
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.response import json_error, json_success
from zerver.lib.validator import check_bool, check_string
from zerver.models import RealmDomain, UserProfile, get_realm_domains

View File

@ -5,8 +5,9 @@ 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 has_request_variables, REQ, require_realm_admin
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

View File

@ -5,9 +5,9 @@ from typing import Any, Dict, Optional, Text
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from zerver.decorator import authenticated_json_post_view, has_request_variables, REQ, \
to_non_negative_int
from zerver.decorator import authenticated_json_post_view, 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
from zerver.lib.queue import queue_json_publish
from zerver.lib.unminify import SourceMap

View File

@ -1,7 +1,7 @@
from django.http import HttpRequest, HttpResponse
from zerver.decorator import has_request_variables, REQ
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.response import json_success
from zerver.lib.validator import check_string
from zerver.models import UserProfile

View File

@ -10,15 +10,16 @@ from django.shortcuts import redirect, render
from django.conf import settings
from six.moves import map
from zerver.decorator import has_request_variables, REQ, JsonableError, \
require_realm_admin, zulip_login_required
from zerver.decorator import require_realm_admin, zulip_login_required
from zerver.forms import CreateUserForm
from zerver.lib.actions import do_change_avatar_fields, do_change_bot_owner, \
do_change_is_admin, do_change_default_all_public_streams, \
do_change_default_events_register_stream, do_change_default_sending_stream, \
do_create_user, do_deactivate_user, do_reactivate_user, do_regenerate_api_key
from zerver.lib.avatar import avatar_url, get_gravatar_url, get_avatar_field
from zerver.lib.exceptions import JsonableError
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
from zerver.lib.streams import access_stream_by_name
from zerver.lib.upload import upload_avatar_image

View File

@ -5,11 +5,11 @@ from django.http import HttpResponse, HttpRequest
from zilencer.models import RemotePushDeviceToken, RemoteZulipServer
from zerver.decorator import has_request_variables, REQ
from zerver.lib.exceptions import JsonableError
from zerver.lib.push_notifications import send_android_push_notification, \
send_apple_push_notification
from zerver.lib.request import JsonableError
from zerver.lib.response import json_error, json_success
from zerver.lib.request import has_request_variables, REQ
from zerver.lib.validator import check_dict, check_int
from zerver.models import UserProfile, PushDeviceToken, Realm
from zerver.views.push_notifications import validate_token