mirror of https://github.com/zulip/zulip.git
models: Check enable_spectator_access value in web_public_streams_enabled.
This commit changes web_public_streams_enabled to return False if realm.enable_spectator_access is False. This is added so that creating web-public streams is not allowed if enable_spectator_access is False.
This commit is contained in:
parent
ad99b4fac9
commit
56a8443f05
|
@ -896,6 +896,9 @@ class Realm(models.Model):
|
|||
# target every open Internet service that can host files.
|
||||
return False
|
||||
|
||||
if not self.enable_spectator_access:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def has_web_public_streams(self) -> bool:
|
||||
|
@ -909,10 +912,11 @@ class Realm(models.Model):
|
|||
def allow_web_public_streams_access(self) -> bool:
|
||||
"""
|
||||
If any of the streams in the realm is web
|
||||
public and `enable_spectator_access` is True,
|
||||
public and `enable_spectator_access` and
|
||||
settings.WEB_PUBLIC_STREAMS_ENABLED is True,
|
||||
then the Realm is web public.
|
||||
"""
|
||||
return self.enable_spectator_access and self.has_web_public_streams()
|
||||
return self.has_web_public_streams()
|
||||
|
||||
|
||||
post_save.connect(flush_realm, sender=Realm)
|
||||
|
|
|
@ -847,6 +847,14 @@ class RealmTest(ZulipTestCase):
|
|||
self.assertEqual(realm.has_web_public_streams(), False)
|
||||
self.assertEqual(realm.web_public_streams_enabled(), False)
|
||||
|
||||
realm.enable_spectator_access = False
|
||||
realm.save()
|
||||
self.assertEqual(realm.has_web_public_streams(), False)
|
||||
self.assertEqual(realm.web_public_streams_enabled(), False)
|
||||
|
||||
realm.enable_spectator_access = True
|
||||
realm.save()
|
||||
|
||||
# Convert Rome to a public stream
|
||||
rome.is_web_public = False
|
||||
rome.save()
|
||||
|
|
Loading…
Reference in New Issue