Beispiel #1
0
    def test_utils(self):
        portal = self.portal
        catalog = self.portal.portal_catalog

        # Creat new use and log in
        self.create_user("user1", "secret")
        self.login(name="user1")

        # Create some chatrooms (of which user1 will be owner)
        for i in range(0, 3):
            chatroom = createContentInContainer(
                portal, "babble.client.chatroom", checkConstraints=False, title="Chatroom %d" % i
            )

        rooms = utils.get_chat_rooms(portal)
        self.assertEquals(len(rooms), 3)

        # Create new user
        self.loginAsPortalOwner()
        self.create_user("user2", "secret")
        self.login(name="user2")

        # This user doesn't have local roles so should not get the rooms
        rooms = utils.get_chat_rooms(portal)
        self.assertEquals(len(rooms), 0)

        # Even if this user is a site Administrators they should not
        self.loginAsPortalOwner()
        portal_groups = portal.portal_groups
        portal_groups.addPrincipalToGroup("user2", "Administrators")
        self.login(name="user2")

        rooms = utils.get_chat_rooms(portal)
        self.assertEquals(len(rooms), 0)

        # Check that they do if a local role is added.
        chatroom = portal["chatroom-1"]
        chatroom.manage_addLocalRoles("user2", ("Reader",))
        chatroom.reindexObject()
        rooms = utils.get_chat_rooms(portal)
        self.assertEquals(len(rooms), 1)
Beispiel #2
0
    def render_chat_box(self, chat_id, box_id, tzoffset):
        """ """
        if chat_id == 'actionbar_babble_online_contacts':
            online_users = utils.get_online_members(self.context)
            template = ViewPageTemplateFile('templates/onlinecontacts.pt')
            return template(self, online_users=online_users, chat_id=chat_id, box_id=box_id)

        elif chat_id == 'actionbar_babble_chat_rooms':
            chatrooms = utils.get_chat_rooms(self.context)  
            template = ViewPageTemplateFile('templates/chatrooms.pt')
            return template(self, chatrooms=chatrooms, chat_id=chat_id, box_id=box_id)

        else:
            return super(BabbleChatBox, self).render_chat_box(chat_id, box_id, tzoffset)
Beispiel #3
0
 def get_chat_rooms(self):
     return utils.get_chat_rooms(self.context)