From 0ab3e15d7153fda65c6c56324a0c8f18287ff534 Mon Sep 17 00:00:00 2001 From: Riken Shah Date: Fri, 23 Apr 2021 09:01:20 +0000 Subject: [PATCH] refactor: Move dev related code from `urls.py` to `dev_urls.py`. --- zproject/dev_urls.py | 12 ++++++++++++ zproject/urls.py | 18 +++++------------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/zproject/dev_urls.py b/zproject/dev_urls.py index bdafbc0d20..db208190e1 100644 --- a/zproject/dev_urls.py +++ b/zproject/dev_urls.py @@ -11,6 +11,11 @@ from django.views.static import serve from zerver.views.auth import config_error, login_page from zerver.views.development.cache import remove_caches +from zerver.views.development.dev_login import ( + api_dev_fetch_api_key, + api_dev_list_users, + dev_direct_login, +) from zerver.views.development.email_log import clear_emails, email_page, generate_all_emails from zerver.views.development.integrations import ( check_send_webhook_fixture_message, @@ -83,6 +88,12 @@ urls = [ path("flush_caches", remove_caches), ] +v1_api_mobile_patterns = [ + # This is for the signing in through the devAuthBackEnd on mobile apps. + path("dev_fetch_api_key", api_dev_fetch_api_key), + # This is for fetching the emails of the admins and the users. + path("dev_list_users", api_dev_list_users), +] # Serve static assets via the Django server if use_prod_static: urls += [ @@ -98,6 +109,7 @@ else: urls += static(urlsplit(settings.STATIC_URL).path, view=serve_static) i18n_urls = [ + path("accounts/login/local/", dev_direct_login, name="login-local"), path("confirmation_key/", confirmation_key), ] urls += i18n_urls diff --git a/zproject/urls.py b/zproject/urls.py index 765803df91..b40057a96a 100644 --- a/zproject/urls.py +++ b/zproject/urls.py @@ -47,11 +47,6 @@ from zerver.views.custom_profile_fields import ( update_realm_custom_profile_field, update_user_custom_profile_data, ) -from zerver.views.development.dev_login import ( - api_dev_fetch_api_key, - api_dev_list_users, - dev_direct_login, -) from zerver.views.digest import digest_page from zerver.views.documentation import IntegrationView, MarkdownDirectoryView, integration_doc from zerver.views.drafts import create_drafts, delete_draft, edit_draft, fetch_drafts @@ -531,7 +526,6 @@ i18n_urls = [ "accounts/register/social//", start_social_signup, name="signup-social" ), path("accounts/login/subdomain/", log_into_subdomain), - path("accounts/login/local/", dev_direct_login, name="login-local"), # We have two entries for accounts/login; only the first one is # used for URL resolution. The second here is to allow # reverse("login") in templates to @@ -726,13 +720,6 @@ v1_api_mobile_patterns = [ # This json format view used by the mobile apps accepts a username # password/pair and returns an API key. path("fetch_api_key", api_fetch_api_key), - # This is for the signing in through the devAuthBackEnd on mobile apps. - path("dev_fetch_api_key", api_dev_fetch_api_key), - # This is for fetching the emails of the admins and the users. - path("dev_list_users", api_dev_list_users), -] -urls += [ - path("api/v1/", include(v1_api_mobile_patterns)), ] # View for uploading messages from email mirror @@ -793,6 +780,11 @@ if settings.TWO_FACTOR_AUTHENTICATION_ENABLED: if settings.DEVELOPMENT: urls += dev_urls.urls i18n_urls += dev_urls.i18n_urls + v1_api_mobile_patterns += dev_urls.v1_api_mobile_patterns + +urls += [ + path("api/v1/", include(v1_api_mobile_patterns)), +] # The sequence is important; if i18n URLs don't come first then # reverse URL mapping points to i18n URLs which causes the frontend