streams: Allow stream admin to update and deactivate streams.

The new Stream administrator role is allowed to manage a stream they
administer, including:
* Setting properties like name, description, privacy and post-policy.
* Removing subscribers
* Deactivating the stream

The access_stream_for_delete_or_update is modified and is used only
to get objects from database and further checks for administrative
rights is done by check_stream_access_for_delete_or_update.

We have also added a new exception class StreamAdministratorRequired.
This commit is contained in:
sahil839
2020-07-13 19:43:28 +05:30
committed by Tim Abbott
parent 78da9fd3ab
commit ca1a8ac78f
4 changed files with 286 additions and 78 deletions

View File

@@ -224,6 +224,18 @@ class OrganizationOwnerRequired(JsonableError):
def msg_format() -> str:
return OrganizationOwnerRequired.OWNER_REQUIRED_MESSAGE
class StreamAdministratorRequired(JsonableError):
code: ErrorCode = ErrorCode.UNAUTHORIZED_PRINCIPAL
ADMIN_REQUIRED_MESSAGE = _("Must be an organization or stream administrator")
def __init__(self) -> None:
super().__init__(self.ADMIN_REQUIRED_MESSAGE)
@staticmethod
def msg_format() -> str:
return StreamAdministratorRequired.ADMIN_REQUIRED_MESSAGE
class MarkdownRenderingException(Exception):
pass