digest: Turn off digest_emails_enabled flag for realms by default.

This commit is contained in:
Puneeth Chaganti 2019-05-08 11:28:26 +05:30 committed by Tim Abbott
parent dd28413c4a
commit d474a41c03
3 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-08 05:42
from __future__ import unicode_literals
from django.db import migrations, models
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def disable_realm_digest_emails_enabled(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
Realm = apps.get_model("zerver", "Realm")
realms = Realm.objects.filter(digest_emails_enabled=True)
realms.update(digest_emails_enabled=False)
class Migration(migrations.Migration):
dependencies = [
('zerver', '0218_remove_create_stream_by_admins_only'),
]
operations = [
migrations.AlterField(
model_name='realm',
name='digest_emails_enabled',
field=models.BooleanField(default=False),
),
migrations.RunPython(disable_realm_digest_emails_enabled,
reverse_code=migrations.RunPython.noop)
]

View File

@ -188,7 +188,7 @@ class Realm(models.Model):
inline_url_embed_preview = models.BooleanField(default=True) # type: bool inline_url_embed_preview = models.BooleanField(default=True) # type: bool
# Whether digest emails are enabled for the organization. # Whether digest emails are enabled for the organization.
digest_emails_enabled = models.BooleanField(default=True) # type: bool digest_emails_enabled = models.BooleanField(default=False) # type: bool
# Day of the week on which the digest is sent (default: Tuesday). # Day of the week on which the digest is sent (default: Tuesday).
digest_weekday = models.SmallIntegerField(default=1) # type: int digest_weekday = models.SmallIntegerField(default=1) # type: int

View File

@ -76,6 +76,8 @@ class TestDigestEmailMessages(ZulipTestCase):
@override_settings(SEND_DIGEST_EMAILS=True) @override_settings(SEND_DIGEST_EMAILS=True)
def test_inactive_users_queued_for_digest(self, mock_django_timezone: mock.MagicMock, def test_inactive_users_queued_for_digest(self, mock_django_timezone: mock.MagicMock,
mock_queue_digest_recipient: mock.MagicMock) -> None: mock_queue_digest_recipient: mock.MagicMock) -> None:
# Turn on realm digest emails for all realms
Realm.objects.update(digest_emails_enabled=True)
cutoff = timezone_now() cutoff = timezone_now()
# Test Tuesday # Test Tuesday
mock_django_timezone.return_value = datetime.datetime(year=2016, month=1, day=5) mock_django_timezone.return_value = datetime.datetime(year=2016, month=1, day=5)
@ -113,6 +115,8 @@ class TestDigestEmailMessages(ZulipTestCase):
@override_settings(SEND_DIGEST_EMAILS=True) @override_settings(SEND_DIGEST_EMAILS=True)
def test_active_users_not_enqueued(self, mock_django_timezone: mock.MagicMock, def test_active_users_not_enqueued(self, mock_django_timezone: mock.MagicMock,
mock_enough_traffic: mock.MagicMock) -> None: mock_enough_traffic: mock.MagicMock) -> None:
# Turn on realm digest emails for all realms
Realm.objects.update(digest_emails_enabled=True)
cutoff = timezone_now() cutoff = timezone_now()
# A Tuesday # A Tuesday
mock_django_timezone.return_value = datetime.datetime(year=2016, month=1, day=5) mock_django_timezone.return_value = datetime.datetime(year=2016, month=1, day=5)
@ -148,6 +152,8 @@ class TestDigestEmailMessages(ZulipTestCase):
@override_settings(SEND_DIGEST_EMAILS=True) @override_settings(SEND_DIGEST_EMAILS=True)
def test_no_email_digest_for_bots(self, mock_django_timezone: mock.MagicMock, def test_no_email_digest_for_bots(self, mock_django_timezone: mock.MagicMock,
mock_queue_digest_recipient: mock.MagicMock) -> None: mock_queue_digest_recipient: mock.MagicMock) -> None:
# Turn on realm digest emails for all realms
Realm.objects.update(digest_emails_enabled=True)
cutoff = timezone_now() cutoff = timezone_now()
# A Tuesday # A Tuesday
mock_django_timezone.return_value = datetime.datetime(year=2016, month=1, day=5) mock_django_timezone.return_value = datetime.datetime(year=2016, month=1, day=5)