mirror of https://github.com/zulip/zulip.git
support: Correctly show Unspecified org type at /activity/support.
Because the org type is marked as "hidden" the HTML was being generated for orgs with Unspecified .org_type with no <option> selected, meaning it was displayed on the page using the first <option> in the list (Business). The /support endpoint should ignore the "hidden" property, since there's no reason not to - we only want to hide this org type from regular users during Org registration.
This commit is contained in:
parent
e68fb802f4
commit
30c26b9510
|
@ -8,7 +8,11 @@ from django.utils.timezone import now as timezone_now
|
|||
from corporate.lib.stripe import add_months, update_sponsorship_status
|
||||
from corporate.models import Customer, CustomerPlan, LicenseLedger, get_customer_by_realm
|
||||
from zerver.actions.invites import do_create_multiuse_invite_link
|
||||
from zerver.actions.realm_settings import do_send_realm_reactivation_email, do_set_realm_property
|
||||
from zerver.actions.realm_settings import (
|
||||
do_change_realm_org_type,
|
||||
do_send_realm_reactivation_email,
|
||||
do_set_realm_property,
|
||||
)
|
||||
from zerver.lib.test_classes import ZulipTestCase
|
||||
from zerver.lib.test_helpers import reset_emails_in_zulip_realm
|
||||
from zerver.models import (
|
||||
|
@ -337,6 +341,28 @@ class TestSupportEndpoint(ZulipTestCase):
|
|||
self.assertEqual(get_org_type_display_name(Realm.ORG_TYPES["business"]["id"]), "Business")
|
||||
self.assertEqual(get_org_type_display_name(883), "")
|
||||
|
||||
def test_unspecified_org_type_correctly_displayed(self) -> None:
|
||||
"""
|
||||
Unspecified org type is special in that it is marked to not be shown
|
||||
on the registration page (because organitions are not meant to be able to choose it),
|
||||
but should be correctly shown at the /support endpoint.
|
||||
"""
|
||||
realm = get_realm("zulip")
|
||||
|
||||
do_change_realm_org_type(realm, 0, acting_user=None)
|
||||
self.assertEqual(realm.org_type, 0)
|
||||
|
||||
self.login("iago")
|
||||
|
||||
result = self.client_get("/activity/support", {"q": "zulip"}, subdomain="zulip")
|
||||
self.assert_in_success_response(
|
||||
[
|
||||
f'<input type="hidden" name="realm_id" value="{realm.id}"',
|
||||
'<option value="0" selected>',
|
||||
],
|
||||
result,
|
||||
)
|
||||
|
||||
@mock.patch("analytics.views.support.update_billing_method_of_current_plan")
|
||||
def test_change_billing_method(self, m: mock.Mock) -> None:
|
||||
cordelia = self.example_user("cordelia")
|
||||
|
|
|
@ -53,11 +53,9 @@
|
|||
<input type="hidden" name="realm_id" value="{{ realm.id }}" />
|
||||
<select name="org_type" id="org_type">
|
||||
{% for realm_type in sorted_realm_types %}
|
||||
{% if not realm_type.hidden %}
|
||||
<option value="{{ realm_type.id }}" {% if realm.org_type == realm_type.id %}selected{% endif %}>
|
||||
{{ _(realm_type.name) }}
|
||||
</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="submit" class="btn btn-default support-submit-button">Update</button>
|
||||
|
|
Loading…
Reference in New Issue