Ejemplo n.º 1
0
def chainHome(request):
  context = {}
  if request.method == 'POST':
    form = NewChainForm(request.POST)
    if form.is_valid():
      name = request.POST['name']
      qc = QuestionChain(chain_name=name)
      qc.save()

  context["chains"] = QuestionChain.objects.all()
  context["form"] = NewChainForm()
  context["menu_location"] = "chain"
  context["previous_page"] = previous_page(request.path)
  return render(request, 'questions/chainHome.html', context)
Ejemplo n.º 2
0
def addChain(request):
  if request.method == 'POST': # If the form has been submitted...
    form = NewChainForm(request.POST) # A form bound to the POST data
    if form.is_valid(): # All validation rules pass
      name = request.POST['name']
      qc = QuestionChain(chain_name=name)
      qc.save()
      #context["previous_page"] = previous_page(request.path)
      return HttpResponseRedirect("%seditChain/%s/" % (previous_page(request.path), qc.id))#check if worked
  else:
    form = NewChainForm() # An unbound form
  return render(request, 'questions/addChain.html', {
    'form': form,
  })