def Edit_Card(request): if request.method == 'POST': id_card = request.POST.get('card') deck = request.POST.get('deck') front = request.POST.get('front') back = request.POST.get('back') signer = Signer(request.user.id) try: deck = signer.unsign(deck) except signing.BadSignature: return HttpResponseRedirect('/') data = {'deck': deck, 'front': front, 'back': back} form = NewCard(data) if form.is_valid(): card = get_object_or_404(Card, card_id=id_card) card.front = front card.back = back card.save() else: errors = form.errors return HttpResponse(json.dumps(errors)) return HttpResponse(json.dumps({"success": "success"}))
def Edit_Card(request): if request.method == 'POST': id_card = request.POST.get('card') deck = request.POST.get('deck') front = request.POST.get('front') back = request.POST.get('back') signer = Signer(request.user.id) try: deck = signer.unsign(deck) except signing.BadSignature: return HttpResponseRedirect('/') data = {'deck' : deck, 'front' : front, 'back' : back} form = NewCard(data) if form.is_valid(): card = get_object_or_404(Card, card_id=id_card) card.front = front card.back = back card.save() else: errors = form.errors return HttpResponse(json.dumps(errors)) return HttpResponse(json.dumps({"success": "success"}))
def New_Card(request): if request.method == 'POST': deck = request.POST.get('deck') front = request.POST.get('front') back = request.POST.get('back') signer = Signer(request.user.id) try: deck = signer.unsign(deck) except signing.BadSignature: return HttpResponseRedirect('/') data = {'deck': deck, 'front': front, 'back': back} form = NewCard(data) if form.is_valid(): print "valid form" card = form.save(commit=False) card.deck_id = deck card.save() else: print "error" errors = form.errors print errors return HttpResponse(json.dumps(errors)) return HttpResponse(json.dumps({"success": "success"}))
def New_Card(request): if request.method == 'POST': deck = request.POST.get('deck') front = request.POST.get('front') back = request.POST.get('back') signer = Signer(request.user.id) try: deck = signer.unsign(deck) except signing.BadSignature: return HttpResponseRedirect('/') data = {'deck' : deck, 'front' : front, 'back' : back} form = NewCard(data) if form.is_valid(): print "valid form" card = form.save(commit=False) card.deck_id = deck card.save() else: print "error" errors = form.errors print errors return HttpResponse(json.dumps(errors)) return HttpResponse(json.dumps({"success": "success"}))