Ejemplo n.º 1
0
def main():
	solrutils.index_signal(6000,"testsolr","#test de #solr","fulanito",datetime.datetime.now(),"test,solr")
	solrutils.index_point(6000,6000,"testsolr","fulanito","#test #1 de #fulanito de #solr",datetime.datetime.now(),46.13,-0.45,"test,1,fulanito")
	solrutils.index_point(6001,6000,"testsolr","fulanito","#test #2 de #fulanito de #solr",datetime.datetime.now(),46.13,-0.45,"test,2,fulanito")
	solrutils.index_point(6002,6000,"testsolr","fulanito","#test #3 de #fulanito de #solr",datetime.datetime.now(),46.13,-0.45,"test,3,fulanito")
	solrutils.modify_signal(6000,"testsolr","#test de #solr","fulanita",datetime.datetime.now(),"test,solr")
	solrutils.modify_point(6000,6000,"testsolr","fulanita","#test #1 de #fulanita de #solr",datetime.datetime.now(),46.13,-0.45,"test,1,fulanita")
	solrutils.modify_point(6001,6000,"testsolr","fulanita","#test #2 de #fulanita de #solr",datetime.datetime.now(),46.13,-0.45,"test,2,fulanita")
	solrutils.modify_point(6002,6000,"testsolr","fulanita","#test #3 de #fulanita de #solr",datetime.datetime.now(),46.13,-0.45,"test,3,fulanita")
Ejemplo n.º 2
0
def mobileAddPoint(request,signalId):

	mapId = settings.MAP_ID
	apiKey = settings.API_KEY
	mapNearZoom = settings.MAP_NEAR_ZOOM


	mySignal = get_object_or_404(Signal,pk=signalId)

	try:
		extra = UserExtra.objects.get(user=request.user)
	except:
		extra = None

	# If the form has been submitted...

	if request.method == 'POST':

		# A form bound to the POST data

		form = mobilePointForm(request.POST, request.FILES)

		# All validation rules pass

		if form.is_valid():
			valores = {}
			valores['lat'] = form.cleaned_data['lat']
			valores['long'] = form.cleaned_data['long']
			valores['texto'] = form.cleaned_data['texto']
			valores['signal'] = form.cleaned_data['signal']

			# Aqui inserto

			newPoint = DataPoint()

			newPoint.lat = form.cleaned_data['lat']
			newPoint.long = form.cleaned_data['long']
			newPoint.auxText = form.cleaned_data['texto']
			newPoint.user = request.user
			newPoint.signal_id = int(form.cleaned_data['signal'])
			newPoint.pointTags = form.cleaned_data['pointTags']

			#if request.FILES.get('fileUrl',default=None) is not None:
			if 'imageUrl' in request.FILES:
				newPoint.imageUrl = request.FILES['imageUrl']

			# Actualizo los contadores y karma de usuario y señal

			# Karma del usuario

			if extra != None:
				extra.karmaCounter += KARMA_PER_INPUT

				# Karma de la señal, de momento lo incremento con el TOTAL del karmaCounter del usuario

				newPoint.signal.karmaCounter += signalKarmaFromUser(extra.karmaCounter)

				extra.save()

			# numero de puntos de la señal

			newPoint.signal.numPoints += 1
			newPoint.signal.numPointsNow += 1

			# Guardo la señal y el punto...

			newPoint.signal.save()

			newPoint.save()

			# inserto el punto en el solr

			solrutils.index_point(newPoint.id,newPoint.signal.id,newPoint.signal.name,newPoint.user.username,newPoint.auxText,datetime.datetime.now(),newPoint.lat,newPoint.long,newPoint.pointTags)

		return render_to_response("thanksPoint.html",locals(),context_instance=RequestContext(request))
	else:
		form = mobilePointForm() # An unbound form

	return render_to_response("mobileAddPoint.html",locals(),context_instance=RequestContext(request))