zilencer: Remove long-obsolete Deployment model.

This was a precursor to RemoteZulipServer, which is no longer used for
anything, and was cluttering the codebase.
This commit is contained in:
Tim Abbott 2017-10-11 23:26:54 -07:00
parent 339e206c90
commit 66a3f514d4
8 changed files with 26 additions and 68 deletions

View File

@ -32,7 +32,7 @@ class Command(ZulipBaseCommand):
* Users' passwords and API keys (users will need to use SSO or reset password)
* Mobile tokens for APNS/GCM (users will need to reconnect their mobile devices)
* ScheduledEmail (Not relevant on a new server)
* Deployment (Unused)
* RemoteZulipServer (Unlikely to be migrated)
* third_party_api_results cache (this means rerending all old
messages could be expensive)

View File

@ -9,7 +9,6 @@ from zerver.decorator import JsonableError
from zerver.lib.test_runner import slow
from zerver.lib.cache import get_stream_cache_key, cache_delete
from zerver.lib.str_utils import force_text
from zilencer.models import Deployment
from zerver.lib.addressee import Addressee
@ -181,17 +180,6 @@ class TestCrossRealmPMs(ZulipTestCase):
RealmDomain.objects.create(realm=realm, domain=domain)
return realm
def setUp(self):
# type: () -> None
dep = Deployment()
dep.base_api_url = "https://zulip.com/api/"
dep.base_site_url = "https://zulip.com/"
# We need to save the object before we can access
# the many-to-many relationship 'realms'
dep.save()
dep.realms = [get_realm("zulip")]
dep.save()
def create_user(self, email):
# type: (Text) -> UserProfile
subdomain = email.split("@")[1]
@ -203,13 +191,9 @@ class TestCrossRealmPMs(ZulipTestCase):
'support@3.example.com'])
def test_realm_scenarios(self):
# type: () -> None
r1 = self.make_realm('1.example.com')
self.make_realm('1.example.com')
r2 = self.make_realm('2.example.com')
r3 = self.make_realm('3.example.com')
deployment = Deployment.objects.filter()[0]
deployment.realms.add(r1)
deployment.realms.add(r2)
deployment.realms.add(r3)
self.make_realm('3.example.com')
def assert_message_received(to_user, from_user):
# type: (UserProfile, UserProfile) -> None

View File

@ -12,7 +12,6 @@ from zerver.lib.test_helpers import MockLDAP
from confirmation.models import Confirmation, create_confirmation_link, MultiuseInvite, \
generate_key, confirmation_url
from zilencer.models import Deployment
from zerver.forms import HomepageForm, WRONG_SUBDOMAIN_ERROR
from zerver.lib.actions import do_change_password, gather_subscriptions

View File

@ -24,7 +24,6 @@ from zerver.lib.actions import (
do_delete_old_unclaimed_attachments,
internal_send_private_message,
)
from zilencer.models import Deployment
from zerver.views.upload import upload_file_backend
@ -451,19 +450,8 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
user2_email = 'test-og-bot@zulip.com'
user3_email = 'other-user@uploadtest.example.com'
dep = Deployment()
dep.base_api_url = "https://zulip.com/api/"
dep.base_site_url = "https://zulip.com/"
# We need to save the object before we can access
# the many-to-many relationship 'realms'
dep.save()
dep.realms = [get_realm("zulip")]
dep.save()
r1 = Realm.objects.create(string_id=test_subdomain, invite_required=False)
RealmDomain.objects.create(realm=r1, domain=test_subdomain)
deployment = Deployment.objects.filter()[0]
deployment.realms.add(r1)
create_user(user1_email, test_subdomain)
create_user(user2_email, 'zulip')

View File

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-10-12 06:27
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('zilencer', '0003_add_default_for_remotezulipserver_last_updated_field'),
]
operations = [
migrations.RemoveField(
model_name='deployment',
name='realms',
),
migrations.DeleteModel(
name='Deployment',
),
]

View File

@ -22,30 +22,3 @@ class RemotePushDeviceToken(zerver.models.AbstractPushDeviceToken):
server = models.ForeignKey(RemoteZulipServer) # type: RemoteZulipServer
# The user id on the remote server for this device device this is
user_id = models.BigIntegerField() # type: int
class Deployment(models.Model):
realms = models.ManyToManyField(zerver.models.Realm,
related_name="_deployments") # type: Manager
is_active = models.BooleanField(default=True) # type: bool
# TODO: This should really become the public portion of a keypair, and
# it should be settable only with an initial bearer "activation key"
api_key = models.CharField(max_length=32, null=True) # type: Optional[Text]
base_api_url = models.CharField(max_length=128) # type: Text
base_site_url = models.CharField(max_length=128) # type: Text
@property
def endpoints(self):
# type: () -> Dict[str, Text]
return {'base_api_url': self.base_api_url, 'base_site_url': self.base_site_url}
@property
def name(self):
# type: () -> Text
# TODO: This only does the right thing for prod because prod authenticates to
# staging with the zulip.com deployment key, while staging is technically the
# deployment for the zulip.com realm.
# This also doesn't necessarily handle other multi-realm deployments correctly
return self.realms.order_by('pk')[0].domain

View File

@ -10,8 +10,6 @@ i18n_urlpatterns = [] # type: Any
# Zilencer views following the REST API style
v1_api_and_json_patterns = [
url('^deployment/report_error$', rest_dispatch,
{'POST': 'zerver.views.report.report_error'}),
url('^remotes/push/register$', rest_dispatch,
{'POST': 'zilencer.views.remote_server_register_push'}),
url('^remotes/push/unregister$', rest_dispatch,

View File

@ -3,10 +3,9 @@ from django.utils.translation import ugettext as _
from django.utils import timezone
from django.http import HttpResponse, HttpRequest
from zilencer.models import Deployment, RemotePushDeviceToken, RemoteZulipServer
from zilencer.models import RemotePushDeviceToken, RemoteZulipServer
from zerver.decorator import has_request_variables, REQ
from zerver.lib.error_notify import do_report_error
from zerver.lib.push_notifications import send_android_push_notification, \
send_apple_push_notification
from zerver.lib.request import JsonableError
@ -29,11 +28,6 @@ def validate_bouncer_token_request(entity, token, kind):
validate_entity(entity)
validate_token(token, kind)
@has_request_variables
def report_error(request, deployment, type=REQ(), report=REQ(validator=check_dict([]))):
# type: (HttpRequest, Deployment, Text, Dict[str, Any]) -> HttpResponse
return do_report_error(deployment.name, type, report)
@has_request_variables
def remote_server_register_push(request, entity, user_id=REQ(),
token=REQ(), token_kind=REQ(validator=check_int), ios_app_id=None):