def recv_make_party(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) new_music = "" new_crash_spots = 0 new_DDs = 0 try: new_music = results['music'][0] new_crash_spots = results['crash_spots'][0] new_DDs = results['DD'][0] except KeyError: pass name1 = '' if 'HTTP_COOKIE' in environ: c = SimpleCookie(environ.get('HTTP_COOKIE', '')) if 'name1' in c: key = c.get('name1').value name1 = usernames.get(key, '') p = party.Party(name1, new_music, int(new_crash_spots), int(new_DDs)) db.add_party(p) 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 += "Liquors:" data += "<p>" for item in results['liquors']: p.add_liquor(item[0:]) data += item[0:] data += "<p>" data += "Type of music: "+new_music data += '<p>' data += "Crash Spots: "+str(new_crash_spots) data += '<p>' data += "Desginated Drivers: "+str(new_DDs) data += """\ <p> <a href='./'>return to index</a> </body> </html> """ start_response('200 OK', list(html_headers)) return [data]
def party_make_submit(self, environ, start_response): formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) content_type = 'text/html' user = results['user'][0] m1=m2=m3=l1=l2=l3=a1=a2=a3=title=date=time=address='' if results.has_key('m1'): m1 = results['m1'][0] if results.has_key('m2'): m2 = results['m2'][0] if results.has_key('m3'): m3 = results['m3'][0] if results.has_key('l1'): l1 = results['l1'][0] if results.has_key('l2'): l2 = results['l2'][0] if results.has_key('l3'): l3 = results['l3'][0] if results.has_key('a1'): a1 = results['a1'][0] if results.has_key('a2'): a2 = results['a2'][0] if results.has_key('a3'): a3 = results['a3'][0] if not results.has_key('title'): title = "Party" else: title = results['title'][0] if not results.has_key('date'): date = "Tonight!" else: date = results['date'][0] if not results.has_key('time'): time = "11:00PM" else: time = results['time'][0] if not results.has_key('address'): address = "Text for address" else: address = results['address'][0] liquors = dict() if m1 != '' and l1 != '' and a1 != '': liquors[(m1,l1)] = a1 if m2 != '' and l2 != '' and a2 != '': liquors[(m2,l2)] = a2 if m3 != '' and l2 != '' and a3 != '': liquors[(m3,l3)] = a3 newParty = Party(user, title, date, time, address, dict(), liquors) db.add_party(newParty) data = """\ <html><head><title>Party Created! - Drinkz - Alex Lockwood</title> <style type="text/css"> h1 {color:red;} p {color:black;} </style></head><body> <h1>Party Created!</h1> <a href='/'>Return to Index</a><p> """ start_response('200 OK', list(html_headers)) return [data]