mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 03:11:54 +00:00
models: Add is_announcement_only to stream_dict in actions.py.
Adds `is_announcement_only` to `stream_dict`s in order to access the property in the frontend.
This commit is contained in:
committed by
Tim Abbott
parent
897ed17f0c
commit
295fcb8536
@@ -2300,6 +2300,7 @@ def notify_subscriptions_added(user_profile: UserProfile,
|
|||||||
stream_id=stream.id,
|
stream_id=stream.id,
|
||||||
in_home_view=subscription.in_home_view,
|
in_home_view=subscription.in_home_view,
|
||||||
invite_only=stream.invite_only,
|
invite_only=stream.invite_only,
|
||||||
|
is_announcement_only=stream.is_announcement_only,
|
||||||
color=subscription.color,
|
color=subscription.color,
|
||||||
email_address=encode_email_address(stream),
|
email_address=encode_email_address(stream),
|
||||||
desktop_notifications=subscription.desktop_notifications,
|
desktop_notifications=subscription.desktop_notifications,
|
||||||
@@ -3939,6 +3940,7 @@ def get_web_public_subs(realm: Realm) -> SubHelperT:
|
|||||||
{'name': stream.name,
|
{'name': stream.name,
|
||||||
'in_home_view': True,
|
'in_home_view': True,
|
||||||
'invite_only': False,
|
'invite_only': False,
|
||||||
|
'is_announcement_only': stream.is_announcement_only,
|
||||||
'color': get_next_color(),
|
'color': get_next_color(),
|
||||||
'desktop_notifications': True,
|
'desktop_notifications': True,
|
||||||
'audible_notifications': True,
|
'audible_notifications': True,
|
||||||
@@ -3980,7 +3982,7 @@ def gather_subscriptions_helper(user_profile: UserProfile,
|
|||||||
stream_ids.add(sub['stream_id'])
|
stream_ids.add(sub['stream_id'])
|
||||||
|
|
||||||
all_streams = get_active_streams(user_profile.realm).select_related(
|
all_streams = get_active_streams(user_profile.realm).select_related(
|
||||||
"realm").values("id", "name", "invite_only", "realm_id",
|
"realm").values("id", "name", "invite_only", "is_announcement_only", "realm_id",
|
||||||
"email_token", "description", "date_created")
|
"email_token", "description", "date_created")
|
||||||
|
|
||||||
stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids]
|
stream_dicts = [stream for stream in all_streams if stream['id'] in stream_ids]
|
||||||
@@ -4032,6 +4034,7 @@ def gather_subscriptions_helper(user_profile: UserProfile,
|
|||||||
stream_dict = {'name': stream["name"],
|
stream_dict = {'name': stream["name"],
|
||||||
'in_home_view': sub["in_home_view"],
|
'in_home_view': sub["in_home_view"],
|
||||||
'invite_only': stream["invite_only"],
|
'invite_only': stream["invite_only"],
|
||||||
|
'is_announcement_only': stream["is_announcement_only"],
|
||||||
'color': sub["color"],
|
'color': sub["color"],
|
||||||
'desktop_notifications': sub["desktop_notifications"],
|
'desktop_notifications': sub["desktop_notifications"],
|
||||||
'audible_notifications': sub["audible_notifications"],
|
'audible_notifications': sub["audible_notifications"],
|
||||||
@@ -4064,6 +4067,7 @@ def gather_subscriptions_helper(user_profile: UserProfile,
|
|||||||
if is_public or user_profile.is_realm_admin:
|
if is_public or user_profile.is_realm_admin:
|
||||||
stream_dict = {'name': stream['name'],
|
stream_dict = {'name': stream['name'],
|
||||||
'invite_only': stream['invite_only'],
|
'invite_only': stream['invite_only'],
|
||||||
|
'is_announcement_only': stream['is_announcement_only'],
|
||||||
'stream_id': stream['id'],
|
'stream_id': stream['id'],
|
||||||
'is_old_stream': is_old_stream(stream["date_created"]),
|
'is_old_stream': is_old_stream(stream["date_created"]),
|
||||||
'stream_weekly_traffic': get_average_weekly_stream_traffic(stream["id"],
|
'stream_weekly_traffic': get_average_weekly_stream_traffic(stream["id"],
|
||||||
|
|||||||
@@ -415,6 +415,7 @@ def apply_event(state: Dict[str, Any],
|
|||||||
stream_data['subscribers'] = []
|
stream_data['subscribers'] = []
|
||||||
stream_data['stream_weekly_traffic'] = 0
|
stream_data['stream_weekly_traffic'] = 0
|
||||||
stream_data['is_old_stream'] = False
|
stream_data['is_old_stream'] = False
|
||||||
|
stream_data['is_announcement_only'] = False
|
||||||
# Add stream to never_subscribed (if not invite_only)
|
# Add stream to never_subscribed (if not invite_only)
|
||||||
state['never_subscribed'].append(stream_data)
|
state['never_subscribed'].append(stream_data)
|
||||||
state['streams'].append(stream)
|
state['streams'].append(stream)
|
||||||
|
|||||||
@@ -1926,6 +1926,7 @@ class EventsRegisterTest(ZulipTestCase):
|
|||||||
('description', check_string),
|
('description', check_string),
|
||||||
('email_address', check_string),
|
('email_address', check_string),
|
||||||
('invite_only', check_bool),
|
('invite_only', check_bool),
|
||||||
|
('is_announcement_only', check_bool),
|
||||||
('in_home_view', check_bool),
|
('in_home_view', check_bool),
|
||||||
('name', check_string),
|
('name', check_string),
|
||||||
('desktop_notifications', check_bool),
|
('desktop_notifications', check_bool),
|
||||||
|
|||||||
Reference in New Issue
Block a user