Esempio n. 1
0
File: moderate.py Progetto: v1o/brmu
	def GET(self):
		db = db_operations(config.temporary_db)
		
		dicts = db.get_all_dicts_from_root()

		web.header('Content-Type', 'application/json')
		return json.dumps(dicts)		
Esempio n. 2
0
File: moderate.py Progetto: v1o/brmu
	def POST(self):
		get_record = web.input(_method='post')

		record_array = get_record.data.split(";")

		db = db_operations(config.temporary_db)

		return db.delete_entry(record_array)
Esempio n. 3
0
File: app.py Progetto: v1o/brmu
	def GET(self):
		db = db_operations(config.permanent_db)
		get_input = web.input(_method='get')

		try:
			response = db.get_all_keys_from_root_dict(get_input.data+config.places_suffix)
			web.header('Content-Type', 'application/json')
			return json.dumps(response)
		except:
			return "Not Found !"
Esempio n. 4
0
File: app.py Progetto: v1o/brmu
	def POST(self):
		get_record = web.input(_method='post')

		db = db_operations(config.temporary_db)

		record_array = get_record.data.split(";")
		#print len(record_array)
		db.save_city_name_place_beer(record_array)

		return "Your new record was added. It will be moderated shortly!"
Esempio n. 5
0
File: moderate.py Progetto: v1o/brmu
	def POST(self):
		get_record = web.input(_method='post')

		db = db_operations(config.permanent_db)

		record_array = get_record.data.split(";")
		#print len(record_array)
		db.save_city_name_place_beer(record_array)

		return "done"
Esempio n. 6
0
File: moderate.py Progetto: v1o/brmu
	def POST(self):
		get_record = web.input(_method='post')
		#print get_record
		
		record_array = get_record.data.split(";")

		beer_name = record_array[0]
		datetime_added = record_array[2]

		db = db_operations(config.permanent_db)

		db.save_beer(beer_name, 0, datetime_added)

		return "done"		
Esempio n. 7
0
File: moderate.py Progetto: v1o/brmu
	def POST(self):
		get_record = web.input(_method='post')
		#print get_record
		
		record_array = get_record.data.split(";")

		place_name = record_array[1]
		datetime_added = record_array[3]

		city_name_array = record_array[0].split("_")

		city_name = city_name_array[0]
		place_name = record_array[1]		

		db = db_operations(config.permanent_db)

		db.save_city_name_place(city_name, place_name, 0, datetime_added)

		return "done"
Esempio n. 8
0
File: app.py Progetto: v1o/brmu
	def GET(self):
		db = db_operations(config.permanent_db)
		get_input = web.input(_method='get')

		city_name, place_name, beer_name = get_input.data.split("_")

		all_dict_keys = db.get_all_keys_from_root_dict(city_name+config.places_beers_suffix)

		if place_name != "Select a place" and beer_name != "Select a beer":
			response = dict()
			if place_name + "-" + beer_name in all_dict_keys:
				#increment city searches
				db.increment_searches(config.cities_list, city_name)
				#increment beer searches
				db.increment_searches(config.beers_list, beer_name)
				#increment places
				db.increment_searches(city_name+config.places_suffix, place_name)
				#return response
				response[place_name+"-"+beer_name] = db.get_all_dicts_from_root_dict(city_name+config.places_beers_suffix)[place_name+"-"+beer_name]
				#print response
				
			try:
				web.header('Content-Type', 'application/json')
				return json.dumps(response)		
			except:
				return "Not Found !"

		elif beer_name == "Select a beer":
			response = dict()
			for place_beer in all_dict_keys:
				if place_name in place_beer:
					print place_beer
					place_beer_key = place_beer.split("-")
					print place_beer_key
					beer_name = place_beer_key[1]
					response[beer_name] = db.get_all_dicts_from_root_dict(city_name+config.places_beers_suffix)[place_beer]

					#increment city searches
					db.increment_searches(config.cities_list, city_name)
					#increment places
					db.increment_searches(city_name+config.places_suffix, place_name)

			try:		
				if len(response) > 0:
					web.header('Content-Type', 'application/json')
					return json.dumps(response)
				else:
					return "Not Found !"
			except:
				return "Not Found !"

		else:
			response = dict()
			for place_beer in all_dict_keys:
				if beer_name in place_beer:
					place_beer_key = place_beer.split("-")
					place_name = place_beer_key[0]
					response[place_name] = db.get_all_dicts_from_root_dict(city_name+config.places_beers_suffix)[place_beer]

					#increment city searches
					db.increment_searches(config.cities_list, city_name)
					#increment beer searches
					db.increment_searches(config.beers_list, beer_name)

			try:
				if len(response) > 0:
					web.header('Content-Type', 'application/json')
					return json.dumps(response)		
				else:
					return "Not Found !"
			except:
				return "Not Found !"
Esempio n. 9
0
File: app.py Progetto: v1o/brmu
	def GET(self):
		db = db_operations(config.permanent_db)
		web.header('Content-Type', 'application/json')
		return json.dumps(db.get_all_keys_from_root_dict(config.beers_list))
Esempio n. 10
0
File: app.py Progetto: v1o/brmu
	def POST(self):
		db = db_operations(config.feedback_db)
		feedback = web.input(_method='post')
		db.save_feedback(feedback)		
Esempio n. 11
0
import pickledb
import time
from database_operations import db_operations
import config
#generate some records
#load romania.db
db = db_operations(config.permanent_db)

f = open("orase.txt", 'r')

#insert cities

for line in f:
	db.save_city(line.lower().strip())
	
f.close()