diff --git a/analytics/management/commands/populate_analytics_db.py b/analytics/management/commands/populate_analytics_db.py index 3d5cece9d6..cfcb697ad3 100644 --- a/analytics/management/commands/populate_analytics_db.py +++ b/analytics/management/commands/populate_analytics_db.py @@ -57,8 +57,7 @@ class Command(BaseCommand): installation_time = timezone.now() - timedelta(days=self.DAYS_OF_DATA) last_end_time = floor_to_day(timezone.now()) realm = Realm.objects.create( - string_id='analytics', name='Analytics', domain='analytics.ds', - date_created=installation_time) + string_id='analytics', name='Analytics', date_created=installation_time) shylock = self.create_user('shylock@analytics.ds', 'Shylock', True, installation_time, realm) def insert_fixture_data(stat, fixture_data, table): diff --git a/analytics/tests/test_counts.py b/analytics/tests/test_counts.py index df34d3d9de..3af3f24bec 100644 --- a/analytics/tests/test_counts.py +++ b/analytics/tests/test_counts.py @@ -34,8 +34,7 @@ class AnalyticsTestCase(TestCase): def setUp(self): # type: () -> None self.default_realm = Realm.objects.create( - string_id='realmtest', name='Realm Test', - domain='test.analytics', date_created=self.TIME_ZERO - 2*self.DAY) + string_id='realmtest', name='Realm Test', date_created=self.TIME_ZERO - 2*self.DAY) # used to generate unique names in self.create_* self.name_counter = 100 # used as defaults in self.assertCountEquals @@ -253,7 +252,7 @@ class TestCountStats(AnalyticsTestCase): # the queries). self.second_realm = Realm.objects.create( string_id='second-realm', name='Second Realm', - domain='second.analytics', date_created=self.TIME_ZERO-2*self.DAY) + date_created=self.TIME_ZERO-2*self.DAY) for minutes_ago in [0, 1, 61, 60*24+1]: creation_time = self.TIME_ZERO - minutes_ago*self.MINUTE user = self.create_user(email='user-%s@second.analytics' % (minutes_ago,), @@ -269,7 +268,7 @@ class TestCountStats(AnalyticsTestCase): # messages_* CountStats self.no_message_realm = Realm.objects.create( string_id='no-message-realm', name='No Message Realm', - domain='no.message', date_created=self.TIME_ZERO-2*self.DAY) + date_created=self.TIME_ZERO-2*self.DAY) self.create_user(realm=self.no_message_realm) self.create_stream_with_recipient(realm=self.no_message_realm) # This huddle should not show up anywhere @@ -504,7 +503,7 @@ class TestDoIncrementLoggingStat(AnalyticsTestCase): # the appropriate *Count table, and that using a different zerver_object # results in a new row being created self.current_property = 'test' - second_realm = Realm.objects.create(string_id='moo', name='moo', domain='moo') + second_realm = Realm.objects.create(string_id='moo', name='moo') stat = LoggingCountStat('test', RealmCount, CountStat.DAY) do_increment_logging_stat(self.default_realm, stat, None, self.TIME_ZERO) do_increment_logging_stat(second_realm, stat, None, self.TIME_ZERO) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 5842f1e8b5..a02bf84557 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -2058,10 +2058,7 @@ def do_create_realm(string_id, name, restricted_to_domain=None, kwargs['invite_required'] = invite_required if org_type is not None: kwargs['org_type'] = org_type - # General a value for domain that we control - domain = string_id + "." + settings.EXTERNAL_HOST - realm = Realm(string_id=string_id, name=name, - domain=domain, **kwargs) + realm = Realm(string_id=string_id, name=name, **kwargs) realm.save() # Create stream once Realm object has been saved diff --git a/zerver/management/commands/initialize_voyager_db.py b/zerver/management/commands/initialize_voyager_db.py index d5f1733d4c..c61c898b54 100644 --- a/zerver/management/commands/initialize_voyager_db.py +++ b/zerver/management/commands/initialize_voyager_db.py @@ -36,8 +36,7 @@ class Command(BaseCommand): def handle(self, *args, **options): # type: (*Any, **Any) -> None - realm = Realm.objects.create(string_id=settings.INTERNAL_BOT_DOMAIN.split('.')[0], - domain=settings.INTERNAL_BOT_DOMAIN) + realm = Realm.objects.create(string_id=settings.INTERNAL_BOT_DOMAIN.split('.')[0]) names = [(settings.FEEDBACK_BOT_NAME, settings.FEEDBACK_BOT)] create_users(realm, names, bot_type=UserProfile.DEFAULT_BOT) diff --git a/zerver/migrations/0068_remove_realm_domain.py b/zerver/migrations/0068_remove_realm_domain.py new file mode 100644 index 0000000000..b1f517b79f --- /dev/null +++ b/zerver/migrations/0068_remove_realm_domain.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-03-13 23:32 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('zerver', '0067_archived_models'), + ] + + operations = [ + migrations.RemoveField( + model_name='realm', + name='domain', + ), + ] diff --git a/zerver/models.py b/zerver/models.py index c872d26f77..a806cc5e3c 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -103,11 +103,6 @@ def get_realm_emoji_cache_key(realm): return u'realm_emoji:%s' % (realm.id,) class Realm(ModelReprMixin, models.Model): - # domain is a domain in the Internet sense. It must be structured like a - # valid email domain. We use is to restrict access, identify bots, etc. - domain = models.CharField(max_length=40, db_index=True, unique=True) # type: Text - # name is the user-visible identifier for the realm. It has no required - # structure. AUTHENTICATION_FLAGS = [u'Google', u'Email', u'GitHub', u'LDAP', u'Dev', u'RemoteUser'] name = models.CharField(max_length=40, null=True) # type: Optional[Text] diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py index 026c9a52bf..2bdac9389d 100644 --- a/zerver/tests/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -214,9 +214,7 @@ class BugdownTest(TestCase): self.assertEqual(converted, '

