# Create your views here.
import json
from django.http import HttpResponse
from namelist.models import Player
from django.views.decorators.csrf import csrf_exempt


@csrf_exempt
def process_ids(request):
    if request.method != 'POST':
        return HttpResponse(status=405)
    
    if not request.POST.has_key('survivors[]') and not request.POST.has_key('survivors'):
        return HttpResponse(status=400)

    survivor_ids = request.POST.getlist('survivors[]')
    survivors = []
    for survivor_id in survivor_ids:
        try:
            survivors.append(int(survivor_id))
        except ValueError:
            pass
    
    survivors = Player.objects.filter(profile_id__in=survivors).select_related()
    data = []
    for survivor in survivors:
        data.append(dict(id=survivor.profile_id, color_code=survivor.category.color_code))
        
    return HttpResponse(json.dumps(data), 'application/json')

@@ -308,23 +308,21 @@
 as_key('
-survivo
+playe
 rs%5B%5D') a
@@ -350,23 +350,21 @@
 as_key('
-survivo
+playe
 rs'):%0A  
@@ -406,23 +406,21 @@
 0)%0A%0A    
-survivo
+playe
 r_ids = 
@@ -441,23 +441,21 @@
 etlist('
-survivo
+playe
 rs%5B%5D')%0A 
@@ -453,31 +453,29 @@
 ers%5B%5D')%0A    
-survivo
+playe
 rs = %5B%5D%0A    
@@ -482,23 +482,21 @@
 for 
-survivo
+playe
 r_id in 
 surv
@@ -491,23 +491,21 @@
 r_id in 
-survivo
+playe
 r_ids:%0A 
@@ -528,23 +528,21 @@
         
-survivo
+playe
 rs.appen
@@ -614,23 +614,21 @@
    %0A    
-survivo
+playe
 rs = Pla
@@ -661,23 +661,21 @@
 _id__in=
-survivo
+playe
 rs).sele
@@ -713,27 +713,23 @@
 for 
-survivor in survivo
+player in playe
 rs:%0A
@@ -756,23 +756,21 @@
 dict(id=
-survivo
+playe
 r.profil
@@ -786,23 +786,21 @@
 or_code=
-survivo
+playe
 r.catego

Clean up mis-named variables.