snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
107
corporate/views/sponsorship.py
Normal file
107
corporate/views/sponsorship.py
Normal file
@@ -0,0 +1,107 @@
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
|
||||
from corporate.lib.decorator import (
|
||||
authenticated_remote_realm_management_endpoint,
|
||||
authenticated_remote_server_management_endpoint,
|
||||
)
|
||||
from zerver.decorator import require_billing_access, zulip_login_required
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.models import UserProfile
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from corporate.lib.stripe import RemoteRealmBillingSession, RemoteServerBillingSession
|
||||
|
||||
|
||||
@zulip_login_required
|
||||
def sponsorship_page(request: HttpRequest) -> HttpResponse:
|
||||
from corporate.lib.stripe import RealmBillingSession
|
||||
|
||||
user = request.user
|
||||
assert user.is_authenticated
|
||||
|
||||
billing_session = RealmBillingSession(user)
|
||||
if billing_session.realm.demo_organization_scheduled_deletion_date is not None:
|
||||
return render(
|
||||
request,
|
||||
"corporate/billing/demo_organization_billing_disabled.html",
|
||||
context={
|
||||
"sponsorship_request": True,
|
||||
},
|
||||
)
|
||||
context = billing_session.get_sponsorship_request_context()
|
||||
if context is None or not user.has_billing_access:
|
||||
return HttpResponseRedirect(reverse("billing_page"))
|
||||
|
||||
return render(request, "corporate/billing/sponsorship.html", context=context)
|
||||
|
||||
|
||||
@authenticated_remote_realm_management_endpoint
|
||||
def remote_realm_sponsorship_page(
|
||||
request: HttpRequest,
|
||||
billing_session: "RemoteRealmBillingSession",
|
||||
) -> HttpResponse: # nocoverage
|
||||
context = billing_session.get_sponsorship_request_context()
|
||||
if context is None:
|
||||
return HttpResponseRedirect(
|
||||
reverse("remote_realm_billing_page", args=(billing_session.remote_realm.uuid,))
|
||||
)
|
||||
|
||||
return render(request, "corporate/billing/sponsorship.html", context=context)
|
||||
|
||||
|
||||
@authenticated_remote_server_management_endpoint
|
||||
def remote_server_sponsorship_page(
|
||||
request: HttpRequest,
|
||||
billing_session: "RemoteServerBillingSession",
|
||||
) -> HttpResponse: # nocoverage
|
||||
context = billing_session.get_sponsorship_request_context()
|
||||
if context is None:
|
||||
return HttpResponseRedirect(
|
||||
reverse("remote_server_billing_page", args=(billing_session.remote_server.uuid,))
|
||||
)
|
||||
|
||||
return render(request, "corporate/billing/sponsorship.html", context=context)
|
||||
|
||||
|
||||
@require_billing_access
|
||||
def sponsorship(
|
||||
request: HttpRequest,
|
||||
user: UserProfile,
|
||||
) -> HttpResponse:
|
||||
from corporate.lib.stripe import RealmBillingSession, SponsorshipRequestForm
|
||||
|
||||
billing_session = RealmBillingSession(user)
|
||||
post_data = request.POST.copy()
|
||||
form = SponsorshipRequestForm(post_data)
|
||||
billing_session.request_sponsorship(form)
|
||||
return json_success(request)
|
||||
|
||||
|
||||
@authenticated_remote_realm_management_endpoint
|
||||
def remote_realm_sponsorship(
|
||||
request: HttpRequest,
|
||||
billing_session: "RemoteRealmBillingSession",
|
||||
) -> HttpResponse: # nocoverage
|
||||
from corporate.lib.stripe import SponsorshipRequestForm
|
||||
|
||||
post_data = request.POST.copy()
|
||||
form = SponsorshipRequestForm(post_data)
|
||||
billing_session.request_sponsorship(form)
|
||||
return json_success(request)
|
||||
|
||||
|
||||
@authenticated_remote_server_management_endpoint
|
||||
def remote_server_sponsorship(
|
||||
request: HttpRequest,
|
||||
billing_session: "RemoteServerBillingSession",
|
||||
) -> HttpResponse: # nocoverage
|
||||
from corporate.lib.stripe import SponsorshipRequestForm
|
||||
|
||||
post_data = request.POST.copy()
|
||||
form = SponsorshipRequestForm(post_data)
|
||||
billing_session.request_sponsorship(form)
|
||||
return json_success(request)
|
||||
Reference in New Issue
Block a user