Ejemplo n.º 1
0
def pilot_detail(request,pilot_id):
    print "in detail"
    pilot1=get_pilot_by_id(pilot_id)
    if not pilot1: raise Http404
    #pilot1["id"]=pilot_id
    name=get_object_or_404(pilot,id=pilot_id)
    #name=pilot.objects.filter(pk=pilot_id)
    #pilot1["name"]=name.name
    print "get json"
    kills_data=get_json_pilot(characterID=pilot_id)
    print "add_json"
    #db_add_json(kills_data)
    #add_pilots_corps_to_db(kills_data)
    print "add_json1"
    #add_json2db(kills_data,pilot_id=pilot_id)
    
    kills,loss=json_utils.divide_kill_lose(pilotID=pilot_id, kills_data=kills_data)
    pilot1["number_kills"]=len(kills)
    pilot1["number_loss"]=len(loss)
    pilot1["last_kill_time"]=json_utils.get_last_kill_time(kills_data=kills_data)
    loss=kill.objects.filter(characterID=pilot_id)
    print "pre render"
    return render(request,"analizer/pilot_detail.html",
                  {"pilot":pilot1,
                   "victim_list":get_victim_list(kills_data),
                   "loss":loss,
                   })    
Ejemplo n.º 2
0
def mates_page(request,pilot_id):
    cursor = connection.cursor() 
    cursor.execute("""select "characterID","characterName",count(*) as cnt from analizer_attacker 
    where "characterID" <> %s and "characterID" <> 0 and
    "killID_id" in     (select "killID_id" from analizer_attacker where "characterID"=%s)
     
    group by "characterID","characterName" order by count(*) desc;
    """,[pilot_id,pilot_id])
    r=cursor.fetchall()
    p=Paginator(r,mates_per_page)
    mate_page = request.GET.get('mate_page', 1)
    try:
        page=p.page(mate_page)
    except PageNotAnInteger:
        page=p.page(1)
    except EmptyPage:
        page=p.page(p.num_pages)
    mates=[]
    for i in page.object_list:
        d=get_pilot_by_id(i[0])
        #if int(i[0])==int(pilot_id): continue
        d["id"]=i[0]
        d["name"]=i[1]
        d["kills"]=i[2]
        #print d
        mates.append(d)
    mates_pages={}
    mates_pages["pilot"]=pilot_id
    if page.has_next():
        mates_pages["next"]=page.next_page_number()
    if page.has_previous():
        mates_pages["prev"]=page.previous_page_number()
    return mates,mates_pages