mirror of https://github.com/zulip/zulip.git
urls: Use unqualified imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
e70f2ae58d
commit
5297e4a30a
|
@ -1,27 +1,42 @@
|
|||
from django.conf.urls import include
|
||||
from django.urls import path
|
||||
|
||||
import analytics.views
|
||||
from analytics.views import (
|
||||
get_activity,
|
||||
get_chart_data,
|
||||
get_chart_data_for_installation,
|
||||
get_chart_data_for_realm,
|
||||
get_chart_data_for_remote_installation,
|
||||
get_chart_data_for_remote_realm,
|
||||
get_realm_activity,
|
||||
get_user_activity,
|
||||
stats,
|
||||
stats_for_installation,
|
||||
stats_for_realm,
|
||||
stats_for_remote_installation,
|
||||
stats_for_remote_realm,
|
||||
support,
|
||||
)
|
||||
from zerver.lib.rest import rest_dispatch
|
||||
|
||||
i18n_urlpatterns = [
|
||||
# Server admin (user_profile.is_staff) visible stats pages
|
||||
path('activity', analytics.views.get_activity),
|
||||
path('activity/support', analytics.views.support,
|
||||
path('activity', get_activity),
|
||||
path('activity/support', support,
|
||||
name='support'),
|
||||
path('realm_activity/<realm_str>/', analytics.views.get_realm_activity),
|
||||
path('user_activity/<email>/', analytics.views.get_user_activity),
|
||||
path('realm_activity/<realm_str>/', get_realm_activity),
|
||||
path('user_activity/<email>/', get_user_activity),
|
||||
|
||||
path('stats/realm/<realm_str>/', analytics.views.stats_for_realm),
|
||||
path('stats/installation', analytics.views.stats_for_installation),
|
||||
path('stats/realm/<realm_str>/', stats_for_realm),
|
||||
path('stats/installation', stats_for_installation),
|
||||
path('stats/remote/<int:remote_server_id>/installation',
|
||||
analytics.views.stats_for_remote_installation),
|
||||
stats_for_remote_installation),
|
||||
path('stats/remote/<int:remote_server_id>/realm/<int:remote_realm_id>/',
|
||||
analytics.views.stats_for_remote_realm),
|
||||
stats_for_remote_realm),
|
||||
|
||||
# User-visible stats page
|
||||
path('stats', analytics.views.stats,
|
||||
name='analytics.views.stats'),
|
||||
path('stats', stats,
|
||||
name='stats'),
|
||||
]
|
||||
|
||||
# These endpoints are a part of the API (V1), which uses:
|
||||
|
@ -35,16 +50,16 @@ i18n_urlpatterns = [
|
|||
v1_api_and_json_patterns = [
|
||||
# get data for the graphs at /stats
|
||||
path('analytics/chart_data', rest_dispatch,
|
||||
{'GET': analytics.views.get_chart_data}),
|
||||
{'GET': get_chart_data}),
|
||||
path('analytics/chart_data/realm/<realm_str>', rest_dispatch,
|
||||
{'GET': analytics.views.get_chart_data_for_realm}),
|
||||
{'GET': get_chart_data_for_realm}),
|
||||
path('analytics/chart_data/installation', rest_dispatch,
|
||||
{'GET': analytics.views.get_chart_data_for_installation}),
|
||||
{'GET': get_chart_data_for_installation}),
|
||||
path('analytics/chart_data/remote/<int:remote_server_id>/installation', rest_dispatch,
|
||||
{'GET': analytics.views.get_chart_data_for_remote_installation}),
|
||||
{'GET': get_chart_data_for_remote_installation}),
|
||||
path('analytics/chart_data/remote/<int:remote_server_id>/realm/<int:remote_realm_id>',
|
||||
rest_dispatch,
|
||||
{'GET': analytics.views.get_chart_data_for_remote_realm}),
|
||||
{'GET': get_chart_data_for_remote_realm}),
|
||||
]
|
||||
|
||||
i18n_urlpatterns += [
|
||||
|
|
|
@ -4,7 +4,14 @@ from django.conf.urls import include
|
|||
from django.urls import path
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
import corporate.views
|
||||
from corporate.views import (
|
||||
billing_home,
|
||||
change_plan_status,
|
||||
initial_upgrade,
|
||||
replace_payment_source,
|
||||
sponsorship,
|
||||
upgrade,
|
||||
)
|
||||
from zerver.lib.rest import rest_dispatch
|
||||
|
||||
i18n_urlpatterns: Any = [
|
||||
|
@ -15,19 +22,19 @@ i18n_urlpatterns: Any = [
|
|||
path('jobs/', TemplateView.as_view(template_name='corporate/jobs.html')),
|
||||
|
||||
# Billing
|
||||
path('billing/', corporate.views.billing_home),
|
||||
path('upgrade/', corporate.views.initial_upgrade, name='initial_upgrade'),
|
||||
path('billing/', billing_home),
|
||||
path('upgrade/', initial_upgrade, name='initial_upgrade'),
|
||||
]
|
||||
|
||||
v1_api_and_json_patterns = [
|
||||
path('billing/upgrade', rest_dispatch,
|
||||
{'POST': corporate.views.upgrade}),
|
||||
{'POST': upgrade}),
|
||||
path('billing/sponsorship', rest_dispatch,
|
||||
{'POST': corporate.views.sponsorship}),
|
||||
{'POST': sponsorship}),
|
||||
path('billing/plan/change', rest_dispatch,
|
||||
{'POST': corporate.views.change_plan_status}),
|
||||
{'POST': change_plan_status}),
|
||||
path('billing/sources/change', rest_dispatch,
|
||||
{'POST': corporate.views.replace_payment_source}),
|
||||
{'POST': replace_payment_source}),
|
||||
]
|
||||
|
||||
# Make a copy of i18n_urlpatterns so that they appear without prefix for English
|
||||
|
|
|
@ -140,9 +140,9 @@ yields a response with this HTTP header:
|
|||
|
||||
We can see this reflected in [zproject/urls.py](https://github.com/zulip/zulip/blob/master/zproject/urls.py):
|
||||
|
||||
path('users', zerver.lib.rest.rest_dispatch,
|
||||
{'GET': zerver.views.users.get_members_backend,
|
||||
'PUT': zerver.views.users.create_user_backend}),
|
||||
path('users', rest_dispatch,
|
||||
{'GET': get_members_backend,
|
||||
'PUT': create_user_backend}),
|
||||
|
||||
In this way, the API is partially self-documenting.
|
||||
|
||||
|
@ -176,8 +176,8 @@ the request, and then figure out which view to show from that.
|
|||
In our example,
|
||||
|
||||
```
|
||||
{'GET': zerver.views.users.get_members_backend,
|
||||
'PUT': zerver.views.users.create_user_backend}
|
||||
{'GET': get_members_backend,
|
||||
'PUT': create_user_backend}
|
||||
```
|
||||
|
||||
is supplied as an argument to `rest_dispatch`, along with the
|
||||
|
|
|
@ -3,30 +3,38 @@ from typing import Any
|
|||
from django.conf.urls import include
|
||||
from django.urls import path
|
||||
|
||||
import zilencer.views
|
||||
from zerver.lib.rest import rest_dispatch
|
||||
from zilencer.views import (
|
||||
register_remote_push_device,
|
||||
register_remote_server,
|
||||
remote_server_check_analytics,
|
||||
remote_server_notify_push,
|
||||
remote_server_post_analytics,
|
||||
unregister_all_remote_push_devices,
|
||||
unregister_remote_push_device,
|
||||
)
|
||||
|
||||
i18n_urlpatterns: Any = []
|
||||
|
||||
# Zilencer views following the REST API style
|
||||
v1_api_and_json_patterns = [
|
||||
path('remotes/push/register', rest_dispatch,
|
||||
{'POST': zilencer.views.register_remote_push_device}),
|
||||
{'POST': register_remote_push_device}),
|
||||
path('remotes/push/unregister', rest_dispatch,
|
||||
{'POST': zilencer.views.unregister_remote_push_device}),
|
||||
{'POST': unregister_remote_push_device}),
|
||||
path('remotes/push/unregister/all', rest_dispatch,
|
||||
{'POST': zilencer.views.unregister_all_remote_push_devices}),
|
||||
{'POST': unregister_all_remote_push_devices}),
|
||||
path('remotes/push/notify', rest_dispatch,
|
||||
{'POST': zilencer.views.remote_server_notify_push}),
|
||||
{'POST': remote_server_notify_push}),
|
||||
|
||||
# Push signup doesn't use the REST API, since there's no auth.
|
||||
path('remotes/server/register', zilencer.views.register_remote_server),
|
||||
path('remotes/server/register', register_remote_server),
|
||||
|
||||
# For receiving table data used in analytics and billing
|
||||
path('remotes/server/analytics', rest_dispatch,
|
||||
{'POST': zilencer.views.remote_server_post_analytics}),
|
||||
{'POST': remote_server_post_analytics}),
|
||||
path('remotes/server/analytics/status', rest_dispatch,
|
||||
{'GET': zilencer.views.remote_server_check_analytics}),
|
||||
{'GET': remote_server_check_analytics}),
|
||||
]
|
||||
|
||||
urlpatterns = [
|
||||
|
|
|
@ -9,10 +9,19 @@ from django.urls import path
|
|||
from django.views.generic import TemplateView
|
||||
from django.views.static import serve
|
||||
|
||||
import zerver.views.auth
|
||||
import zerver.views.development.email_log
|
||||
import zerver.views.development.integrations
|
||||
import zerver.views.development.registration
|
||||
from zerver.views.auth import login_page
|
||||
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,
|
||||
dev_panel,
|
||||
get_fixtures,
|
||||
send_all_webhook_fixture_messages,
|
||||
)
|
||||
from zerver.views.development.registration import (
|
||||
confirmation_key,
|
||||
register_development_realm,
|
||||
register_development_user,
|
||||
)
|
||||
|
||||
# These URLs are available only in the development environment
|
||||
|
||||
|
@ -33,22 +42,22 @@ urls = [
|
|||
os.path.join(settings.DEPLOY_ROOT, 'docs/_build/html')}),
|
||||
|
||||
# The special no-password login endpoint for development
|
||||
path('devlogin/', zerver.views.auth.login_page,
|
||||
path('devlogin/', login_page,
|
||||
{'template_name': 'zerver/dev_login.html'}, name='login_page'),
|
||||
|
||||
# Page for testing email templates
|
||||
path('emails/', zerver.views.development.email_log.email_page),
|
||||
path('emails/generate/', zerver.views.development.email_log.generate_all_emails),
|
||||
path('emails/clear/', zerver.views.development.email_log.clear_emails),
|
||||
path('emails/', email_page),
|
||||
path('emails/generate/', generate_all_emails),
|
||||
path('emails/clear/', clear_emails),
|
||||
|
||||
# Listing of useful URLs and various tools for development
|
||||
path('devtools/', TemplateView.as_view(template_name='zerver/dev_tools.html')),
|
||||
# Register New User and Realm
|
||||
path('devtools/register_user/',
|
||||
zerver.views.development.registration.register_development_user,
|
||||
register_development_user,
|
||||
name='register_dev_user'),
|
||||
path('devtools/register_realm/',
|
||||
zerver.views.development.registration.register_development_realm,
|
||||
register_development_realm,
|
||||
name='register_dev_realm'),
|
||||
|
||||
# Have easy access for error pages
|
||||
|
@ -56,13 +65,13 @@ urls = [
|
|||
path('errors/5xx/', TemplateView.as_view(template_name='500.html')),
|
||||
|
||||
# Add a convenient way to generate webhook messages from fixtures.
|
||||
path('devtools/integrations/', zerver.views.development.integrations.dev_panel),
|
||||
path('devtools/integrations/', dev_panel),
|
||||
path('devtools/integrations/check_send_webhook_fixture_message',
|
||||
zerver.views.development.integrations.check_send_webhook_fixture_message),
|
||||
check_send_webhook_fixture_message),
|
||||
path('devtools/integrations/send_all_webhook_fixture_messages',
|
||||
zerver.views.development.integrations.send_all_webhook_fixture_messages),
|
||||
send_all_webhook_fixture_messages),
|
||||
path('devtools/integrations/<integration_name>/fixtures',
|
||||
zerver.views.development.integrations.get_fixtures),
|
||||
get_fixtures),
|
||||
]
|
||||
|
||||
# Serve static assets via the Django server
|
||||
|
@ -79,7 +88,7 @@ else:
|
|||
urls += static(urlsplit(settings.STATIC_URL).path, view=serve_static)
|
||||
|
||||
i18n_urls = [
|
||||
path('confirmation_key/', zerver.views.development.registration.confirmation_key),
|
||||
path('confirmation_key/', confirmation_key),
|
||||
]
|
||||
urls += i18n_urls
|
||||
|
||||
|
|
669
zproject/urls.py
669
zproject/urls.py
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue