def add_qands_to_sheet(request, sheet_id=None, id_qands=None): c = {} try: this_sheet = Sheet(id=sheet_id) s_q = SmartQAndS.objects.get(id=id_qands_to_add) q = QAndS(sheet=this_sheet, smartqands=s_q, question=s_q.question, solution=s_q.solution) q.save() except: print 'error' return HttpResponseRedirect('..')
def smartqands_to_qands(request, sheet_id=None, smartqands_id=None): c = {} if sheet_id and smartqands_id: if request.method == "GET": if request.GET.get('q', False): this_sheet = Sheet.objects.get(id=sheet_id) this_smartqands = SmartQAndS.objects.get(id=smartqands_id) this_qands=QAndS(sheet=this_sheet, smartqands=this_smartqands, question=request.GET.get('q',''),solution=request.GET.get('s', '')) this_qands.save() return HttpResponseRedirect('/sheet/{0}'.format(this_sheet.id)) else: #this_sheet = Sheet.objects.get(id=sheet_id) #this_smartqands = SmartQAndS.objects.get(id=smartqands_id) #this_qands = QAndS(sheet=this_sheet, smartqands=this_smartqands, question=request.GET.get('q', ''), solution=request.GET.get('s', '')) #this_qands.save() this_smartqands = SmartQAndS.objects.get(id=smartqands_id) c['smartqands'] = this_smartqands c['script'] = this_smartqands.lastest.script c['sheet_id'] = sheet_id return render_to_response('show_smartqands.html', c)