コード例 #1
0
ファイル: center.py プロジェクト: s-silva/roadhouse
	def handle_accounts(self, url):
	
		obj = None

		if url == "login": # email, pass
			email = self.get_argument("email", "0")
			passw = self.get_argument("pass", "0")

			if email == "0" or passw == "0":
				return obj

			r = login.login(email, passw)	
			
			if r != False:
				self.key = login.make_key(r)
				people = core.people.People(self.key)
				cuid = r
				userdata = people.get(str(cuid))
				if userdata is None:
					obj = {"result" : "error"}
					login.logout(self.key)
					return obj

				if "dp" in userdata:
					if userdata["dp"] == "":
						dp_s = ""
						dp_l = ""
					else:
						dp_s = "/static/cdn/full/" + userdata["dp"]
						dp_l = "/static/cdn/full/" + userdata["dp"]
				else:
					dp_s = ""
					dp_l = ""
				
				

				print userdata["fname"] + " " + userdata["lname"] + " logged in dp - " + dp_s
				obj = {"result" : "success", "key": self.key, "user": {"id": str(cuid), "dp_s": dp_s, "dp_l": dp_l, "uname": userdata["fname"] + " " + userdata["lname"]}}
			else:
				obj = {"result" : "error"}

			return obj


		elif url == "create_account":
			obj = {"result" : "error"}

			people = core.people.People(self.key)

			person =  {"fname"		 : self.get_argument("fname", ""),
					   "lname" 		 : self.get_argument("lname", ""),
					   "username" 	 : self.get_argument("username", ""),
					   "email" 		 : self.get_argument("email", ""),
					   "rating"	 	 : {"rating1" : 0, "rating2" : 0},
					   "password" 	 : self.get_argument("password", ""),
					   "location" 	 : {"name" : "Unknown Location", "type" : 0},
					   "coordinates" : [0, 0],
					   "description" : self.get_argument("description", ""),
					   "status" 	 : self.get_argument("status", "")}
			
			pcr = people.create(person)
			
			if pcr == 1:
				email = self.get_argument("email", "0")
				passw = self.get_argument("password", "0")

				if email == "0" or passw == "0":
					return obj

				r = login.login(email, passw)	
				
				if r != False:
					self.key = login.make_key(r)
					people = core.people.People(self.key)
					cuid = r
					userdata = people.get(str(cuid))
					if userdata is None:
						obj = {"result" : "error"}
						login.logout(self.key)
						return obj

					if "dp" in userdata:
						if userdata["dp"] == "":
							dp_s = ""
							dp_l = ""
						else:
							dp_s = "/static/cdn/full/" + userdata["dp"]
							dp_l = "/static/cdn/full/" + userdata["dp"]
					else:
						dp_s = ""
						dp_l = ""
				

					print userdata["fname"] + " " + userdata["lname"] + " logged in dp - " + dp_s
					obj = {"result" : "success", "key": self.key, "user": {"id": str(cuid), "dp_s": dp_s, "dp_l": dp_l, "uname": userdata["fname"] + " " + userdata["lname"]}}
				else:
					obj = {"result" : "error"}
		

		if url == "logout":
			r = login.logout(self.key)	
			
			if r == True:		
				obj = {"result" : "success"}
			else:
				obj = {"result" : "error"}

			return obj


		if url == "deactivate":
			obj = {"result" : "Not Implemented"}
			return obj

		return obj
コード例 #2
0
ファイル: initialize.py プロジェクト: s-silva/roadhouse
def main(args):
	print "started initialization"
		
	db.connect()
	people = core.people.People(0)
	rooms = core.rooms.Rooms(0)

	if db.roadhouse is not None:
		
		"""
		John Doe
		Jane Roe
		石戸谷 貞子
		
		"""
		
		print "db found"

		db.roadhouse.secure.remove()

		db.roadhouse.config.update({}, {"$set" : {"last_userid" : 0}}, True)
		db.roadhouse.people.remove()
		
		people.create({"fname" : "John",
					   "lname" : "Smith",
					   "username" : "johnsmith",
					   "email" : "*****@*****.**",
					   "rating" : {"rating1" : 0, "rating2" : 0},
					   "password" : "123",
					   "location" : {"name" : "Unknown Location", "type" : 0},
					   "coordinates" : [0, 0],
					   "description" : "A man of word",
					   "status" : "Good morning..."})
					   
		people.create({"fname" : "Mary",
					   "lname" : "Jane",
					   "username" : "maryjane",
					   "email" : "*****@*****.**",
					   "rating" : {"rating1" : 0, "rating2" : 0},
					   "password" : "123",
					   "location" : {"name" : "Unknown Location", "type" : 0},
					   "coordinates" : [0, 0],
					   "description" : "Hey!",
					   "status" : "Drawing some stuff."})
					   
		people.create({"fname" : "石戸谷",
					   "lname" : "貞子",
					   "username" : "sadako",
					   "email" : "*****@*****.**",
					   "rating" : {"rating1" : 0, "rating2" : 0},
					   "password" : "123",
					   "location" : {"name" : "Unknown Location", "type" : 0},
					   "coordinates" : [0, 0],
					   "description" : "Blah",
					   "status" : "Growing plants here..."})
					   
		db.roadhouse.rooms.remove()

		rooms.create({"name"		 : "Mayfield Park",
					   "dsc" 		 : "Love, peace, music",
					   "address" 	 : "7th street, Elf Town",
					   "status" 	 : "",
					   "size"        : 10,
					   "type"        : rooms.room_type_place,
					   "security"    : {"type": rooms.security_level_open, "password": ""},
					   "locname"	 : "",
					   "loc" 		 : [1.0, 1.0],
					   "event" 		 : {"start": 0, "end": 0},
					   "ratings" 	 : {"rating1" : 0, "rating2" : 0},
					   "tickets"	 : {"message" : "", "url": "", "price": ""},
					   "conversation": None})

		rooms.create({"name"		 : "Coffee Shop",
					   "dsc" 		 : "Jim's Coffee Spot",
					   "address" 	 : "22/1, Elf Town",
					   "status" 	 : "",
					   "size"        : 5,
					   "type"        : rooms.room_type_place,
					   "security"    : {"type": rooms.security_level_open, "password": ""},
					   "locname"	 : "",
					   "loc" 		 : [2.0, 1.0],
					   "event" 		 : {"start": 0, "end": 0},
					   "ratings" 	 : {"rating1" : 0, "rating2" : 0},
					   "tickets"	 : {"message" : "", "url": "", "price": ""},
					   "conversation": None})

		rooms.create({"name"		 : "College of Design and Arts",
					   "dsc" 		 : "Welcome to the Elf Town College of Art",
					   "address" 	 : "12/A, Elf Town",
					   "status" 	 : "",
					   "size"        : 20,
					   "type"        : rooms.room_type_place,
					   "security"    : {"type": rooms.security_level_open, "password": ""},
					   "locname"	 : "",
					   "loc" 		 : [1.0, 1.0],
					   "event" 		 : {"start": 0, "end": 0},
					   "ratings" 	 : {"rating1" : 0, "rating2" : 0},
					   "tickets"	 : {"message" : "", "url": "", "price": ""},
					   "conversation": None})
	else:
		print('Ouch!')