예제 #1
0
    def test_mark_read(self):
        uapi = UserApi(None)
        groups = [GroupApi(None).get_one(Group.TIM_USER),
                  GroupApi(None).get_one(Group.TIM_MANAGER),
                  GroupApi(None).get_one(Group.TIM_ADMIN)]
        user_a = uapi.create_user(email='this.is@user',
                                 groups=groups, save_now=True)
        user_b = uapi.create_user(email='*****@*****.**',
                                 groups=groups, save_now=True)

        wapi = WorkspaceApi(user_a)
        workspace = wapi.create_workspace(
            'test workspace',
            save_now=True)

        role_api = RoleApi(user_a)
        role_api.create_one(user_b, workspace, UserRoleInWorkspace.READER, False)
        cont_api_a = ContentApi(user_a)
        cont_api_b = ContentApi(user_b)

        page_1 = cont_api_a.create(ContentType.Page, workspace, None,
                                   'this is a page', do_save=True)

        for rev in page_1.revisions:
            eq_(user_b not in rev.read_by.keys(), True)

        cont_api_b.mark_read(page_1)

        for rev in page_1.revisions:
            eq_(user_b in rev.read_by.keys(), True)
예제 #2
0
파일: __init__.py 프로젝트: buxx/tracim
    def put_read(self, item_id):
        item_id = int(item_id)
        content_api = ContentApi(tmpl_context.current_user, True, True) # Here we do not filter deleted items
        item = content_api.get_one(item_id, self._item_type, tmpl_context.workspace)

        item_url = self._std_url.format(item.workspace_id, item.parent_id, item.content_id)

        try:
            msg = _('{} marked as read.').format(self._item_type_label)
            content_api.mark_read(item)

            tg.flash(msg, CST.STATUS_OK)
            tg.redirect(item_url)

        except ValueError as e:
            logger.debug(self, 'Exception: {}'.format(e.__str__))
            msg = _('{} not marked as read: {}').format(self._item_type_label, str(e))
            tg.flash(msg, CST.STATUS_ERROR)
            tg.redirect(item_url)
예제 #3
0
파일: __init__.py 프로젝트: qyqx/tracim
    def put_read(self, item_id):
        item_id = int(item_id)
        content_api = ContentApi(tmpl_context.current_user, True, True) # Here we do not filter deleted items
        item = content_api.get_one(item_id, self._item_type, tmpl_context.workspace)

        item_url = self._std_url.format(item.workspace_id, item.parent_id, item.content_id)

        try:
            msg = _('{} marked as read.').format(self._item_type_label)
            content_api.mark_read(item)

            tg.flash(msg, CST.STATUS_OK)
            tg.redirect(item_url)

        except ValueError as e:
            logger.debug(self, 'Exception: {}'.format(e.__str__))
            msg = _('{} not marked as read: {}').format(self._item_type_label, str(e))
            tg.flash(msg, CST.STATUS_ERROR)
            tg.redirect(item_url)
예제 #4
0
    def test_mark_read(self):
        uapi = UserApi(None)
        groups = [
            GroupApi(None).get_one(Group.TIM_USER),
            GroupApi(None).get_one(Group.TIM_MANAGER),
            GroupApi(None).get_one(Group.TIM_ADMIN)
        ]
        user_a = uapi.create_user(email='this.is@user',
                                  groups=groups,
                                  save_now=True)
        user_b = uapi.create_user(email='*****@*****.**',
                                  groups=groups,
                                  save_now=True)

        wapi = WorkspaceApi(user_a)
        workspace = wapi.create_workspace('test workspace', save_now=True)

        role_api = RoleApi(user_a)
        role_api.create_one(user_b, workspace, UserRoleInWorkspace.READER,
                            False)
        cont_api_a = ContentApi(user_a)
        cont_api_b = ContentApi(user_b)

        page_1 = cont_api_a.create(ContentType.Page,
                                   workspace,
                                   None,
                                   'this is a page',
                                   do_save=True)

        for rev in page_1.revisions:
            eq_(user_b not in rev.read_by.keys(), True)

        cont_api_b.mark_read(page_1)

        for rev in page_1.revisions:
            eq_(user_b in rev.read_by.keys(), True)