本文整理汇总了Python中polls.models.Wares.setwareinbar方法的典型用法代码示例。如果您正苦于以下问题:Python Wares.setwareinbar方法的具体用法?Python Wares.setwareinbar怎么用?Python Wares.setwareinbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类polls.models.Wares
的用法示例。
在下文中一共展示了Wares.setwareinbar方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: nymodtagelse
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def nymodtagelse(request):
message = []
try:
truthval = Openandclose.isbaropen()
except Noopeningsyet:
truthval = False
message.append("")
if (truthval):
#TODO: make it distinct if there are no wares or bar is open
allwares = Wares.objects.all().filter(id=0)
message.append("Varemodtagelse er ikke muligt med åben bar")
context = {'allwares': allwares, 'message': message}
else:
allwares = Wares.objects.all()
for ware in allwares:
try:
if request.POST:
valgbar = request.POST["valgbar." + str(ware.id)]
valglager = request.POST['valglager.' + str(ware.id)]
valgbar = int(valgbar) + ware.inbar
valglager = int(valglager) + ware.instockroom
Wares.setwareinbar(ware.id, valgbar)
Wares.setwareinstockroom(ware.id, valglager)
except KeyError:
message.append("OBS: metoden virker ikke for " + ware.warename + "Tilkald udvikleren.")
#return render(request, 'polls/modtagelser/ny.html', context)
except ValueError:
message.append("OBS: alt blev ikke udfyldt fra" + ware.warename)
#return render(request, 'polls/modtagelser/ny.html', context)
Refreshstock.insert()
if request.POST:
message.append("Ændringerne er nu foretaget")
context = {'allwares': allwares, 'message': message}
return render(request, 'polls/modtagelser/ny.html', context)
示例2: test_Waresnamehistory1
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_Waresnamehistory1(self):
self.assertEqual(len(Waresnamehistory.objects.all().filter(warename="Carlsberg")) == 0, True)
self.assertEqual(len(Waresnamehistory.objects.all()) == 0, True)
Wares.insert("Carlsberg")
try:
Wares.insert("Carlsberg")
except Alreadymade:
pass
Wares.insert("Carlsberg Light")
Wares.insert("Yankeebar")
Wares.insert("Haribo Clickmix")
Wares.insert("Mokai")
Wares.insert("Heineken")
Wares.insert("Tuborg")
self.assertEqual(len(Waresnamehistory.objects.all().filter(warename="Carlsberg")) == 1, True)
self.assertEqual(len(Waresnamehistory.objects.all()) == 7, True)
Wares.setwarename(1, "Carlsberg xtreme")
Wares.setwarename(7, "Tuborg guld")
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
Wares.getthis(1)
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
Wares.getopeningwares()
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
Wares.getstdprice(1)
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
Wares.setwareinbar(1,10)
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
Wares.setwareinstockroom(2,300)
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
Wares.setstandardprice(1,1)
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
Wares.deletethis(1)
self.assertEqual(len(Waresnamehistory.objects.all()) == 9, True)
示例3: test_setinbar
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_setinbar(self):
Wares.insert("Carslberg")
Wares.insert("Tuborg")
Wares.setwareinbar(1,5)
Wares.setwareinbar(2,10)
self.assertEqual(len(Wares.objects.all().filter(inbar=5)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(inbar=10)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(inbar=2)) == 2, False)
示例4: test_setinstockroom
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_setinstockroom(self):
Wares.insert("Carslberg")
Wares.insert("Tuborg")
Wares.insert("Heineken")
Wares.setwareinstockroom(1,5)
Wares.setwareinstockroom(2,10)
Wares.setwareinbar(3,20)
self.assertEqual(len(Wares.objects.all().filter(instockroom=5)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(instockroom=10)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(instockroom=20)) == 1, False)
self.assertEqual(len(Wares.objects.all().filter(instockroom=2)) == 2, False)
示例5: test_getwaresforopening
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_getwaresforopening(self):
Wares.insert("Carslberg")
Wares.insert("Tuborg")
Wares.insert("Heineken")
self.assertEqual(len(Wares.objects.all()) == 3, True)
self.assertEqual(len(Wares.getopeningwares()) == 0, True)
Wares.setwareinbar(1,1)
self.assertEqual(len(Wares.getopeningwares()) == 1, True)
Wares.setwareinstockroom(1,2)
self.assertEqual(len(Wares.getopeningwares()) == 1, True)
Wares.setwareinstockroom(2,2)
self.assertEqual(len(Wares.getopeningwares()) == 2, True)
示例6: test_standardprice
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_standardprice(self):
Wares.insert("Carslberg")
Wares.insert("Tuborg")
Wares.insert("Heineken")
Wares.setwareinbar(1,5)
Wares.setwareinstockroom(1,5)
Wares.setstandardprice(1,500) #Carlsberg er dyrt
Wares.setstandardprice(2,50)
Wares.setstandardprice(3,50)
self.assertEqual(len(Wares.objects.all().filter(standardprice=500)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(standardprice=50)) == 2, True)
self.assertEqual(len(Wares.objects.all()) == 3, True)
示例7: test_getstdprice
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_getstdprice(self):
Wares.insert("Carslberg")
Wares.insert("Tuborg")
Wares.setwareinbar(1,5)
Wares.setwareinbar(2,10)
self.assertEqual(len(Wares.objects.all().filter(inbar=5)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(inbar=10)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(inbar=2)) == 2, False)
Wares.setstandardprice(1,10)
Wares.setstandardprice(2,30)
self.assertEqual(Wares.getstdprice(1) == 10, True)
self.assertEqual(Wares.getstdprice(1) == 30, False)
self.assertEqual(Wares.getstdprice(2) == 30, True)
示例8: luk
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def luk(request):
# Used for displaying information to user
message = []
# Test if there is an open bar
if (not Openandclose.isbaropen()):
allwares = Wares.objects.all().filter(id=0)
message.append("baren er allerede lukket")
else:
allwares = Wares.getopeningwares()
for ware in allwares:
try:
valgbar = ware.inbar
valglager = ware.instockroom
if request.POST:
if ("valgbar." + str(ware.id)) in request.POST:
valgbar = request.POST["valgbar." + str(ware.id)]
else:
raise MyError("valgbar for #" + str(ware.id) + " gik galt")
if ("valglager." + str(ware.id)) in request.POST:
valglager = request.POST['valglager.' + str(ware.id)]
else:
raise MyError("valglager for #" + str(ware.id) + " gik galt")
Wares.setwareinbar(ware.id, int(valgbar))
Wares.setwareinstockroom(ware.id, int(valglager))
except KeyError:
message.append("luk-metoden virker ikke. Tilkald udvikler")
#return render(request, 'polls/Luk.html', context)
except ValueError:
message.append(ware.warename + " blev ikke udfyldt")
#return render(request, 'polls/Luk.html', context)
kommentar = ""
if request.POST:
if ("kommentar" in request.POST):
kommentar = request.POST["kommentar"]
Openandclose.closebar(kommentar)
else:
Openandclose.closebar(kommentar)
message.append("Tillykke! Du har nu lukket baren.")
context = {'allwares': allwares,'message':message}
return render(request, 'polls/Luk.html', context)
示例9: test_Waresdeletehistory
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_Waresdeletehistory(self):
self.assertEqual(len(Waresdeletehistory.objects.all()) == 0, True)
Wares.insert("Carlsberg")
try:
Wares.insert("Carlsberg")
except Alreadymade:
pass
Wares.insert("Carlsberg Light")
Wares.insert("Yankeebar")
Wares.insert("Haribo Clickmix")
Wares.insert("Mokai")
Wares.insert("Heineken")
Wares.insert("Tuborg")
Wares.deletethis(1)
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.setwarename(2, "Carlsberg xtreme")
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.getthis(2)
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.getopeningwares()
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.getstdprice(2)
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.setwareinbar(2,10)
Wares.setwareinbar(2,20)
Wares.setwareinbar(3,11)
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.setwareinstockroom(3,300)
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.setstandardprice(2,1)
self.assertEqual(len(Waresdeletehistory.objects.all()) == 1, True)
Wares.deletethis(5)
self.assertEqual(len(Waresdeletehistory.objects.all()) == 2, True)
示例10: test_getprice
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def test_getprice(self):
Wares.insert("Carslberg")
Wares.insert("Tuborg")
Wares.insert("Heineken")
Wares.setwareinbar(1,5)
Wares.setwareinstockroom(1,5)
Wares.setstandardprice(1,500) #Carlsberg er dyrt
Wares.setstandardprice(2,50)
Wares.setstandardprice(3,50)
self.assertEqual(len(Wares.objects.all().filter(standardprice=500)) == 1, True)
self.assertEqual(len(Wares.objects.all().filter(standardprice=50)) == 2, True)
self.assertEqual(len(Wares.objects.all()) == 3, True)
Events.insert("Paaske")
Events.insert("frebar")
Events.insert("hverdag")
Pricesinevent.insert(1,1)
Pricesinevent.insert(1,2)
Pricesinevent.insert(1,3)
Pricesinevent.insert(2,1)
Pricesinevent.insert(2,2)
Pricesinevent.insert(2,3)
Pricesinevent.setprice(1,1,-50)
self.assertEqual(Extrafunctions.getprice(1,1) == 450, True)
示例11: aaben
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def aaben(request, event_id):
event = Events.getthis(event_id)
message = []
# Test if there is an open bar
try:
truthval = Openandclose.isbaropen()
except Noopeningsyet:
truthval = False
# If the bar is open no wares will be displayed
if (truthval):
#TODO: make it distinct if there are no wares or bar is open
allwares = Wares.objects.all().filter(id=0)
eventpris = 0
message.append("baren er allerede åben")
context = {'allwares': allwares, 'event': event, 'eventpris': eventpris}
else:
allwares = Wares.getopeningwares()
# TODO: consider if this can be removed
if (len(allwares) == 0):
eventpris = 0
#context = {'allwares': allwares, 'event': event, 'eventpris': eventpris}
#TODO: if the change may not commit unless all forms have been filled, it might be necessary to run through all wares once to test that things are in order
else:
for ware in allwares:
try:
eventpris = Pricesinevent.geteventprice(ware.id, event.id)
valgbar = ware.inbar
valglager = ware.instockroom
if request.POST:
if ("valgbar." + str(ware.id)) in request.POST:
valgbar = request.POST["valgbar." + str(ware.id)]
else:
raise MyError("valgbar for #" + str(ware.id) + " gik galt")
if ("valglager." + str(ware.id)) in request.POST:
valglager = request.POST['valglager.' + str(ware.id)]
else:
raise MyError("valglager for #" + str(ware.id) + " gik galt")
Wares.setwareinbar(ware.id, valgbar)
Wares.setwareinstockroom(ware.id, valglager)
except KeyError:
message.append("aaben-metoden virker ikke. Tilkald udvikler")
except ValueError:
message.append(ware.warename + " blev ikke udfyldt")
kommentar = ""
if request.POST:
if ("kommentar" in request.POST):
kommentar = request.POST["kommentar"]
Openandclose.openbar(event_id, kommentar)
else:
Openandclose.openbar(event_id, kommentar)
message.append("Tillykke! Du har nu åbnet baren.")
context = {'allwares': allwares, 'event': event, 'eventpris': eventpris, 'message': message}
return render(request, 'polls/Aaben.html', context)
示例12: clean_inbar
# 需要导入模块: from polls.models import Wares [as 别名]
# 或者: from polls.models.Wares import setwareinbar [as 别名]
def clean_inbar(self):
inbar = self.cleaned_data['inbar']
if (inbar == None):
pass
else:
Wares.setwareinbar(self.wareid, inbar)