コード例 #1
0
ファイル: streams.py プロジェクト: wbsabc/zulip
def update_default_stream_group_streams(
    request: HttpRequest,
    user_profile: UserProfile,
    group_id: int,
    op: str = REQ(),
    stream_names: List[str] = REQ(validator=check_list(check_string))
) -> None:
    group = access_default_stream_group_by_id(
        user_profile.realm,
        group_id,
    )
    streams = []
    for stream_name in stream_names:
        (stream, recipient,
         sub) = access_stream_by_name(user_profile, stream_name)
        streams.append(stream)

    if op == 'add':
        do_add_streams_to_default_stream_group(user_profile.realm, group,
                                               streams)
    elif op == 'remove':
        do_remove_streams_from_default_stream_group(user_profile.realm, group,
                                                    streams)
    else:
        return json_error(
            _('Invalid value for "op". Specify one of "add" or "remove".'))
    return json_success()
コード例 #2
0
def update_default_stream_group_info(request: HttpRequest, user_profile: UserProfile, group_id: int,
                                     new_group_name: str=REQ(validator=check_string, default=None),
                                     new_description: str=REQ(validator=check_string,
                                                              default=None)) -> None:
    if not new_group_name and not new_description:
        return json_error(_('You must pass "new_description" or "new_group_name".'))

    group = access_default_stream_group_by_id(user_profile.realm, group_id,)
    if new_group_name is not None:
        do_change_default_stream_group_name(user_profile.realm, group, new_group_name)
    if new_description is not None:
        do_change_default_stream_group_description(user_profile.realm, group, new_description)
    return json_success()
コード例 #3
0
ファイル: streams.py プロジェクト: gnprice/zulip
def update_default_stream_group_info(request: HttpRequest, user_profile: UserProfile, group_id: int,
                                     new_group_name: Text=REQ(validator=check_string, default=None),
                                     new_description: Text=REQ(validator=check_string,
                                                               default=None)) -> None:
    if not new_group_name and not new_description:
        return json_error(_('You must pass "new_description" or "new_group_name".'))

    group = access_default_stream_group_by_id(user_profile.realm, group_id,)
    if new_group_name is not None:
        do_change_default_stream_group_name(user_profile.realm, group, new_group_name)
    if new_description is not None:
        do_change_default_stream_group_description(user_profile.realm, group, new_description)
    return json_success()
コード例 #4
0
ファイル: streams.py プロジェクト: scrapcode/zulip
def update_default_stream_group_info(
    request: HttpRequest,
    user_profile: UserProfile,
    group_id: int,
    new_group_name: Optional[str] = REQ(default=None),
    new_description: Optional[str] = REQ(default=None),
) -> HttpResponse:
    if not new_group_name and not new_description:
        raise JsonableError(_('You must pass "new_description" or "new_group_name".'))

    group = access_default_stream_group_by_id(user_profile.realm, group_id)
    if new_group_name is not None:
        do_change_default_stream_group_name(user_profile.realm, group, new_group_name)
    if new_description is not None:
        do_change_default_stream_group_description(user_profile.realm, group, new_description)
    return json_success()
コード例 #5
0
ファイル: streams.py プロジェクト: gnprice/zulip
def update_default_stream_group_streams(request: HttpRequest, user_profile: UserProfile,
                                        group_id: int, op: Text=REQ(),
                                        stream_names: List[Text]=REQ(
                                            validator=check_list(check_string))) -> None:
    group = access_default_stream_group_by_id(user_profile.realm, group_id,)
    streams = []
    for stream_name in stream_names:
        (stream, recipient, sub) = access_stream_by_name(user_profile, stream_name)
        streams.append(stream)

    if op == 'add':
        do_add_streams_to_default_stream_group(user_profile.realm, group, streams)
    elif op == 'remove':
        do_remove_streams_from_default_stream_group(user_profile.realm, group, streams)
    else:
        return json_error(_('Invalid value for "op". Specify one of "add" or "remove".'))
    return json_success()
コード例 #6
0
def remove_default_stream_group(request: HttpRequest,
                                user_profile: UserProfile,
                                group_id: int) -> None:
    group = access_default_stream_group_by_id(user_profile.realm, group_id)
    do_remove_default_stream_group(user_profile.realm, group)
    return json_success()
コード例 #7
0
ファイル: streams.py プロジェクト: gnprice/zulip
def remove_default_stream_group(request: HttpRequest, user_profile: UserProfile,
                                group_id: int) -> None:
    group = access_default_stream_group_by_id(user_profile.realm, group_id)
    do_remove_default_stream_group(user_profile.realm, group)
    return json_success()