urls: Rename function names to match naming syntax of remote pages.

This commit is contained in:
Aman Agrawal 2023-12-01 06:23:39 +00:00 committed by Tim Abbott
parent a2c1a2f4bb
commit c822e953be
3 changed files with 21 additions and 25 deletions

View File

@ -24,10 +24,10 @@ from corporate.views.portico import (
)
from corporate.views.remote_billing_page import (
remote_billing_legacy_server_login,
remote_billing_page_realm,
remote_billing_page_server,
remote_billing_plans_realm,
remote_billing_plans_server,
remote_realm_billing_page,
remote_server_billing_page,
remote_realm_plans_page,
remote_server_plans_page,
remote_server_billing_finalize_login,
)
from corporate.views.session import (
@ -180,14 +180,14 @@ urlpatterns += [
"remote-billing-login/<signed_billing_access_token>", remote_server_billing_finalize_login
),
# Remote server billing endpoints.
path("realm/<realm_uuid>/plans", remote_billing_plans_realm, name="remote_billing_plans_realm"),
path("realm/<realm_uuid>/plans", remote_realm_plans_page, name="remote_realm_plans_page"),
path(
"server/<server_uuid>/plans",
remote_billing_plans_server,
name="remote_billing_plans_server",
remote_server_plans_page,
name="remote_server_plans_page",
),
path("realm/<realm_uuid>/billing", remote_billing_page_realm, name="remote_billing_page_realm"),
path("server/<server_uuid>/billing", remote_billing_page_server, name="remote_billing_page_server"),
path("realm/<realm_uuid>/billing", remote_realm_billing_page, name="remote_realm_billing_page"),
path("server/<server_uuid>/billing", remote_server_billing_page, name="remote_server_billing_page"),
path("realm/<realm_uuid>/upgrade", remote_realm_upgrade_page, name="remote_realm_upgrade_page"),
path(
"server/<server_uuid>/upgrade",

View File

@ -106,9 +106,7 @@ def remote_server_billing_finalize_login(
assert identity_dict["next_page"] in VALID_NEXT_PAGES
if identity_dict["next_page"] is None:
return HttpResponseRedirect(
reverse("remote_billing_plans_realm", args=(remote_realm_uuid,))
)
return HttpResponseRedirect(reverse("remote_realm_plans_page", args=(remote_realm_uuid,)))
else:
return HttpResponseRedirect(
reverse(f"remote_realm_{identity_dict['next_page']}_page", args=(remote_realm_uuid,))
@ -188,8 +186,8 @@ def remote_billing_plans_common(
request: HttpRequest, realm_uuid: Optional[str], server_uuid: Optional[str]
) -> HttpResponse:
"""
Once implemented, this function, shared between remote_billing_plans_realm
and remote_billing_plans_server, will return a Plans page, adjusted depending
Once implemented, this function, shared between remote_realm_plans_page
and remote_server_plans_page, will return a Plans page, adjusted depending
on whether the /realm/... or /server/... endpoint is being used
"""
@ -198,15 +196,13 @@ def remote_billing_plans_common(
@self_hosting_management_endpoint
@typed_endpoint
def remote_billing_plans_realm(request: HttpRequest, *, realm_uuid: PathOnly[str]) -> HttpResponse:
def remote_realm_plans_page(request: HttpRequest, *, realm_uuid: PathOnly[str]) -> HttpResponse:
return remote_billing_plans_common(request, realm_uuid=realm_uuid, server_uuid=None)
@self_hosting_management_endpoint
@typed_endpoint
def remote_billing_plans_server(
request: HttpRequest, *, server_uuid: PathOnly[str]
) -> HttpResponse:
def remote_server_plans_page(request: HttpRequest, *, server_uuid: PathOnly[str]) -> HttpResponse:
return remote_billing_plans_common(request, server_uuid=server_uuid, realm_uuid=None)
@ -214,8 +210,8 @@ def remote_billing_page_common(
request: HttpRequest, realm_uuid: Optional[str], server_uuid: Optional[str]
) -> HttpResponse:
"""
Once implemented, this function, shared between remote_billing_page_realm
and remote_billing_page_server, will return a Billing page, adjusted depending
Once implemented, this function, shared between remote_realm_billing_page
and remote_server_billing_page, will return a Billing page, adjusted depending
on whether the /realm/... or /server/... endpoint is being used
"""
@ -224,13 +220,13 @@ def remote_billing_page_common(
@self_hosting_management_endpoint
@typed_endpoint
def remote_billing_page_server(request: HttpRequest, *, server_uuid: PathOnly[str]) -> HttpResponse:
def remote_server_billing_page(request: HttpRequest, *, server_uuid: PathOnly[str]) -> HttpResponse:
return remote_billing_page_common(request, server_uuid=server_uuid, realm_uuid=None)
@self_hosting_management_endpoint
@typed_endpoint
def remote_billing_page_realm(request: HttpRequest, *, realm_uuid: PathOnly[str]) -> HttpResponse:
def remote_realm_billing_page(request: HttpRequest, *, realm_uuid: PathOnly[str]) -> HttpResponse:
return remote_billing_page_common(request, realm_uuid=realm_uuid, server_uuid=None)
@ -285,4 +281,4 @@ def remote_billing_legacy_server_login(
authenticated_at=datetime_to_timestamp(timezone_now()),
)
return HttpResponseRedirect(reverse("remote_billing_page_server", args=(remote_server_uuid,)))
return HttpResponseRedirect(reverse("remote_server_billing_page", args=(remote_server_uuid,)))

View File

@ -37,7 +37,7 @@ def remote_realm_sponsorship_page(
) -> HttpResponse: # nocoverage
context = billing_session.get_sponsorship_request_context()
if context is None:
return HttpResponseRedirect(reverse("remote_billing_page_realm"))
return HttpResponseRedirect(reverse("remote_realm_billing_page"))
return render(request, "corporate/sponsorship.html", context=context)
@ -49,7 +49,7 @@ def remote_server_sponsorship_page(
) -> HttpResponse: # nocoverage
context = billing_session.get_sponsorship_request_context()
if context is None:
return HttpResponseRedirect(reverse("remote_billing_page_server"))
return HttpResponseRedirect(reverse("remote_server_billing_page"))
return render(request, "corporate/sponsorship.html", context=context)