human
Complete this python program:
def can_edit_collection(handler):
assistant
#Here is the Python code you requested.

    """Decorator to check whether the user can edit collection.
    """
    def test_can_edit(self, collection_id, **kwargs):
        if (not self.user_id):
            raise base.UserFacingExceptions.NotLoggedInException
        collection_rights = rights_manager.get_collection_rights(collection_id)
        if (collection_rights is None):
            raise base.UserFacingExceptions.PageNotFoundException
        if rights_manager.check_can_edit_activity(self.user_id, self.actions, constants.ACTIVITY_TYPE_COLLECTION, collection_rights):
            return handler(self, collection_id, **kwargs)
        else:
            raise base.UserFacingExceptions.UnauthorizedUserException('You    do    not    have    credentials    to    edit    this    collection.')
    test_can_edit.__wrapped__ = True
    return test_can_edit