Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
support: Add button to delete configured fixed next plan.
Aman Agrawal8cba101e05bc
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 51f84e87bc3..a302591a76c 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -571,6 +571,7 @@ class SupportType(Enum):update_plan_end_date = 7update_required_plan_tier = 8configure_fixed_price_plan = 9+ delete_fixed_price_next_plan = 10class SupportViewRequest(TypedDict, total=False):@@ -3030,6 +3031,15 @@ class BillingSession(ABC):assert support_request["new_plan_tier"] is not Nonenew_plan_tier = support_request["new_plan_tier"]success_message = self.do_change_plan_to_new_tier(new_plan_tier)+ elif support_type == SupportType.delete_fixed_price_next_plan:+ customer = self.get_customer()+ assert customer is not None+ fixed_price_offer = CustomerPlanOffer.objects.filter(+ customer=customer, status=CustomerPlanOffer.CONFIGURED+ ).first()+ assert fixed_price_offer is not None+ fixed_price_offer.delete()+ success_message = "Fixed price offer deleted"return success_messagediff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.pyindex f06774cc0a3..337c64ad38e 100644--- a/corporate/tests/test_stripe.py+++ b/corporate/tests/test_stripe.py@@ -6350,6 +6350,61 @@ class TestRemoteRealmBillingFlow(StripeTestCase, RemoteRealmBillingTestCase):]:self.assert_in_response(substring, response)+ @responses.activate+ @mock_stripe()+ def test_delete_configured_fixed_price_plan_offer(self, *mocks: Mock) -> None:+ self.login("iago")++ self.add_mock_response()+ with time_machine.travel(self.now, tick=False):+ send_server_data_to_push_bouncer(consider_usage_statistics=False)++ self.assertFalse(CustomerPlanOffer.objects.exists())++ annual_fixed_price = 1200+ # Configure required_plan_tier and fixed_price.+ result = self.client_post(+ "/activity/remote/support",+ {+ "remote_realm_id": f"{self.remote_realm.id}",+ "required_plan_tier": CustomerPlan.TIER_SELF_HOSTED_BASIC,+ },+ )+ self.assert_in_success_response(+ ["Required plan tier for Zulip Dev set to Zulip Basic."], result+ )++ result = self.client_post(+ "/activity/remote/support",+ {"remote_realm_id": f"{self.remote_realm.id}", "fixed_price": annual_fixed_price},+ )+ self.assert_in_success_response(+ ["Customer can now buy a fixed price Zulip Basic plan."], result+ )+ fixed_price_plan_offer = CustomerPlanOffer.objects.filter(+ status=CustomerPlanOffer.CONFIGURED+ ).first()+ assert fixed_price_plan_offer is not None+ self.assertEqual(fixed_price_plan_offer.tier, CustomerPlanOffer.TIER_SELF_HOSTED_BASIC)+ self.assertEqual(fixed_price_plan_offer.fixed_price, annual_fixed_price * 100)+ self.assertEqual(fixed_price_plan_offer.get_plan_status_as_text(), "Configured")++ result = self.client_get("/activity/remote/support", {"q": "example.com"})+ self.assert_in_success_response(+ ["Next plan information:", "Zulip Basic", "Configured", "Plan has a fixed price."],+ result,+ )++ billing_session = RemoteRealmBillingSession(remote_realm=self.remote_realm)+ support_request = SupportViewRequest(+ support_type=SupportType.delete_fixed_price_next_plan,+ )+ success_message = billing_session.process_support_view_request(support_request)+ self.assertEqual(success_message, "Fixed price offer deleted")+ result = self.client_get("/activity/remote/support", {"q": "example.com"})+ self.assert_not_in_success_response(["Next plan information:"], result)+ self.assert_in_success_response(["Fixed price", "Annual amount in dollars"], result)+@responses.activate@mock_stripe()def test_upgrade_user_to_fixed_price_plan_pay_by_invoice(self, *mocks: Mock) -> None:diff --git a/corporate/views/support.py b/corporate/views/support.pyindex c1f2d3a33bc..b8903ce6270 100644--- a/corporate/views/support.py+++ b/corporate/views/support.py@@ -503,6 +503,7 @@ def remote_servers_support(modify_plan: Optional[str] = REQ(default=None, str_validator=check_string_in(VALID_MODIFY_PLAN_METHODS)),+ delete_fixed_price_next_plan: bool = REQ(default=False, json_validator=check_bool),) -> HttpResponse:context: Dict[str, Any] = {}@@ -573,6 +574,10 @@ def remote_servers_support(support_type=SupportType.modify_plan,plan_modification=modify_plan,)+ elif delete_fixed_price_next_plan:+ support_view_request = SupportViewRequest(+ support_type=SupportType.delete_fixed_price_next_plan,+ )if support_view_request is not None:if remote_realm_support_request:try:diff --git a/templates/corporate/support/next_plan_details.html b/templates/corporate/support/next_plan_details.htmlindex 963a270e7f6..68aa61b3d32 100644--- a/templates/corporate/support/next_plan_details.html+++ b/templates/corporate/support/next_plan_details.html@@ -16,3 +16,11 @@{% endif %}{% endif %}<b>Estimated annual revenue</b>: ${{ dollar_amount(plan_data.estimated_next_plan_revenue) }}<br />+{% if plan_data.next_plan.fixed_price %}+<form method="POST">+ {{ csrf_input }}+ <input type="hidden" name="{{ remote_type }}" value="{{ remote_id }}" />+ <input type="hidden" name="delete_fixed_price_next_plan" value="true" />+ <button type="submit" class="delete-next-fixed-price-plan-button">Delete configured fixed price next plan</button>+</form>+{% endif %}diff --git a/templates/corporate/support/remote_realm_details.html b/templates/corporate/support/remote_realm_details.htmlindex 1f8e20ae579..103c74bf2df 100644--- a/templates/corporate/support/remote_realm_details.html+++ b/templates/corporate/support/remote_realm_details.html@@ -63,6 +63,8 @@{% set plan_data = support_data[remote_realm.id].plan_data %}{% set format_discount = format_discount %}{% set dollar_amount = dollar_amount %}+ {% set remote_id = remote_realm.id %}+ {% set remote_type = "remote_realm_id" %}{% include 'corporate/support/next_plan_details.html' %}{% endwith %}</div>diff --git a/templates/corporate/support/remote_server_support.html b/templates/corporate/support/remote_server_support.htmlindex eaf3c4160a6..b6e0493c707 100644--- a/templates/corporate/support/remote_server_support.html+++ b/templates/corporate/support/remote_server_support.html@@ -103,6 +103,8 @@{% set plan_data = remote_servers_support_data[remote_server.id].plan_data %}{% set format_discount = format_discount %}{% set dollar_amount = dollar_amount %}+ {% set remote_id = remote_server.id %}+ {% set remote_type = "remote_server_id" %}{% include 'corporate/support/next_plan_details.html' %}{% endwith %}</div>diff --git a/web/styles/portico/activity.css b/web/styles/portico/activity.cssindex 83eaef0211b..476e246e3d2 100644--- a/web/styles/portico/activity.css+++ b/web/styles/portico/activity.css@@ -170,6 +170,7 @@ tr.admin td:first-child {}}+.delete-next-fixed-price-plan-button,.approve-sponsorship-button,.support-search-button,.support-submit-button,@@ -228,6 +229,7 @@ tr.admin td:first-child {}}+.delete-next-fixed-price-plan-button,.delete-user-button,.scrub-realm-button {color: hsl(0deg 0% 100%);