コード例 #1
0
def amount_test():
	db._reset_db()												#1

	mfg = "Johnnie Walker"										#2
	name = "Black Label"
	typ = "Blended Scotch"

	db.add_bottle_type(mfg, name, typ)							#3

	db.add_to_inventory(mfg, name, "1000ml")					#4
	assert db.get_liquor_amount(mfg, name) == "1000.0ml"
	db.add_to_inventory(mfg, name, "2000ml")					#5
	assert db.get_liquor_amount(mfg, name) == "3000.0ml"
	db.add_to_inventory(mfg, name, "3oz")						#6
	assert db.get_liquor_amount(mfg, name) == "3088.7205ml"
コード例 #2
0
ファイル: app.py プロジェクト: mmarinetti/Python-Server
    def inventory(self, environ, start_response):
        content_type = 'text/html'
        data = """\
<html>
<head>
<title>Inventory</title>
<style type='text/css'>
h1 {color:red;}
body {
font-size: 14px;
}
</style>
</head>
<body>
<h1>Inventory:</h1>
<table>
  <tr>
    <td>Liquor:</td>
    <td>Amount(ml):</td>
  </tr>
"""
        for mfg, liquor in db.get_liquor_inventory():
            data += '<tr>'
            data += '<td>'+str(mfg)+' '+str(liquor)+'</td>'
            data += '<td>'+str(db.get_liquor_amount(mfg, liquor))+'</td>'
            data += '</tr>'
        data += """\
</table>
<a href='./'>Back To Index</a>
</body>
</html>
"""
       
        start_response('200 OK', list(html_headers))
        return [data]
コード例 #3
0
ファイル: test_drinkz.py プロジェクト: benblaut/cse491-drinkz
def test_get_liquor_amount_1():
    db._reset_db()

    db.add_bottle_type('Johnnie Walker', 'Black Label', 'blended scotch')
    db.add_to_inventory('Johnnie Walker', 'Black Label', '1000 ml')
    amount = db.get_liquor_amount('Johnnie Walker', 'Black Label')
    assert amount == 1000.0, amount
コード例 #4
0
ファイル: recipes.py プロジェクト: madalynrose/cse491-drinkz
    def need_ingredients(self):
		needed = []
		#loop through ingredients
		for (typ, needed_amount) in self.ingredients:
			needed_amount = db.convert_to_ml(needed_amount)
			#check supply
			supply = db.check_inventory_for_type(typ)
			print supply
			if supply:
				total_amount = 0
				for m,l,_ in supply:
					total_amount = db.get_liquor_amount(m,l)
				if needed_amount - total_amount > 0:
					#we don't have enough :(
					needed_amount = needed_amount - total_amount
				else:
					continue
			
			needed.append((typ, needed_amount))

		if needed == []:
			return False
		else:

			return needed
コード例 #5
0
ファイル: app.py プロジェクト: zippleer/cse491-drinkz
 def inventory(self, environ, start_response):
     content_type = 'text/html'
     data = """
     <table border=\"1\" cellpadding =\"5\">
     <tr><th>Manfacturer</th><th>Liquor</th><th>Amount</th></tr>
     """
     for mfg,liquor in db.get_liquor_inventory():
         data = data + "<tr><td> "+ mfg +" </td><td> "+liquor+" </td><td> "+str(db.get_liquor_amount(mfg,liquor)) + " ml"+" </td></tr>"
     data = data + "</table>"
     
     data = data + """</br>
 </br>
 <h2> Menu </h2>
 <a href='/'>Home</a></br>
 <a href='recipes'>Recipes</a></br>
 <a href='inventory'>Inventory</a></br>
 <a href='liquor_types'>Liquor Types</a></br>
 <a href='convert_to_ml'>Convert Amount</a></br>
 <a href='recipe_input'>Add Recipe</a></br>
 <a href='type_form'>Add Bottle Type</a></br>
 <a href='inv_form'>Add to Inventory</a></br>
 """
     data = self.buildHtmlPage("Inventory","",data)
     start_response('200 OK', [('Content-type', content_type)])
     return [data]
