def show_archive(categories=None):
    group = get_current_group()
    if categories is None:
        categories = get_board_categories(group)
    threads = get_posts_queryset(group, categories)
    # Get dates
    threads = threads.values('postdate')
    # Count posts in (year, month) tuples
    months_dict = dict()
    for t in threads:
        tmp = (t['postdate'].year, t['postdate'].month)
        months_dict[tmp] = months_dict.get(tmp, 0) + 1

    # Sort it by year and then by month, in increasing order (last month first)
    months = sorted(months_dict.iteritems(), \
                        lambda a, b: \
                        cmp(a[0][0], b[0][0]) \
                        or cmp(a[0][1], b[0][1]))
    months.reverse()
    return {'links': months}
def show_archive(categories = None):
    group = get_current_group()
    if categories is None:
        categories = get_board_categories(group)
    threads = get_posts_queryset(group, categories)
    # Get dates
    threads = threads.values('postdate')
    # Count posts in (year, month) tuples
    months_dict = dict()
    for t in threads:
        tmp = (t['postdate'].year, t['postdate'].month)
        months_dict[tmp] = months_dict.get(tmp, 0) + 1

    # Sort it by year and then by month, in increasing order (last month first)
    months = sorted(months_dict.iteritems(), \
                        lambda a, b: \
                        cmp(a[0][0], b[0][0]) \
                        or cmp(a[0][1], b[0][1]))
    months.reverse()
    return {'links': months}
Esempio n. 3
0
 def items(self):
     group = get_current_group()
     categories = get_board_categories(group)
     threads = get_posts_queryset(group, categories)
     return threads
Esempio n. 4
0
 def items(self):
     group = get_current_group()
     categories = get_board_categories(group)
     threads = get_posts_queryset(group, categories )
     return threads