def enter_debater(request): if request.method == 'POST': form = DebaterForm(request.POST) if form.is_valid(): try: form.save() except ValueError: return render_to_response('error.html', { 'error_type': "Debater", 'error_name': "[" + form.cleaned_data['name'] + "]", 'error_info': "Debater name cannot be validated, most likely a duplicate debater" }, context_instance=RequestContext( request)) return render_to_response( 'thanks.html', { 'data_type': "Debater", 'data_name': "[" + form.cleaned_data['name'] + "]", 'data_modification': "CREATED", 'enter_again': True }, context_instance=RequestContext(request)) else: form = DebaterForm() return render_to_response('data_entry.html', { 'form': form, 'title': "Create Debater:" }, context_instance=RequestContext(request))
def enter_debater(request): if request.method == "POST": form = DebaterForm(request.POST) if form.is_valid(): try: form.save() except ValueError: return render_to_response( "error.html", { "error_type": "Debater", "error_name": "[" + form.cleaned_data["name"] + "]", "error_info": "Debater name cannot be validated, most likely a duplicate debater", }, context_instance=RequestContext(request), ) return render_to_response( "thanks.html", { "data_type": "Debater", "data_name": "[" + form.cleaned_data["name"] + "]", "data_modification": "CREATED", "enter_again": True, }, context_instance=RequestContext(request), ) else: form = DebaterForm() return render_to_response( "data_entry.html", {"form": form, "title": "Create Debater:"}, context_instance=RequestContext(request) )
def view_debater(request, debater_id): debater_id = int(debater_id) try: debater = Debater.objects.get(pk=debater_id) except Debater.DoesNotExist: return render_to_response('error.html', { 'error_type': "View Debater", 'error_name': str(debater_id), 'error_info': "No such debater" }, context_instance=RequestContext(request)) if request.method == 'POST': form = DebaterForm(request.POST, instance=debater) if form.is_valid(): try: form.save() except ValueError: return render_to_response('error.html', { 'error_type': "Debater", 'error_name': "[" + form.cleaned_data['name'] + "]", 'error_info': "Debater name cannot be validated, most likely a non-existent debater" }, context_instance=RequestContext( request)) return render_to_response( 'thanks.html', { 'data_type': "Debater", 'data_name': "[" + form.cleaned_data['name'] + "]" }, context_instance=RequestContext(request)) else: rounds = RoundStats.objects.filter(debater=debater) rounds = sorted(list(rounds), key=lambda x: x.round.round_number) form = DebaterForm(instance=debater) # Really only should be one teams = Team.objects.filter(debaters=debater) links = [] for team in teams: links.append( ('/team/' + str(team.id) + '/', "View %s" % team.name, False)) return render_to_response( 'data_entry.html', { 'form': form, 'debater_obj': debater, 'links': links, 'debater_rounds': rounds, 'title': "Viewing Debater: %s" % (debater.name) }, context_instance=RequestContext(request))
def view_debater(request, debater_id): debater_id = int(debater_id) try: debater = Debater.objects.get(pk=debater_id) except Debater.DoesNotExist: return render_to_response( "error.html", {"error_type": "View Debater", "error_name": str(debater_id), "error_info": "No such debater"}, context_instance=RequestContext(request), ) if request.method == "POST": form = DebaterForm(request.POST, instance=debater) if form.is_valid(): try: form.save() except ValueError: return render_to_response( "error.html", { "error_type": "Debater", "error_name": "[" + form.cleaned_data["name"] + "]", "error_info": "Debater name cannot be validated, most likely a non-existent debater", }, context_instance=RequestContext(request), ) return render_to_response( "thanks.html", {"data_type": "Debater", "data_name": "[" + form.cleaned_data["name"] + "]"}, context_instance=RequestContext(request), ) else: rounds = RoundStats.objects.filter(debater=debater) rounds = sorted(list(rounds), key=lambda x: x.round.round_number) form = DebaterForm(instance=debater) # Really only should be one, TODO: change to get when we have tests teams = Team.objects.filter(debaters=debater) links = [("/debater/" + str(debater_id) + "/delete/", "Delete", True)] for team in teams: links.append(("/team/" + str(team.id) + "/", "View %s" % team.name, False)) return render_to_response( "data_entry.html", { "form": form, "debater_obj": debater, "links": links, "debater_rounds": rounds, "title": "Viewing Debater: %s" % (debater.name), }, context_instance=RequestContext(request), )
def view_debater(request, debater_id): debater_id = int(debater_id) try: debater = Debater.objects.get(pk=debater_id) except Debater.DoesNotExist: return render_to_response('error.html', {'error_type': "View Debater", 'error_name': str(debater_id), 'error_info':"No such debater"}, context_instance=RequestContext(request)) if request.method == 'POST': form = DebaterForm(request.POST,instance=debater) if form.is_valid(): try: form.save() except ValueError: return render_to_response('error.html', {'error_type': "Debater", 'error_name': "["+form.cleaned_data['name']+"]", 'error_info':"Debater name cannot be validated, most likely a non-existent debater"}, context_instance=RequestContext(request)) return render_to_response('thanks.html', {'data_type': "Debater", 'data_name': "["+form.cleaned_data['name']+"]"}, context_instance=RequestContext(request)) else: rounds = RoundStats.objects.filter(debater=debater) form = DebaterForm(instance=debater) # Really only should be one, TODO: change to get when we have tests teams = Team.objects.filter(debaters = debater) links = [('/debater/'+str(debater_id)+'/delete/', 'Delete', True)] for team in teams: links.append(('/team/'+str(team.id)+'/', "View %s"%team.name, False)) return render_to_response('data_entry.html', {'form': form, 'debater_obj': debater, 'links': links, 'debater_rounds': rounds, 'title':"Viewing Debater: %s"%(debater.name)}, context_instance=RequestContext(request))
def enter_debater(request): if request.method == 'POST': form = DebaterForm(request.POST) if form.is_valid(): try: form.save() except ValueError: return render_to_response('error.html', {'error_type': "Debater",'error_name': "["+form.cleaned_data['name']+"]", 'error_info':"Debater name cannot be validated, most likely a duplicate debater"}, context_instance=RequestContext(request)) return render_to_response('thanks.html', {'data_type': "Debater", 'data_name': "["+form.cleaned_data['name']+"]", 'data_modification': "CREATED", 'enter_again': True}, context_instance=RequestContext(request)) else: form = DebaterForm() return render_to_response('data_entry.html', {'form': form, 'title': "Create Debater:"}, context_instance=RequestContext(request))