コード例 #6
0
ファイル: app.py プロジェクト: khessiny/cse491-drinkz
    def inventory(self, environ, start_response):
		if self.get_name(environ) != False:
			namenow = self.get_name(environ)
			tlist = set()
			addin=""
			for mfg, liquor in db.get_liquor_inventory():  #for every item returned 
					if (mfg,liquor) in tlist:  #check if in posted list  or go on
						continue
					else:
						tlist.add((mfg,liquor)) #add to posted list 
						quant = db.get_liquor_amount(mfg,liquor) #get quaniity
						newquant=str(quant)

					addin += "<li><div class=\"ui-grid-b\"><div class=\"ui-block-a\" style=\"width:50%\">" + mfg + "</div><div class=\"ui-block-b\" style=\"width:25%\">" + liquor + "</div><div class=\"ui-block-c\" style=\"width:25%\">" + newquant + " (ml)</div></div></li>"
			
			vars = dict(title="Inventory",name=namenow,inventory=addin)
			template = env.get_template("inventory.html")
			data = template.render(vars)
			content_type = 'text/html'
			start_response('200 OK', list(html_headers))
			return [str(data)]
		else:
			headers = list(html_headers)
			headers.append(('Location', '/login'))
			start_response('302 Found', headers)
			return ["Redirect to /login..."]
コード例 #7
0
ファイル: app.py プロジェクト: dwigell/cse491-drinkz
    def inventory(self, environ, start_response):

        data = """
<html>
<head>
<title>CSE491-Inventory</title>
<style type = 'text/css'>
h1 {color:green;}
body {font-size: 18px;}
</style>
</head>
<body>
"""
        
        data += "<b><h1>Inventory</h1></b><p>Manufacturer, Liquor Type, Amount (ml)</p><ul>"

        for mfg, liquor in db.get_liquor_inventory():
            data += "<p> </p>"
            data += "<li> %s,  %s, %s" % (mfg, liquor, db.get_liquor_amount(mfg,liquor))

        data += "</ul>"

        data += """
<p><a href='/'>Home</a>
</p>
<p><a href='recipes'>Recipes</a>
</p>
<p><a href='liquorTypes'>Liquor Types</a>
</p>
</body>
</html>
"""
        start_response('200 OK', list(html_headers))
        return [data]
コード例 #8
0
ファイル: recipes.py プロジェクト: mbozugrace/HappyHours
	def need_ingredients(self):
		i = 0
		#get the types from the database
		for val in db.get_all_recipes():
			while i < len(db.get_all_recipes().values()):
				types =  db.get_Type(db.get_all_recipes().values()[i][0][0])
				print types
				amt = db.get_liquor_amount(types[0], types[1])
				print amt[0]
				recipe_Amounts = db.get_all_recipes().values()[i][0][1].split(' ')
				print recipe_Amounts

				conversion = db.convert_ml(int(recipe_Amounts[0]), recipe_Amounts[1])

				print conversion
	
				if amt[0] < conversion:
					req = conversion - amt[0]
					req_type = db.get_all_recipes().values()[i][0][0], req
					replenish.append(req_type)
					repl[db.get_all_recipes().keys()[i]] = "Yes"
				else:
					msg = "we enough of that type"
					repl[db.get_all_recipes().keys()[i]] = "No"



				i = i + 1

		return repl
コード例 #9
0
ファイル: app.py プロジェクト: mill2121/cse491-drinkz
    def inventory(self, environ, start_response):
        content_type = 'text/html'
        text = """

<!DOCTYPE HTML>
<html>
<head>
<title>Liquor Inventory</title>
<style type='text/css'>
h1 {text-decoration:underline; text-align:center; color:red;}
body { font-size:14px; }
</style>
</head>
<body>
<h1>Liquor Inventory</h1>
<ul>
    <li><a href='/'>Home</a></li>
    <li><a href='/recipes'>List Recipes</a></li>
    <li><a href='/inventory'>List Inventory</a></li>
    <li><a href='/liquor_types'>List Liquor Types</a></li>
</ul>
<hr />
<ul>
"""
        liquor_inventory = list(db.get_liquor_inventory())
        for (m,l) in liquor_inventory:
            amount = db.get_liquor_amount(m,l)
            text += "\t<li>" + m + " - " + l + " - " + str(amount) + "ml</li>\n"
        text += '</ul>'
        text += '</body></html>'

        data = text
        start_response('200 OK', list(html_headers))
        return [data]
