当前位置: 首页>>代码示例>>Python>>正文


Python models.Wares类代码示例

本文整理汇总了Python中polls.models.Wares的典型用法代码示例。如果您正苦于以下问题:Python Wares类的具体用法?Python Wares怎么用?Python Wares使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Wares类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: nymodtagelse

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)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:34,代码来源:views.py

示例2: waredelete

def waredelete(request, wares_id):
    ware = Wares.getthis(wares_id)
    message = []
    if "slet" in request.POST:
        Wares.deletethis(ware.id)
        message.append("Varen er nu slettet. Oplysninger om varen ligger stadigt gemt i historikken")
    return render(request, 'polls/slet_vare.html', {'message': message, 'ware': ware})
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:7,代码来源:views.py

示例3: test_insertware

 def test_insertware(self):
     #Tests that a ware can be inserted with insert function
     Wares.insert("Carlsberg")
     self.assertEqual(len(Wares.objects.all().filter(warename="Carlsberg")) == 1, True)
     self.assertEqual(len(Wares.objects.all().filter(warename="Calrsberg")) == 1, False)
     Wares.insert("Tuborg")
     self.assertEqual(len(Wares.objects.all().filter(warename="Tuborg")) == 1, True)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:7,代码来源:tests.py

示例4: clean_price

 def clean_price(self):
     price = self.cleaned_data['price']
     if (price == None):
         pass
     else:
         Ourwares = Waresingroup.getwares(self.wgid)
         for warerelation in Ourwares:
             Wares.setstandardprice(warerelation.ware.id, price)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:8,代码来源:forms.py

示例5: clean_name

 def clean_name(self):
     name = self.cleaned_data['name']
     if (name == None):
         pass
     elif (name == ""):
         pass
     else:
         if Wares.nameisavailable(name):
             Wares.setwarename(self.wareid, name)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:9,代码来源:forms.py

示例6: test_insertgrouping

 def test_insertgrouping(self):
     Wares.insert("Carlsberg")
     Wares.insert("Tuborg")
     Waregroups.insert("Luxusoeller")
     Waregroups.insert("Basisoeller")
     Waresingroup.insert(1,1)
     Waresingroup.insert(1,2)
     Waresingroup.insert(2,1)
     Waresingroup.insert(2,2)
     self.assertEqual(len(Wares.objects.all()) == 2, True)
     self.assertEqual(len(Waregroups.objects.all()) == 2, True)
     self.assertEqual(len(Waresingroup.objects.all()) == 2, True)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:12,代码来源:tests.py

示例7: test_deleteonrelations1

 def test_deleteonrelations1(self):
     Wares.insert("Carlsberg")
     Wares.insert("Tuborg")
     Waregroups.insert("Luxusoeller")
     Waregroups.insert("Basisoeller")
     Waresingroup.insert(1,1)
     Waresingroup.insert(1,2)
     Waresingroup.insert(2,1)
     Waresingroup.insert(2,2)
     self.assertEqual(len(Waresingroup.objects.all()) == 2, True)
     Waregroups.deletethis(2)
     self.assertEqual(len(Waresingroup.objects.all()) == 0, True)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:12,代码来源:tests.py

示例8: test_setinbar

 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)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:8,代码来源:tests.py

示例9: luk

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)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:44,代码来源:views.py

示例10: test_insertpricing

 def test_insertpricing(self):
     Wares.insert("Carlsberg")
     Wares.insert("Tuborg")
     Wares.setstandardprice(1,500) #Carlsberg er dyrt
     Wares.setstandardprice(2,50)
     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)
     self.assertEqual(len(Events.objects.all()) == 3, True)
     self.assertEqual(len(Pricesinevent.objects.all()) == 6, True)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:17,代码来源:tests.py

示例11: detail

