Example #1
0
def userSubmit(request):
    # from DataFiles.save import saveToFile
    if request.method == "POST":
        try:
            kw = request.POST["kw"]
            km = request.POST["km"]
            year = request.POST["year"]
            ac = request.POST["ac"]
            gears = request.POST["gears"]
            body = request.POST["body"]
            userPrice = request.POST["userPrice"]
            if body == "0":
                body = "0,0,0"
            if body == "1":
                body = "1,0,0"
            if body == "2":
                body = "0,1,0"
            if body == "3":
                body = "0,0,1"
            carAdInstance = CarAd(kw=kw, km=km, year=year, ac=ac, gears=gears, body=body, price=userPrice)
            carAdInstance.save()
            # saveToFile(kw, km, year, ac, gears, body, userPrice)
            # return HttpResponse(status=200)
            return render("index.html", {"cars": CarAd.objects.all()})
        except Exception, e:
            traceback.print_exc()
            return HttpResponse(status=403)
Example #2
0
            # klima manuelna 0, automatska 1
            if "Manuelni" in menjacIKlima:
                menjac = 0
            else:
                menjac = 1
            if "Manuelna" in menjacIKlima:
                klima = 0
            else:
                klima = 1

            try:
                writeF = str(kw) + "," + km + "," + year + "," + str(klima) + "," + str(menjac) + "," + str(
                    karos) + "," + price + '\n'

                if "Manu" in writeF:
                    print("Manu found")
                elif "Auto" in writeF:
                    print("Auto found")
                else:
                    f.write(writeF)
                    carAdInstance = CarAd(kw=kw, km=km, year=year, ac=klima, gears=menjac, body=karos, price=price,
                                          idFromSite=idFromSite)
                    carAdInstance.save()

            except Exception as e:
                errorFile.write(str(x) + '********' + str(e) + '********' + '\n')
                pass
    x += 1
f.close()

errorFile.close()