Exemplo n.º 1
0
    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..."]
Exemplo n.º 2
0
    def liquor_types(self, environ, start_response):
        content_type = 'text/html'
        data = """\
<html>
<head>
<title>Liquor Types</title>
<style type='text/css'>
h1 {color:red;}
body {
font-size: 14px;
}
</style>
</head>
<body>
<h1>Types of Liquor:</h1>
<ul>
"""
        for mfg, liquor in db.get_liquor_inventory():
            data += '<li> '+str(liquor)
        data += """\
</ul>
<a href='./'>Back To Index</a>
</body>
<html>
"""

        start_response('200 OK', list(html_headers))
        return [data]
Exemplo n.º 3
0
    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]
Exemplo n.º 4
0
    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]
Exemplo n.º 5
0
    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]
Exemplo n.º 6
0
 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]
Exemplo n.º 7
0
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
Exemplo n.º 8
0
    def rpc_liquor_inventory(self):
        inv = []
        inventory = db.get_liquor_inventory()
        for k in inventory:
            inv.append(k[0])

        return inv
Exemplo n.º 9
0
 def rpc_get_liquor_inventory(self):
     liquor_in = []
     tup = ()
     for mfg, liquor in db.get_liquor_inventory():
         tup = (mfg, liquor)
         liquor_in.append(tup)
     print type(liquor_in[0])
     return liquor_in
Exemplo n.º 10
0
    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()))
Exemplo n.º 11
0
def inventory():
	tcontent = []
	for i in db.get_liquor_inventory():
		tup = (i[0], i[1], i[2])
		tcontent.append(tup)

	vars = dict(title = 'Liquor Inventory', theaders=["MFG","Liquor","Amount (mL)"],tcontent = tcontent)

	return JinjaLoader('bottle_type_pages.html', vars)
Exemplo n.º 12
0
 def rpc_get_liquor_inventory(self):
     db.add_bottle_type('Johnnie Walker', 'Black Label', 'blended scotch')
     db.add_to_inventory('Johnnie Walker', 'Black Label', '1000 ml')
     
     inv = []
     for mfg,lqr in db.get_liquor_inventory():
         inv.append((mfg,lqr))
         
     return inv
Exemplo n.º 13
0
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')
Exemplo n.º 14
0
def test_get_liquor_inventory():
    db._reset_db()

    db.add_bottle_type('Johnnie Walker', 'Black Label', 'blended scotch')
    db.add_to_inventory('Johnnie Walker', 'Black Label', '1000 ml')

    x = []
    for mfg, liquor in db.get_liquor_inventory():
        x.append((mfg, liquor))

    assert x == [('Johnnie Walker', 'Black Label')], x
Exemplo n.º 15
0
    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]
Exemplo n.º 16
0
    def make_party(self, environ, start_response):
        name1 = ''
        name1_key = '*empty*'
        if 'HTTP_COOKIE' in environ:
            c = SimpleCookie(environ.get('HTTP_COOKIE', ''))
            if 'name1' in c:
                key = c.get('name1').value
                name1 = usernames.get(key, '')
                name1_key = key
        if name1 == '':
            headers = list(html_headers)
            headers.append(('Location', '/login_1'))
            start_response('302 Found', headers)
            return ["Redirect to login_1..."]

        content_type = 'text/html'
        data = """\
<html>
<head>
<title>Party</title>
<style type='text/css'>
h1 {color:red;}
body {
font-size: 14px;
}
</style>
</head>
<body>
"""
        data += "Liquor at party:"
        data += "<p>"
        data += """\
<form action='recv_make_party'>
"""
        for mfg, liquor in db.get_liquor_inventory():
            data +=  "<input type='checkbox' name='liquors' value='"+mfg+' '+liquor+"'>"+liquor
            data += "<p>"

        data += """\
<p>
Type of Music at Party: <input type='text' name='music' size='20'>
Crash Spots: <input type='text' name='crash_spots' size='2'>
Designated Drivers: <input type='text' name='DD' size='2'>
<p>
<input type='submit'>
</form>
<p>
<a href='./'>return to index</a>
"""

        start_response('200 OK', list(html_headers))
        return [data]
Exemplo n.º 17
0
    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]
Exemplo n.º 18
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
Exemplo n.º 19
0
    def inventory(self, environ, start_response):
        title = "inventory"
        content = """<table border='1' margin='50px'>
        <tr>
        <td><strong>Manufacturer</strong></td>
        <td><strong>Liquor</strong></td>
        <td><strong>Amount</strong></td>
        </tr>
        """
        inventory = db.get_liquor_inventory()
        for k in inventory:
            content += "<tr><td>%s </td><td>%s</td><td>%d ml\
            </td></tr>"%(k[0],k[1],db.get_liquor_amount(k[0],k[1]))
        content += "</table>"

        data = begining % (title,title) + content + end 
        start_response('200 OK', list(html_headers))
        return [data]
Exemplo n.º 20
0
def generate_inventory_table():
	data = """ 
	<table border="1">
	<tr>
	<th>Manufacturer</th>
	<th>Liquor Type</th>
	<th>Amount</th>
	"""
	for mfg, liquor in db.get_liquor_inventory():
    		#Get the amount in ml 
    		amt = db.get_liquor_amount(mfg,liquor)
    		amount = str(amt) + ' ml'
    		data = data +  "<tr> <td>" + mfg + "</td> <td>"+ liquor + "</td> <td>"+ amount+ " </td> </tr>"

	data = data + """
	</table>
	</tr>
	</table>
	"""
	return data
Exemplo n.º 21
0
 def rpc_get_liquor_inventory(self):
     return [ (mfg, liquor) for (mfg, liquor) in db.get_liquor_inventory() ]
Exemplo n.º 22
0
    def rpc_get_liqour_inventory(self):
        liqourInvList = list()

        for (m, l) in db.get_liquor_inventory():
            liqourInvList.append((m, l))
        return liqourInvList
Exemplo n.º 23
0
 def rpc_GetLiquorInventory(self):
     return list(db.get_liquor_inventory());
Exemplo n.º 24
0
 def rpc_get_liquor_inventory(self):
     liquor_list = []
     for (m, l) in db.get_liquor_inventory():
         liquor_list.append((m, l))
     return liquor_list
Exemplo n.º 25
0
 def rpc_get_liquor_inventory(self):
     inventories = db.get_liquor_inventory()
     inventory_list = []
     for inventory in inventories:
         inventory_list.append((inventory[0],inventory[1]))
     return inventory_list
Exemplo n.º 26
0
 def rpc_get_liquor_inventory(self):
     inventory = []
     for inv in db.get_liquor_inventory():
         inventory.append(inv)
     inventory.sort()
     return inventory
Exemplo n.º 27
0
    def rpc_get_liquor_inventory(self):
	list = []
	for mfg, liquor in db.get_liquor_inventory():
		list.append((mfg,liquor))
	return list
Exemplo n.º 28
0
 def rpc_get_liquor_inventory(self):
     inventory = []
     for m, l in db.get_liquor_inventory():
         inventory.append((m,l))
     return inventory
Exemplo n.º 29
0
    def rpc_liquor_inventory(self):
	inventory = []
	liquor =  db.get_liquor_inventory()
	for mfg ,l in liquor:
		inventory.append(mfg)
	return inventory
Exemplo n.º 30
0
	def rpc_get_liquor_inventory(self):
		results = []
		for i in db.get_liquor_inventory():
			results.append(i)
		return results