говнокод

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def vehicle_top(request, vehicle_id=None):
if not vehicle_id:
vehicles = cache.get('top-vehicle-list')
if not vehicles:
raw = dict(
[(record.vehicle_id, {'id': record.vehicle_id, 'vehicle':record.get_name(), 'kills':record.kills, '\
player': record.player})
for record in InfoVehicle.objects.all().order_by('kills').select_related()])
vehicles = resort(raw, 'kills')
cache.set('top-vehicle-list', vehicles, CACHE_TIME)
else:
players = InfoVehicle.objects.filter(vehicle_id=vehicle_id).order_by('-kills').select_related()[:100]
name = players[0].get_name()
return render_to_response('players/boards/vehicles.html', locals(), RequestContext(request))