mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
support: Approve sponsorship for remote server customer.
Adds ability to approve a sponsorship request for a customer attached to a remote server via the remote server support view.
This commit is contained in:
committed by
Tim Abbott
parent
2218e667a6
commit
69f6d3dcb1
@@ -388,6 +388,7 @@ def remote_servers_support(
|
|||||||
remote_server_id: Optional[int] = REQ(default=None, converter=to_non_negative_int),
|
remote_server_id: Optional[int] = REQ(default=None, converter=to_non_negative_int),
|
||||||
discount: Optional[Decimal] = REQ(default=None, converter=to_decimal),
|
discount: Optional[Decimal] = REQ(default=None, converter=to_decimal),
|
||||||
sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool),
|
sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool),
|
||||||
|
approve_sponsorship: bool = REQ(default=False, json_validator=check_bool),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
context: Dict[str, Any] = {}
|
context: Dict[str, Any] = {}
|
||||||
|
|
||||||
@@ -411,7 +412,9 @@ def remote_servers_support(
|
|||||||
|
|
||||||
support_view_request = None
|
support_view_request = None
|
||||||
|
|
||||||
if sponsorship_pending is not None:
|
if approve_sponsorship:
|
||||||
|
support_view_request = SupportViewRequest(support_type=SupportType.approve_sponsorship)
|
||||||
|
elif sponsorship_pending is not None:
|
||||||
support_view_request = SupportViewRequest(
|
support_view_request = SupportViewRequest(
|
||||||
support_type=SupportType.update_sponsorship_status,
|
support_type=SupportType.update_sponsorship_status,
|
||||||
sponsorship_status=sponsorship_pending,
|
sponsorship_status=sponsorship_pending,
|
||||||
|
|||||||
@@ -2580,8 +2580,20 @@ class RemoteRealmBillingSession(BillingSession): # nocoverage
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
def approve_sponsorship(self) -> str:
|
def approve_sponsorship(self) -> str:
|
||||||
# TBD
|
# Sponsorship approval is only a support admin action.
|
||||||
return ""
|
assert self.support_session
|
||||||
|
|
||||||
|
self.do_change_plan_type(tier=None, is_sponsored=True)
|
||||||
|
customer = self.get_customer()
|
||||||
|
if customer is not None and customer.sponsorship_pending:
|
||||||
|
customer.sponsorship_pending = False
|
||||||
|
customer.save(update_fields=["sponsorship_pending"])
|
||||||
|
self.write_to_audit_log(
|
||||||
|
event_type=AuditLogEventType.SPONSORSHIP_APPROVED, event_time=timezone_now()
|
||||||
|
)
|
||||||
|
# TODO: Add something (probably email) to let remote realm
|
||||||
|
# organization know that the sponsorship request was approved.
|
||||||
|
return f"Sponsorship approved for {self.billing_entity_display_name}"
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def is_sponsored(self) -> bool:
|
def is_sponsored(self) -> bool:
|
||||||
@@ -2848,8 +2860,20 @@ class RemoteServerBillingSession(BillingSession): # nocoverage
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
def approve_sponsorship(self) -> str:
|
def approve_sponsorship(self) -> str:
|
||||||
# TBD
|
# Sponsorship approval is only a support admin action.
|
||||||
return ""
|
assert self.support_session
|
||||||
|
|
||||||
|
self.do_change_plan_type(tier=None, is_sponsored=True)
|
||||||
|
customer = self.get_customer()
|
||||||
|
if customer is not None and customer.sponsorship_pending:
|
||||||
|
customer.sponsorship_pending = False
|
||||||
|
customer.save(update_fields=["sponsorship_pending"])
|
||||||
|
self.write_to_audit_log(
|
||||||
|
event_type=AuditLogEventType.SPONSORSHIP_APPROVED, event_time=timezone_now()
|
||||||
|
)
|
||||||
|
# TODO: Add something (probably email) to let remote server
|
||||||
|
# organization know that the sponsorship request was approved.
|
||||||
|
return f"Sponsorship approved for {self.billing_entity_display_name}"
|
||||||
|
|
||||||
@override
|
@override
|
||||||
def process_downgrade(self, plan: CustomerPlan) -> None:
|
def process_downgrade(self, plan: CustomerPlan) -> None:
|
||||||
|
|||||||
@@ -58,6 +58,17 @@
|
|||||||
<button type="submit" class="btn btn-default support-submit-button">Update</button>
|
<button type="submit" class="btn btn-default support-submit-button">Update</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
{% if plan_data[remote_server.id].customer and plan_data[remote_server.id].customer.sponsorship_pending %}
|
||||||
|
<form method="POST" class="">
|
||||||
|
{{ csrf_input }}
|
||||||
|
<input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" />
|
||||||
|
<input type="hidden" name="approve_sponsorship" value="true" />
|
||||||
|
<button class="btn btn-default sea-green small approve-sponsorship-button">
|
||||||
|
Approve full sponsorship
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<form method="POST" class="remote-server-form">
|
<form method="POST" class="remote-server-form">
|
||||||
<b>Discount</b>:<br />
|
<b>Discount</b>:<br />
|
||||||
{{ csrf_input }}
|
{{ csrf_input }}
|
||||||
|
|||||||
Reference in New Issue
Block a user