コード例 #10
0
ファイル: app.py プロジェクト: andre223/cse491-drinkz
def inventoryList():
    # this sets up jinja2 to load templates from the 'templates' directory
    loader = jinja2.FileSystemLoader("../drinkz/templates")
    env = jinja2.Environment(loader=loader)

    # pick up a filename to render
    filename = "pages.html"

    inventoryList = list()
    for (m, l) in db.get_liquor_inventory():
        inventoryList.append(str(m) + " " + str(l) + " " + str(db.get_liquor_amount(m, l)) + " ml")

    # variables for the template rendering engine
    vars = dict(
        title="Inventory List",
        addtitle="Add to Inventory",
        form="""<form action='addInventory'>
Manufacturer<input type='text' name='mfg' size'20'><p>
Liquor<input type='text' name='liquor' size'20'><p>
Amount<input type='text' name='amt' size'20'><p>
<input type='submit'>
</form>""",
        names=inventoryList,
    )

    template = env.get_template(filename)

    x = template.render(vars).encode("ascii", "ignore")
    return x
コード例 #11
0
ファイル: recipes.py プロジェクト: LXlagent3/cse491-drinkz
    def need_ingredients(self):

        missing_list = []

        bottle_type_list = []
        
	for i in self.ingredients:
	    for item in db._bottle_types_db:
		if  i[0] == item[2]:
		    bottle_type_list.append(item)


        amounts_list = []

	for i in bottle_type_list:
	    if db.check_inventory(i[0], i[1]):
		amount = (i[0], i[2], db.get_liquor_amount(i[0], i[1]))
		amounts_list.append(amount)        
                
        for i in self.ingredients:
            amount = 0.0
            for item in amounts_list: 
                if i[0]==item[1]:
                    if amount < float(item[2]): 
                        amount = float(item[2])
            ing_amount = convert.convert_ml(i[1])            
            if float(amount) < float(ing_amount):
                needed = float(ing_amount)-float(amount)
                needed_tup = (i[0], needed)
                missing_list.append(needed_tup)


	return missing_list
コード例 #12
0
ファイル: recipes.py プロジェクト: mmarinetti/Python-Server
    def need_ingredients(self):
        need = []
        amount = 0
        for i in self.ingredients:
            typehave = db.check_inventory_for_type(i[0])
            most = 0
            for (m, l) in typehave:
                if db.get_liquor_amount(m, l) > most:
                    amount = db.get_liquor_amount(m, l)
                    most = amount

            amount = db.convert_to_ml(i[1])-amount
            if amount > 0:
                need.append((i[0], amount))

        return need
コード例 #13
0
def test_json_add_to_inventory():
    db._reset_db()

    call_remote(method='add_liquor_type', params=['Johnnie Walker', 'black label',
                                                  'blended scotch'], id=1)
    call_remote(method='add_to_inventory', params=['Johnnie Walker', 'black label',
                                                   '4 oz'], id=1)

    assert db.get_liquor_amount('Johnnie Walker', 'black label') == 118.294
コード例 #14
0
ファイル: app.py プロジェクト: Chris498/cse491-drinkz
    def inventory(self, environ, start_response):
        start_response("200 OK", list(html_headers))

        title = "inventory"
        inventory = [ (m, l, db.get_liquor_amount(m, l)) \
                      for (m, l) in db.get_liquor_inventory() ]
        
        template = env.get_template("inventory.html")
        return str(template.render(locals()))
コード例 #15
0
ファイル: my_tests.py プロジェクト: benblaut/cse491-drinkz
def test_get_liquor_amount_3():
    db._reset_db()

    db.add_bottle_type('Johnnie Walker', 'Black Label', 'blended scotch')
    db.add_to_inventory('Johnnie Walker', 'Black Label', '1000 ml')
    db.add_to_inventory('Johnnie Walker', 'Black Label', '750 g')
    db.add_to_inventory('Johnnie Walker', 'Black Label', '250 ml')
    amount = db.get_liquor_amount('Johnnie Walker', 'Black Label')

    print "\n%s" % amount
