models: Remove Realm.domain.

This commit is contained in:
Rishi Gupta 2017-03-13 16:51:51 -07:00 committed by Tim Abbott
parent b416587aab
commit 30024d0a8f
9 changed files with 31 additions and 25 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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',
),
]

View File

@ -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]

View File

@ -214,9 +214,7 @@ class BugdownTest(TestCase):
self.assertEqual(converted, '<p>Check out this file <a href="file:///Volumes/myserver/Users/Shared/pi.py" target="_blank" title="file:///Volumes/myserver/Users/Shared/pi.py">file:///Volumes/myserver/Users/Shared/pi.py</a></p>')
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']})

View File

@ -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

View File

@ -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"),