models: Change default org_type to CORPORATE.

Once we implement org_type-specific features, it'll be easy to change a
corporate realm to a community realm, but hard to go the other way. The main
difference (the main thing that makes migrating from a community realm to a
corporate realm hard) is that you'd have to make everyone sign another terms
of service.
This commit is contained in:
Rishi Gupta 2017-06-26 14:58:50 -07:00 committed by Greg Price
parent 4327402d57
commit 36cd122905
7 changed files with 32 additions and 12 deletions

View File

@ -60,7 +60,7 @@ class RegistrationForm(forms.Form):
realm_subdomain = forms.CharField(max_length=Realm.MAX_REALM_SUBDOMAIN_LENGTH, required=False)
realm_org_type = forms.ChoiceField(((Realm.COMMUNITY, 'Community'),
(Realm.CORPORATE, 'Corporate')),
initial=Realm.COMMUNITY, required=False)
initial=Realm.CORPORATE, required=False)
def __init__(self, *args, **kwargs):
# type: (*Any, **Any) -> None

View File

@ -295,7 +295,7 @@ class ZulipTestCase(TestCase):
return self.submit_reg_form_for_user(email, password)
def submit_reg_form_for_user(self, email, password, realm_name="Zulip Test",
realm_subdomain="zuliptest", realm_org_type=Realm.COMMUNITY,
realm_subdomain="zuliptest", realm_org_type=Realm.CORPORATE,
from_confirmation='', full_name=None, timezone=u'', **kwargs):
# type: (Text, Text, Optional[Text], Optional[Text], int, Optional[Text], Optional[Text], Optional[Text], **Any) -> HttpResponse
"""

View File

@ -36,14 +36,14 @@ Usage: ./manage.py create_realm --string_id=acme --name='Acme'"""
dest='org_type',
action="store_const",
const=Realm.CORPORATE,
help='Is a corporate org_type')
default=None,
help='Is a corporate org_type. Is the default.')
parser.add_argument('--community',
dest='org_type',
action="store_const",
const=Realm.COMMUNITY,
default=None,
help='Is a community org_type. Is the default.')
help='Is a community org_type.')
def handle(self, *args, **options):
# type: (*Any, **Any) -> None

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-06-26 21:56
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('zerver', '0085_fix_bots_with_none_bot_type'),
]
operations = [
migrations.AlterField(
model_name='realm',
name='org_type',
field=models.PositiveSmallIntegerField(default=1),
),
]

View File

@ -135,7 +135,7 @@ class Realm(ModelReprMixin, models.Model):
# Valid org_types are {CORPORATE, COMMUNITY}
CORPORATE = 1
COMMUNITY = 2
org_type = models.PositiveSmallIntegerField(default=COMMUNITY) # type: int
org_type = models.PositiveSmallIntegerField(default=CORPORATE) # type: int
date_created = models.DateTimeField(default=timezone_now) # type: datetime.datetime
notifications_stream = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE) # type: Optional[Stream]

View File

@ -911,7 +911,7 @@ class RealmCreationTest(ZulipTestCase):
self.assertEqual(get_user(email, realm).realm, realm)
# Check defaults
self.assertEqual(realm.org_type, Realm.COMMUNITY)
self.assertEqual(realm.org_type, Realm.CORPORATE)
self.assertEqual(realm.restricted_to_domain, False)
self.assertEqual(realm.invite_required, True)
@ -1132,7 +1132,7 @@ class UserSignUpTest(ZulipTestCase):
'realm_name': 'Zulip Test',
'realm_subdomain': 'zuliptest',
'key': find_key_by_email(email),
'realm_org_type': Realm.COMMUNITY,
'realm_org_type': Realm.CORPORATE,
'terms': True})
# User should now be logged in.
@ -1167,7 +1167,7 @@ class UserSignUpTest(ZulipTestCase):
'realm_name': 'Zulip Test',
'realm_subdomain': 'zuliptest',
'key': find_key_by_email(email),
'realm_org_type': Realm.COMMUNITY,
'realm_org_type': Realm.CORPORATE,
'terms': True,
'from_confirmation': '1'})
self.assert_in_success_response(["You're almost there."], result)
@ -1199,7 +1199,7 @@ class UserSignUpTest(ZulipTestCase):
'realm_name': 'Zulip Test',
'realm_subdomain': 'zuliptest',
'key': find_key_by_email(email),
'realm_org_type': Realm.COMMUNITY,
'realm_org_type': Realm.CORPORATE,
'terms': True,
'full_name': "New Guy",
'from_confirmation': '1'})
@ -1240,7 +1240,7 @@ class UserSignUpTest(ZulipTestCase):
'realm_name': 'Zulip Test',
'realm_subdomain': 'zuliptest',
'key': find_key_by_email(email),
'realm_org_type': Realm.COMMUNITY,
'realm_org_type': Realm.CORPORATE,
'terms': True})
mock_error.assert_called_once()
self.assertEqual(result.status_code, 302)

View File

@ -430,7 +430,7 @@ def create_simple_community_realm():
# type: () -> None
simple_realm = Realm.objects.create(
string_id="simple", name="Simple Realm", restricted_to_domain=False,
invite_required=False, org_type=Realm.COMMUNITY)
invite_required=False, org_type=Realm.CORPORATE)
names = [
("alice", "alice@example.com"),