def man_return(request): DVALUE = 0.05 if request.method=="POST": longitude = float(request.POST.get("longitude")) latitude = float(request.POST.get("latitude")) mylongitude = longitude mylatitude = latitude man_id =request.POST.get("id") if not Man.objects.filter(user_id = man_id): new_man= Man(user_id = man_id,longitude = mylongitude,latitude = mylatitude) new_man.save() all_event = Event.objects.all() near_event = [] if all_event: for i in all_event: # if ((i.longitude < DVALUE+longitude)and(i.longitude>longitude-DVALUE)and(i.latitude<latitude+DVALUE)and(i.latitude>latitude-DVALUE)): near_event.append({'content':i.content+u'','starttime':i.starttime,'endtime':i.endtime,'longitude':i.longitude,'latitude':i.latitude,'address':i.address+u''}) all_emergency = Emergency.objects.all() near_emergencycontent = [] near_emergencylongitude = [] near_emergencylatitude = [] near_emergency = [] if all_emergency: for i in all_emergency: # if ((i.longitude < DVALUE+longitude)and(i.longitude>longitude-DVALUE)and(i.latitude<latitude+DVALUE)and(i.latitude>latitude-DVALUE)): near_emergency.append({'content':i.content+u'','longitude':i.longitude,'latitude':i.latitude}) data = { "near_event":near_event, "near_emergency":near_emergency } mimetype = 'application/json' return HttpResponse(simplejson.dumps(data,ensure_ascii = False),mimetype = mimetype) return HttpResponse("Hello,HackDay!")
def event_send(request): if request.method=="POST": event_longitude = request.POST.get("longitude") event_latitude = request.POST.get("latitude") man_id = request.POST.get("id") if not Man.objects.filter(user_id = man_id): new_man= Man(user_id = man_id,longitude = event_longitude,latitude = event_latitude) new_man.save() if (request.POST.get("content"))and(request.POST.get("longitude"))and(request.POST.get("latitude"))and(request.POST.get("address")): event_content = u''+request.POST.get("content") event_longitude = request.POST.get("longitude") event_latitude = request.POST.get("latitude") event_starttime = int(request.POST.get("starttime")) event_endtime = int(request.POST.get("endtime")) event_address = request.POST.get("address") myevent = Event(content = event_content,longitude = event_longitude,latitude = event_latitude,starttime = event_starttime,endtime = event_endtime,address = event_address) myevent.save() return HttpResponse("")