コード例 #16
0
ファイル: test_drinkz.py プロジェクト: benblaut/cse491-drinkz
def test_get_liquor_amount_2():
    db._reset_db()

    db.add_bottle_type('Johnnie Walker', 'Black Label', 'blended scotch')
    
    data = "Johnnie Walker,Black Label,1000 ml"
    fp = StringIO(data)                 # make this look like a file handle
    n = load_bulk_data.load_inventory(fp)

    amount = db.get_liquor_amount('Johnnie Walker', 'Black Label')
    assert amount == 1000.0, amount
コード例 #17
0
ファイル: make_html.py プロジェクト: birdanth/cse491-drinkz
def inventory():
    html = ""
    for m, l in db.get_liquor_inventory():
        amount = db.get_liquor_amount(m, l)
        html += '<li>%s' % m
        html += ' - %s' % l
        html += ' - %s</li>' % amount
    html += """</ul>"""

    inv =  env.get_template('inventory.html')
    return inv.render(inventory=html).encode('ascii', 'ignore')
コード例 #18
0
ファイル: app.py プロジェクト: Ryalian/cse491-drinkz
    def inventory(self, environ, start_response):
	data = direction
	inventory = "<ol>"
	for liquor in db.get_liquor_inventory():
		mfg = liquor[0]
		l   = liquor[1]
		amount = db.get_liquor_amount(mfg,l)
		inventory += "<li>" + mfg + ", " + l + ": " + str(amount) + "ml </li>\n"
	data = data + inventory + "</ol>"
        data = css_html.cssgen('blue','30','Inventory') + data + css_html.htmlgen()
	start_response('200 OK', list(html_headers))
	return [data]
コード例 #19
0
ファイル: recipes.py プロジェクト: dwigell/cse491-drinkz
    def need_ingredients(self):

        missing_list = []

        # PUT ALL THE LIQUOR TYPES NEEDED IN A LIST(see if they exist) ===========

        bottle_type_list = []
        
	for i in self.ingredients:
	    for item in db._bottle_types_db:
		if  i[0] == item[2]:
		    bottle_type_list.append(item)

        #print bottle_type_list, "bottle_type_list"

        #=========================================================================


        # CHECK INVENTORY FOR THOSE LIQUORS(put them in a list of tuples)=========

        amounts_list = []

	for i in bottle_type_list:
	    if db.check_inventory(i[0], i[1]):
		amount = (i[0], i[2], db.get_liquor_amount(i[0], i[1]))
		amounts_list.append(amount)


        #print amounts_list, "amounts_list"
            
        
        #=========================================================================

        # CREATE THE MISSING LIST=================================================

        
                
        for i in self.ingredients:
            amount = 0.0
            for item in amounts_list: #replace smaller amount with larger
                if i[0]==item[1]:
                    if amount < float(item[2]): 
                        amount = float(item[2])
            ing_amount = convert.convert_ml(i[1])#convert the ingredient to ml
            
            if float(amount) < float(ing_amount):#compare the amount with ing
                needed = float(ing_amount)-float(amount)
                needed_tup = (i[0], needed)
                missing_list.append(needed_tup)#add to missing list


	return missing_list
コード例 #20
0
ファイル: app.py プロジェクト: newrockm/cse491-drinkz
    def show_inventory(self, environ, start_response):
        vars = {}
        inventory = []
        if environ['REQUEST_METHOD'].endswith('POST'):
            vars['error'] = self.do_add_inventory(environ)

        for (mfg, liquor) in db.get_liquor_inventory():
            amount = db.get_liquor_amount(mfg, liquor)
            inventory.append((mfg, liquor, amount))
        vars['inventory'] = inventory
        data = self._render('inventory.html', 'Show Inventory', vars)
        start_response('200 OK', list(html_headers))
        return [data]
