def main(request): """ Note on annotations: Old: Return annotations by concatenating Annotation last 10 and Comment last 10, adding all related comments (comments on same item that are older). annotations_old = get_annotations( annotations=list(Annotation.objects.all().order_by('-timestamp')[:10]), comments=Comment.objects.all().order_by('-submit_date')[:10]) New: Return annotations by Action filtered to include only: annotation-added (to meeting), ignore annotated (by user) comment-added """ context = cache.get('main_page_context') if not context: context = {} context['title'] = _('Home') actions = list(main_actions()[:10]) annotations = get_annotations( annotations=[a.target for a in actions if a.verb != 'comment-added'], comments=[x.target for x in actions if x.verb == 'comment-added']) context['annotations'] = annotations bill_votes = [x['object_id'] for x in voting.models.Vote.objects.get_popular(Bill)] if bill_votes: context['bill'] = Bill.objects.get(pk=random.choice(bill_votes)) context['topics'] = Topic.objects.filter(status__in=PUBLIC_TOPIC_STATUS)\ .order_by('-modified')\ .select_related('creator')[:10] context['has_search'] = True # disable the base template search cache.set('main_page_context', context, 300) # 5 Minutes template_name = '%s.%s%s' % ('main', settings.LANGUAGE_CODE, '.html') return render_to_response(template_name, context, context_instance=RequestContext(request))
def items(self): return main_actions()[:20]