<s> from django . contrib . auth . models import User <EOL> from django . core . urlresolvers import reverse <EOL> from django . http import HttpResponseRedirect , Http404 <EOL> from django . template import RequestContext <EOL> from django . shortcuts import render_to_response , get_object_or_404 <EOL> from dashboard . models import * <EOL> from dashboard . util import force_url_paths , avoid_duplicate_queries <EOL> from dashboard . views import commits , blogs <EOL> from django . db import connection <EOL> INDEX_EVENT_COUNT = <NUM_LIT:100> <EOL> def feed ( request ) : <EOL> objs = Event . objects . select_subclasses ( ) . order_by ( '<STR_LIT:date>' ) . reverse ( ) [ : INDEX_EVENT_COUNT ] <EOL> avoid_duplicate_queries ( objs , "<STR_LIT>" , "<STR_LIT>" , <EOL> author = { request . user . id : request . user } <EOL> if request . user . is_authenticated ( ) else { } ) <EOL> return render_to_response ( '<STR_LIT>' , { <EOL> '<STR_LIT>' : objs , <EOL> '<STR_LIT>' : True <EOL> } , context_instance = RequestContext ( request ) ) <EOL> def event ( request , url_path ) : <EOL> resp = force_url_paths ( event , url_path ) <EOL> if resp : return resp <EOL> try : <EOL> qs = InheritanceQuerySet ( model = Event ) <EOL> the_event = qs . select_subclasses ( ) . get ( url_path = url_path ) <EOL> except : <EOL> raise Http404 <EOL> if the_event . __class__ is Commit : <EOL> return HttpResponseRedirect ( reverse ( commits . show , <EOL> args = ( the_event . project . url_path , <EOL> the_event . url_path , ) ) ) <EOL> else : <EOL> if the_event . project is not None : <EOL> return HttpResponseRedirect ( reverse ( blogs . show_post , <EOL> args = ( the_event . project . url_path , <EOL> the_event . url_path , ) ) ) <EOL> else : <EOL> return HttpResponseRedirect ( reverse ( blogs . show_user_post , <EOL> args = ( the_event . author . id , <EOL> the_event . url_path , ) ) ) <EOL> raise Http404 </s>