コード例 #21
0
ファイル: test_drinkz.py プロジェクト: Befall/cse491-drinkz
def test_script_load_inventory_1():
    db._reset_db()

    scriptpath = 'bin/load-liquor-inventory'
    module = imp.load_source('llt', scriptpath)
    exit_code = module.main([scriptpath, 'test-data/bottle-types-data-1.txt', 'test-data/inventory-data-1.txt'])

    assert exit_code == 0, 'non zero exit code %s' % exit_code

    assert db._check_bottle_type_exists('Johnnie Walker', 'Black Label')
    
    amount = db.get_liquor_amount('Johnnie Walker', 'Black Label')
    assert amount == 1234.0, amount
コード例 #22
0
ファイル: recipes.py プロジェクト: jonesd52/cse491-drinkz
    def need_ingredients(self):
        missing = []
        for (typ,need) in self.ingredients:
	    database_liquors = db.check_for_type(typ)
	    amt = db.convert_to_ml(need)
	    liq_max = 0.0
	    for (m,l) in database_liquors:
	        liq_amt = db.get_liquor_amount(m,l)
	        if(liq_amt > liq_max):
	            liq_max = liq_amt
	    if(liq_max < amt):
	        necesito = amt - liq_max
	        missing.append((typ,necesito))
	return missing
コード例 #23
0
ファイル: test_drinkz.py プロジェクト: Befall/cse491-drinkz
def test_get_liquor_amount_5():
    db._reset_db()

    db.add_bottle_type('Johnnie Walker', 'Black Label', 'blended scotch')
    
    data = "Johnnie Walker,Black Label,1000 ml\nJohnnie Walker,Black Label,50 gallons"
    fp = StringIO(data)                 # make this look like a file handle
    n = load_bulk_data.load_inventory(fp)

    try:
        amount = db.get_liquor_amount('Johnnie Walker', 'Black Label')
        assert 0
    except:
        pass                            # we expect to see an error about gallons
コード例 #24
0
ファイル: recipes.py プロジェクト: credwards27/cse491-drinkz
 def need_ingredients(self):
     missing = []
     
     for (type, amt) in self.ingredients:
         # get a list of what types are in inventory
         have_types = db.check_inventory_for_type(type)
         
         # get the amount of the needed type that is already in the inventory
         have_amount = 0.0
         
         for (mfg, lqr) in have_types:
             # only the highest amount of one type counts as the total amount
             # this prevents mixing alcohols
             if db.get_liquor_amount(mfg,lqr) > have_amount:
                 have_amount = db.get_liquor_amount(mfg,lqr)
         
         # find out how much is needed
         need_amount = have_amount - to_ml(amt)
         
         if need_amount < 0.0:
             missing.append((type, need_amount*-1))
     
     return missing
コード例 #25
0
ファイル: app.py プロジェクト: vogelmi3-msu/cse491-drinkz
    def add_to_inventory_recv(self, environ, start_response):
        formdata = environ['QUERY_STRING']
        results = urlparse.parse_qs(formdata)

        mfg = results['mfg'][0]
        liquor = results['liquor'][0]
        amount = results['amount'][0]
        myBool = db.check_inventory(mfg,liquor)
        if myBool == True:
            intial_amt = db.get_liquor_amount(mfg,liquor)
        else:
            intial_amt = 0
        db.add_to_inventory(mfg, liquor, amount)
        db.save_db('bin/sample_database')
        taste_of_success = db.check_inventory(mfg, liquor)
        amt_success = db.get_liquor_amount(mfg,liquor)
        if taste_of_success == True and amt_success > intial_amt:
            data = generate_html.generate_liquor_types_html()

        else:
            content_type = 'text/html'
            data = """  <html>
    <head>
    <title>Failure to Add Liquor!</title>
        <style type ="text/css">
        h1{color:red;}
    </style>
    </head>
    <body>"""
            data += """Failed to add Liquor type, please try again!"""
            data += generate_html.generate_menu()
            data += """
</body>
</html>
"""     
        start_response('200 OK', list(html_headers))
        return [data]
