def alternative_judges(request, round_id, judge_id=None): round_obj = Round.objects.get(id=int(round_id)) round_number = round_obj.round_number round_gov, round_opp = round_obj.gov_team, round_obj.opp_team # All of these variables are for the convenience of the template try: current_judge_id = int(judge_id) current_judge_obj = Judge.objects.get(id=current_judge_id) current_judge_name = current_judge_obj.name current_judge_rank = current_judge_obj.rank except TypeError: current_judge_id, current_judge_obj, current_judge_rank = "","","" current_judge_name = "No judge" excluded_judges = Judge.objects.exclude(judges__round_number = round_number) \ .filter(checkin__round_number = round_number) included_judges = Judge.objects.filter(judges__round_number = round_number) \ .filter(checkin__round_number = round_number) excluded_judges = [(j.name, j.id, float(j.rank)) for j in assign_judges.can_judge_teams(excluded_judges, round_gov, round_opp)] included_judges = [(j.name, j.id, float(j.rank)) for j in assign_judges.can_judge_teams(included_judges, round_gov, round_opp)] included_judges = sorted(included_judges, key=lambda x: -x[2]) excluded_judges = sorted(excluded_judges, key=lambda x: -x[2]) return render_to_response('judge_dropdown.html', locals(), context_instance=RequestContext(request))
def alternative_judges(request, round_id, judge_id=None): round_obj = Round.objects.get(id=int(round_id)) round_number = round_obj.round_number round_gov, round_opp = round_obj.gov_team, round_obj.opp_team # All of these variables are for the convenience of the template try: current_judge_id = int(judge_id) current_judge_obj = Judge.objects.get(id=current_judge_id) current_judge_name = current_judge_obj.name current_judge_rank = current_judge_obj.rank except TypeError: current_judge_id, current_judge_obj, current_judge_rank = "", "", "" current_judge_name = "No judge" excluded_judges = Judge.objects.exclude(judges__round_number = round_number) \ .filter(checkin__round_number = round_number) included_judges = Judge.objects.filter(judges__round_number = round_number) \ .filter(checkin__round_number = round_number) excluded_judges = [(j.name, j.id, float(j.rank)) for j in assign_judges.can_judge_teams( excluded_judges, round_gov, round_opp)] included_judges = [(j.name, j.id, float(j.rank)) for j in assign_judges.can_judge_teams( included_judges, round_gov, round_opp)] included_judges = sorted(included_judges, key=lambda x: -x[2]) excluded_judges = sorted(excluded_judges, key=lambda x: -x[2]) return render_to_response('judge_dropdown.html', locals(), context_instance=RequestContext(request))