Exemplo n.º 1
0
def geocode(address, isCenter=False, sensor="false", **geo_args):
	cep = ''
	if isCenter:
		pc = MongoDB.find_city(address[1])
		if pc is None:
			geo_args.update({
				'address': address[0].replace(' ', '+'),
				'sensor': sensor
			})
			# print(address)
			temp = geocode2(address[0], isCenter=True, **geo_args)
			MongoDB.insert_item(temp)
			return temp
		else:
			return pc
	else:
		cep = address[1]
		pc = MongoDB.find_postal_code(cep)
		if pc is None:
			geo_args.update({
				'address': address[0].replace(' ', '+'),
				'sensor': sensor
			})
			temp = geocode2(cep, **geo_args)
			MongoDB.insert_item(temp)
			return temp
		else:
			return pc
Exemplo n.º 2
0
def createDataBaseCIDs():
	"""
	Cria a base de CIDs que serão utilizados
	function()
	"""
	with open('cid-10.txt', 'r+') as f:
		grouping = ''
		for line in f.readlines():
			line = line.strip()
			s = line.split(') - ')
			s[0] = s[0].replace('(','')
			if '-' in s[0]:
				group = s[0]
				group_description = s[1]
			if '-' not in s[0] and len(s) > 1:
				d = {}
				d['type'] = 'cid'
				d['version'] = 10
				d['code'] = s[0]
				d['neoplasms'] = s[1]
				d['neoplasms_group'] = group
				d['neoplasms_group_description'] = group_description
				# print(d)
				MongoDB.insert_item(d)
	f.closed
Exemplo n.º 3
0
def uploadFilesToMediaFolder(fileItem):
    t = int(time.time())
    filename = "%s_%s" % (str(t), fileItem)
    d = {}
    d["type"] = "file"
    d["extension"] = str(filename.split(".")[-1])
    d["name"] = str(filename)
    d["date"] = t
    MongoDB.insert_item(d)
    path = "media/%s" % (filename)
    destination = open(path, "wb+")
    message = "Upload feito com sucesso!"
    for chunk in fileItem.chunks():
        destination.write(chunk)
    destination.close()
    return message
Exemplo n.º 4
0
def region(request):
	if request.method == 'POST':
		list_points = request.POST.get('new_points').split(';')
		if len(list_points) > 2:
			price = request.POST.get('price')
			color = request.POST.get('color')
			d = {}
			d['type'] = 'region'
			d['price'] = price
			d['color'] = color
			d['LatLng'] = []

			for i in list_points:
				if i != '':
					temp = re.sub(r'^\s+', '', re.sub(r'[^\-0-9.0-9\[\],]', '', i)).split(',')
					d['LatLng'].append([float(temp[0]), float(temp[1])])
			
			MongoDB.insert_item(d)

	colors = [
		['#F7FBFF', '100-500'],
		['#DEEBF7', '500-1000'],
		['#C6DBEF', '1000-1500'],
		['#9ECAE1', '1500-2000'],
		['#6BAED6', '2000-2500'],
		['#4292C6', '2500-3000'],
		['#2171B5', '3000-3500'],
		['#08519C', '3500-4000'],
		['#08306B', '4000-5000'],
		['#08186C', '5000-6000'],
		['#21086C', '6000-10000'],
	]
	regions, table = viewLists.listTableMoreInputs()
	t = get_template('region.html')
	html = t.render(
		Context(
			{'center' : "-23.2062436,-45.900007" ,
			'colors' : colors,
			'regions' : regions,
			'table': table,
			'csrf_token' : csrf(request)['csrf_token']
			}
		)
	)
	html = html.replace("'", "'")
	return HttpResponse(html)