def detail(request, wares_id):
    ware = Wares.getthis(wares_id)
    waregroups = Waresingroup.getwaregroups(wares_id)
    try:
        waregroup = waregroups[0].waregroup
    except IndexError:
        waregroup = None
    if request.method == "POST":
        form = WareForm(request.POST)
        form.change_wareid(wares_id)
        #TODO: make redirect work so changes appear
        #return redirect(, {'form': form, 'ware':ware})
    else:
        form = WareForm()
        form.change_wareid(wares_id)
    return render(request, 'polls/detail.html', {'form': form, 'ware':ware, 'waregroup': waregroup})
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:16,代码来源:views.py

示例12: test_getwaregroups

 def test_getwaregroups(self):
     Wares.insert("Carlsberg")
     Wares.insert("Tuborg")
     Wares.insert("Heineken")
     Waregroups.insert("Luxusoeller")
     Waregroups.insert("Basisoeller")
     Waresingroup.insert(1,1)
     Waresingroup.insert(1,2)
     Waresingroup.insert(2,1)
     Waresingroup.insert(2,2)
     Waresingroup.insert(3,1)
     self.assertEqual(len(Waresingroup.getwaregroups(1)) == 1, True)
     self.assertEqual(len(Waresingroup.getwaregroups(2)) == 1, True)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:13,代码来源:tests.py

示例13: createware

def createware(request):
    error = [] 
    if ('valgnavn' in request.POST): 
        newname = request.POST['valgnavn']
        if newname == "":
            error.append("Du skal vælge et navn")
        elif 'ja' in request.POST:
            Wares.insert(newname)
            ware = Wares.get_last()
            form = WareForm()
            Wares.insert(newname + " (åbnet vare)")
            #Sends user to details for ware
            return render(request, 'polls/detail.html', {'form': form,'ware':ware})

        else:
            Wares.insert(newname)
            ware = Wares.get_last()
            form = WareForm()
            #Sends user to details for ware
            return render(request, 'polls/detail.html', {'form': form, 'ware':ware})
    return render(request, 'polls/skab_vare.html', {'error': error})    
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:21,代码来源:views.py

示例14: test_geteventprice

    def test_geteventprice(self):
        Wares.insert("Carlsberg")
        Wares.insert("Tuborg")
        Wares.setstandardprice(1,500) #Carlsberg er dyrt
        Wares.setstandardprice(2,50)
        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)
        
        newprice = Pricesinevent.geteventprice(1,1)
        self.assertEqual(newprice==500, True)

        Pricesinevent.setprice(1,1,-50)
        
        newprice = Pricesinevent.geteventprice(1,1)
        self.assertEqual(newprice==500, False)
        self.assertEqual(newprice==450, True)
        
        Pricesinevent.setprice(1,1,-50)
        newprice = Pricesinevent.geteventprice(1,1)
        self.assertEqual(newprice==450, True)

        Pricesinevent.setprice(2,1,-50)
        newprice = Pricesinevent.geteventprice(2,1)
        self.assertEqual(newprice==0, True)

        Pricesinevent.setprice(2,1,-100)
        newprice = Pricesinevent.geteventprice(2,1)
        self.assertEqual(newprice==-50, True)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:36,代码来源:tests.py

示例15: test_getthis

 def test_getthis(self):
     Wares.insert("Carlsberg")
     Wares.insert("Tuborg")
     Wares.insert("Heineken")
     Waregroups.insert("Luxusoeller")
     Waregroups.insert("Basisoeller")
     Waresingroup.insert(1,1)
     Waresingroup.insert(1,2)
     Waresingroup.insert(2,1)
     Waresingroup.insert(2,2)
     Waresingroup.insert(3,1)
     test1 = Waresingroup.getthis(1,2)
     self.assertEqual(test1.ware.warename == "Carlsberg", True)
     self.assertEqual(test1.waregroup.wgname == "Basisoeller", True)
     test2 = Waresingroup.getthis(3,1)
     self.assertEqual(test2.ware.warename == "Heineken", True)
     self.assertEqual(test2.waregroup.wgname == "Luxusoeller", True)
开发者ID:cejsing,项目名称:Softwareudvikling,代码行数:17,代码来源:tests.py


注:本文中的polls.models.Wares类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。