Check out this file file:///Volumes/myserver/Users/Shared/pi.py

') with self.settings(ENABLE_FILE_LINKS=False): - realm = Realm.objects.create( - domain='file_links_test.example.com', - string_id='file_links_test') + realm = Realm.objects.create(string_id='file_links_test') bugdown.make_md_engine( realm.id, {'realm_filters': [[], u'file_links_test.example.com'], 'realm': [u'file_links_test.example.com', 'Realm name']}) diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index 3a99bcf89e..2fec65808b 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -148,7 +148,7 @@ class TopicHistoryTest(ZulipTestCase): class TestCrossRealmPMs(ZulipTestCase): def make_realm(self, domain): # type: (Text) -> Realm - realm = Realm.objects.create(string_id=domain, domain=domain, invite_required=False) + realm = Realm.objects.create(string_id=domain, invite_required=False) RealmAlias.objects.create(realm=realm, domain=domain) return realm diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py index aea8baed06..1bffcb93ec 100644 --- a/zilencer/management/commands/populate_db.py +++ b/zilencer/management/commands/populate_db.py @@ -124,12 +124,12 @@ class Command(BaseCommand): # welcome-bot (needed for do_create_realm) hasn't been created yet zulip_realm = Realm.objects.create( string_id="zulip", name="Zulip Dev", restricted_to_domain=True, - invite_required=False, org_type=Realm.CORPORATE, domain="zulip.com") + invite_required=False, org_type=Realm.CORPORATE) RealmAlias.objects.create(realm=zulip_realm, domain="zulip.com") if options["test_suite"]: mit_realm = Realm.objects.create( string_id="zephyr", name="MIT", restricted_to_domain=True, - invite_required=False, org_type=Realm.CORPORATE, domain="mit.edu") + invite_required=False, org_type=Realm.CORPORATE) RealmAlias.objects.create(realm=mit_realm, domain="mit.edu") # Create test Users (UserProfiles are automatically created, @@ -414,7 +414,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, domain="simple.com") + invite_required=False, org_type=Realm.COMMUNITY) names = [ ("alice", "alice@example.com"),