def tootehaldus(request): is_worker(request) notice = "" keeled = langs.objects.all() if request.POST: # DELETE A TOODE if "delete" in request.POST["submit-btn"]: for item in toode.objects.filter( toode_id=request.POST["submit-btn"].split("_")[0]): item.delete() notice = "Toode edukalt eemaldatud!" # NUKE TOODE elif "nuke" in request.POST["submit-btn"]: for item in toode.objects.all(): item.delete() notice = "Kõik tooted edukalt eemaldatud!" # EDIT TOODE elif "edit" in request.POST["submit-btn"]: ID = request.POST["submit-btn"].split("_")[0] try: img = request.FILES["image"] except: img = toode.objects.filter(toode_id=ID)[0].img price = request.POST["price"] prevprice = request.POST["prevprice"] esilehele = request.POST["esilehele"] for keel in keeled: lang = keel.lang name = request.POST[keel.lang + "_name"] description = request.POST[keel.lang + "_description"] specs = request.POST[keel.lang + "_specs"] toode.objects.get(lang=keel.lang, toode_id=ID).delete() toode.objects.create(toode_id=ID, lang=keel.lang, name=name, price=price, prevprice=prevprice, description=description, esilehele=esilehele, img=img, specs=specs) notice = "Toode edukalt muudetud!" toote_id = toode.objects.all().values("toode_id").distinct() tooted = [] for ID in toote_id: item = [] for lang in keeled: item.append( toode.objects.get(lang=lang.lang, toode_id=ID["toode_id"])) tooted.append(item) return render(request, "tootehaldus.html", context={ "tooted": tooted, "lang_separator": float(99) / float(len(langs.objects.all())), "notice": notice })
def loader(request): is_worker(request) if request.POST: items = lister(request.POST["sisu"]) if request.POST["table"] == "foodstore": if request.POST["delete"] == "yes": foodstore_menu.objects.filter(lang=items[0][0]).delete() for item in items: foodstore_menu.objects.create(lang=item[0], item_cat=item[1], item_name=item[2], item_price=item[3]) if request.POST["table"] == "repair": if request.POST["delete"] == "yes": repair_menu.objects.filter(lang=items[0][0]).delete() for item in items: repair_menu.objects.create(lang=item[0], item_cat=item[1], item_name=item[2], item_price=item[3]) if request.POST["table"] == "filmstudio": if request.POST["delete"] == "yes": filmstudio_inventory.objects.all().delete() for item in items: filmstudio_inventory.objects.create(item=item[0], desc=item[1], qty=item[2]) return render(request, 'loader.html', context={})
def rehvihotell(request): is_worker(request) return render( request, 'kalender.html', context={'link': google_link.objects.get(name="rehvihotell")})
def reklaam(request): request.session['paper'] = '-' is_worker(request) items = reklaam_entry.objects.all() if bool(request.POST) == True: request.session['paper'] = request.POST['submit-btn'] items = reklaam_entry.objects.filter(nimi=request.POST['submit-btn']) return render(request, 'reklaam.html', context={'items': items})
def xmltotxt(request): is_worker(request) if request.method == 'POST': form = UploadFileForm(request.POST, request.FILES) if "Motoral" in request.POST["firm"]: inquiry = import_motoral(request.FILES["file"]) if "Hasmar" in request.POST["firm"]: inquiry = import_hasmar(request.FILES["file"]) doc = export_baltiautoosad(inquiry) # file_data = writeTXT(ImportXML(), request.POST["name"]) response = HttpResponse(doc.toxml(encoding="utf-8"), content_type='application/text charset=utf-8') response[ 'Content-Disposition'] = 'attachment; filename="{}.xml"'.format( request.POST["name"]) return response else: form = UploadFileForm() return render(request, 'xmltotxt.html', {'form': form})
def tootelisamine(request): notice = "" is_worker(request) if request.POST: # IF USING TRANSLATE try: test = request.POST["translate"] main = request.POST["main"] toode_id = randomString() picture = request.FILES["image"] try: esilehele = request.POST["esilehele"] esilehele = "y" except: esilehele = "n" for lang in langs.objects.all(): price = request.POST[main + "_price"] prevprice = request.POST[main + "_prevprice"] if main == lang.lang: name = request.POST[main + "_name"] description = request.POST[main + "_description"] specs = request.POST[main + "_specs"] else: tekst = [ request.POST[main + "_name"], request.POST[main + "_description"], request.POST[main + "_specs"] ] sisu = tolgi(tekst, main, lang.lang) name = sisu[0] description = sisu[1] specs = sisu[2].replace(", ", ";") toode.objects.create(toode_id=toode_id, lang=lang.lang, name=name, price=price, prevprice=prevprice, description=description, esilehele=esilehele, img=picture, specs=specs) notice = "Toode edukalt lisatud ja tõlgitud!" except Exception as e: print(str(e)) notice = "Toote lisamine ja tõlkimine EBAÕNNESTUS!" # IF NOT TRANSLATING try: test = request.POST["translate"] except: picture = request.FILES["image"] toode_id = randomString() try: esilehele = request.POST["esilehele"] esilehele = "y" except: esilehele = "n" for lang in langs.objects.all(): name = request.POST[lang.lang + "_name"] price = request.POST[lang.lang + "_price"] prevprice = request.POST[lang.lang + "_prevprice"] description = request.POST[lang.lang + "_description"] specs = request.POST[lang.lang + "_specs"] toode.objects.create(toode_id=toode_id, lang=lang.lang, name=name, price=price, prevprice=prevprice, description=description, esilehele=esilehele, img=picture, specs=specs) notice = "Toode lisatud edukalt!" return render(request, "tootelisamine.html", context={ "langs": langs.objects.all(), "lang_separator": float(99) / float(len(langs.objects.all())), "notice": notice })
def varuosad(request): is_worker(request) return render(request, 'kalender.html', context={ 'link':google_link.objects.first() })
def hooldus(request): is_worker(request) return render(request, 'kalender.html', context={'link': google_link.objects.get(name="hooldus")})