コード例 #26
0
ファイル: recipes.py プロジェクト: AdamPro13/cse491-drinkz
    def need_ingredients(self):
        myList = list()
        for currentIngredient in self._myIngredients:
            listOfMandLTuples = db.check_inventory_for_type(currentIngredient[0])
            amountInStock = 0
            for myTuple in listOfMandLTuples:
                val = db.get_liquor_amount(myTuple[0],myTuple[1])
                if val>amountInStock:
                    amountInStock = val
            amountInDebt = amountInStock - db.convert_to_ml(currentIngredient[1])

            if ( amountInDebt < 0 ):
                myList.append((currentIngredient[0],amountInDebt*-1.))

        return myList
コード例 #27
0
ファイル: recipes.py プロジェクト: andre223/cse491-drinkz
    def need_ingredients(self):
	missingList = list()        
	for ingredient in self._ingredients:   #go through current ingredients
	    listOfTuples = db.check_inventory_for_type(ingredient[0])
	    
	    stockAmount = 0            
	    for tuple in listOfTuples:                
		amt = db.get_liquor_amount(tuple[0],tuple[1])                
		if amt>stockAmount:                    
		    stockAmount = amt
	    debtAmount = stockAmount - db.convert_to_ml(ingredient[1])
	    
	    if ( debtAmount < 0 ):
		missingList.append((ingredient[0],debtAmount*-1.))        
	return missingList
コード例 #28
0
def Inventory():

    fp =  """<table border="1"><tr><th>Liquor</th><th>Amount (in mL)</th></tr>"""
    
    print db._bottle_types_db

    for mfg, liquor in db.get_liquor_inventory():
        x = db.get_liquor_amount( mfg, liquor)
        fp +=  "<tr><td>%s</td><td align=center>%s</td></tr>" % (mfg, x)


    fp += "</table>" 

    fp += "<p><a href='/'>Index</a></p><p><a href='recipes'>Recipes</a></p><p><a href='liquor_types'>Liquor Types</a></p>"

    return fp
コード例 #29
0
ファイル: recipes.py プロジェクト: alhulaymi/cse491-drinkz
    def need_ingredients(self):

        # the list we're hoping to return
        missing = []

        found = False

        # go through the ingredients
        for ing in self.ingredients:
            found = False
            # make a tuple to be added eventually
            need = (ing[0], db.convert_to_ml(ing[1]))

            original_needed_amount = need[1]  # ignore this for a while, it will come in handy soon

            # now compare the ingredient type to the types we hve
            for type in db.get_bottle_types():

                # if we know such type exists and that type is in our inventory (by a mfg and a liquor)
                if (type[2] == need[0]) and db.check_inventory(type[0], type[1]):
                    # print "checking "+type[2]+" with mfg= "+type[0]+ " with liquor "+type[1]
                    # see how much liquor is available by that particular mfg and liquor
                    available_amount = db.get_liquor_amount(type[0], type[1])

                    # if we have more than or equal amount of that liquor from that particular mfg and liquor
                    if available_amount >= original_needed_amount:
                        # print "found it :)"
                        # then we're done here, let's move on to the next ingredient (break out of the current/types loop)
                        found = True
                        break

                    else:  # if the amount is not enough

                        # how much is missing? (difference between what we need and what we have)
                        difference_amount = original_needed_amount - available_amount

                        # we will try to find the mfg and liquor with the minimum missing amount. Otherwise, just leave it alone.
                        # I know I could've used min() but this will make thigns look simpler
                        if difference_amount < need[1]:
                            # print "we will replace the current "+str(need[1])+" with the new differnece: "+str(difference_amount)
                            need = (need[0], difference_amount)
                        # else:
                        # print "we will not replace "+str(need[1])+" with the new difference "+str(difference_amount)

            if not found:
                missing.append(need)
        return missing
コード例 #30
0
ファイル: recipes.py プロジェクト: khessiny/cse491-drinkz
    def need_ingredients(self):
	 volume = 0 
         missing = []
	 for type, quantity in self.singridients:
      		needed = convert.convert_to_ml(quantity)
	 	available = db.check_inventory_for_type(type)
        	for (m,l) in available:
			vol = db.get_liquor_amount(m,l)
			if vol > volume:
				volume = vol
		if volume < needed:
			missing.append((type,needed - volume))
			volume = 0
		else:
			continue


         return missing