models: Add Stream.history_public_to_subscribers.

This commit adds a new field history_public_to_subscribers to the
Stream model, which serves a similar function to the old
settings.PRIVATE_STREAM_HISTORY_FOR_SUBSCRIBERS; we still use that
setting as the default value for new streams to avoid breaking
backwards-compatibility for those users before we are ready with an
actual UI for users to choose directly.

This also comes with a migration to set the value of the new field for
existing streams with an algorithm matching that used at runtime.

With significant changes by Tim Abbott.

This is an initial part of our efforts on #9232.
This commit is contained in:
Eeshan Garg
2018-04-26 20:30:26 -02:30
committed by Tim Abbott
parent 9729b1a4ad
commit 057ff9c91e
8 changed files with 270 additions and 26 deletions

View File

@@ -525,7 +525,8 @@ class ZulipTestCase(TestCase):
return open(fn).read()
def make_stream(self, stream_name: Text, realm: Optional[Realm]=None,
invite_only: Optional[bool]=False) -> Stream:
invite_only: Optional[bool]=False,
history_public_to_subscribers: Optional[bool]=False) -> Stream:
if realm is None:
realm = self.DEFAULT_REALM
@@ -534,6 +535,7 @@ class ZulipTestCase(TestCase):
realm=realm,
name=stream_name,
invite_only=invite_only,
history_public_to_subscribers=history_public_to_subscribers,
)
except IntegrityError: # nocoverage -- this is for bugs in the tests
raise Exception('''