def view_judge(request, judge_id):
    judge_id = int(judge_id)
    try:
        judge = Judge.objects.get(pk=judge_id)
    except Judge.DoesNotExist:
        return render_to_response('error.html', 
                                 {'error_type': "View Judge",
                                  'error_name': str(judge_id),
                                  'error_info':"No such judge"}, 
                                  context_instance=RequestContext(request))
    if request.method == 'POST':
        form = JudgeForm(request.POST,instance=judge)
        if form.is_valid():
            try:
               form.save()
            except __HOLE__:
                return render_to_response('error.html', 
                                         {'error_type': "Judge",
                                          'error_name': "["+form.cleaned_data['name']+"]",
                                          'error_info':"Judge information cannot be validated."}, 
                                          context_instance=RequestContext(request))
            return render_to_response('thanks.html', 
                                     {'data_type': "Judge",
                                      'data_name': "["+form.cleaned_data['name']+"]",
                                      'data_modification': "EDIT"}, 
                                      context_instance=RequestContext(request))
        else :
            return render_to_response('error.html', 
                                     {'error_type': "Judge",
                                      'error_name': "",
                                      'error_info': form.errors}, 
                                      context_instance=RequestContext(request))
    else:
        form = JudgeForm(instance=judge)
        base_url = '/judge/'+str(judge_id)+'/'
        scratch_url = base_url + 'scratches/view/'
        delete_url =  base_url + 'delete/'
        links = [(scratch_url,'Scratches for '+str(judge.name),False),
                 (delete_url,'Delete', True)]
        return render_to_response('data_entry.html', 
                                 {'form': form,
                                  'links': links,
                                  'title': "Viewing Judge: %s" %(judge.name)}, 
                                  context_instance=RequestContext(request))
dataset/ETHPy150Open jolynch/mit-tab/mittab/apps/tab/judge_views.py/view_judge