コード例 #1
0
ファイル: views.py プロジェクト: geojeff/kotti_todos
    def view(self):

        session = DBSession()

        query = (session.query(TodoItem)
                .filter(TodoItem.parent_id == self.context.id)
                .order_by(TodoItem.todostate)
                .order_by(TodoItem.modification_date.desc())
                )

        items = query.all()

        page = self.request.params.get('page', 1)

        settings = todos_settings()

        if settings['use_batching']:
            items = Batch.fromPagenumber(items,
                          pagesize=settings['pagesize'],
                          pagenumber=int(page))

        return {
            'api': template_api(self.context, self.request),
            'macros': get_renderer('templates/macros.pt').implementation(),
            'items': items,
            'settings': settings,
            }
コード例 #2
0
ファイル: views.py プロジェクト: geojeff/kotti_todos
    def view(self):

        session = DBSession()

        query = session.query(Category).filter(
                Category.parent_id == self.context.id)

        items = query.all()

        todos_data = {}
        for state in todo_states:
            todos_data[state] = 0

        todos_data['total'] = 0

        modification_dates_and_items = []

        for item in items:
            if item.children:
                done_count = 0
                for todo in item.children:
                    todos_data[todo.todostate] += 1
                    if todo.todostate == 'done':
                        done_count += 1

                todos_data['total'] += len(item.children)

                sorted_todoitems = sorted(item.children,
                                      key=lambda x: x.modification_date,
                                      reverse=True)

                modification_dates_and_items.append(
                        (sorted_todoitems[0].modification_date,
                         sorted_todoitems[0],
                         done_count,
                         item))
            else:
                modification_dates_and_items.append(
                        (item.modification_date, item, 0, item))

        items = sorted(modification_dates_and_items)

        page = self.request.params.get('page', 1)

        settings = todos_settings()

        if settings['use_batching']:
            items = Batch.fromPagenumber(items,
                          pagesize=settings['pagesize'],
                          pagenumber=int(page))

        return {
            'api': template_api(self.context, self.request),
            'macros': get_renderer('templates/macros.pt').implementation(),
            'items': items,
            'todos_data': todos_data,
            'data_keys': todo_states + ['total'],
            'settings': settings,
            }
コード例 #3
0
ファイル: views.py プロジェクト: geojeff/kotti_todos
    def view(self):

        settings = todos_settings()

        return {
            'api': template_api(self.context, self.request),
            'macros': get_renderer('templates/macros.pt').implementation(),
            'settings': settings,
            }
コード例 #4
0
ファイル: test_resources.py プロジェクト: geojeff/kotti_todos
def test_todos_wrong_settings(db_session):
    settings = get_current_registry().settings
    settings['kotti_todos.todos_settings.use_batching'] = u'blibs'
    settings['kotti_todos.todos_settings.pagesize'] = u'blabs'
    settings['kotti_todos.todos_settings.use_auto_batching'] = u'blubs'
    settings['kotti_todos.todos_settings.link_headline_overview'] = u'blobs'

    b_settings = todos_settings()
    assert b_settings['use_batching'] == False
    assert b_settings['pagesize'] == 5
    assert b_settings['use_auto_batching'] == False
    assert b_settings['link_headline_overview'] == False
コード例 #5
0
ファイル: test_resources.py プロジェクト: geojeff/kotti_todos
def test_todos_change_settings(db_session):
    settings = get_current_registry().settings
    settings['kotti_todos.todos_settings.use_batching'] = u'false'
    settings['kotti_todos.todos_settings.pagesize'] = u'2'
    settings['kotti_todos.todos_settings.use_auto_batching'] = u'false'
    settings['kotti_todos.todos_settings.link_headline_overview'] = u'false'

    b_settings = todos_settings(db_session)
    assert b_settings['use_batching'] == False
    assert b_settings['pagesize'] == 2
    assert b_settings['use_auto_batching'] == False
    assert b_settings['link_headline_overview'] == False
コード例 #6
0
ファイル: test_resources.py プロジェクト: geojeff/kotti_todos
def test_todos_default_settings(db_session):
    b_settings = todos_settings()
    assert b_settings['use_batching'] == True
    assert b_settings['pagesize'] == 5
    assert b_settings['use_auto_batching'] == True
    assert b_settings['link_headline_overview'] == True