from base import *
from srsbrowser.models import REF_TYPE_CHOICES
def main_page(request):
    recent_uploads = SRS.objects.filter(type="sr-org").order_by('-id')[0:5]
    recent_views   = SRS.objects.all().order_by('-updated_date', '-views')[0:5]
    
    counts = []
    for type in REF_TYPE_CHOICES:
        type_key = type[0] 
        count = SRS.objects.filter(type=type_key).count()
        if count:
            counts.append({'type': type[0], 
                           'type_display': type[1], 
                           'count':count}) 

    return render_to_response('references/index.html', {'recent_uploads': recent_uploads, 'recent_views': recent_views, 'counts': counts})
