def ifoundyou_set_permission_action(request): if request.method == 'POST': telephone = request.POST.get('telephone','') times = request.POST.get('times','') passwd = request.POST.get('passwd','') try: Coordinate.objects.get(telephone = telephone,times = times,passwd = security(passwd)) request.session['%s%s' % (telephone,times)] = True return HttpResponse('ok') except: return HttpResponse('error') else: return HttpResponseRedirect('/home')
def getcoordinate_action(request): username = request.GET.get('username',0) passwd = request.GET.get('passwd',0) telephone = request.GET.get('telephone',0) times = request.GET.get('times',0) longitude = request.GET.get('longitude',0) latitude = request.GET.get('latitude',0) version = request.GET.get('version',0) if not username or not telephone or not times or not longitude or not latitude or not passwd or not version: return HttpResponse('parameter error') else: if version < ANDROID_CLIENT_VERSION: return HttpResponse("update") try: Userinfo.objects.get(username=username) except: return HttpResponse("user doesn't exist") if len(passwd) == 0: return HttpResponse('passwd length error') if telephone.startswith('+86'): telephone = telephone[3:] elif telephone.startswith('0086'): telephone = telephone[4:] elif telephone[0] != '1': return HttpResponse('telephone error') try: int(telephone) except: return HttpResponse('telephone error just num') try: pass longitude = str(float(longitude)) latitude = str(float(latitude)) except: return HttpResponse('longitude or latitude is error') user = Userinfo.objects.get(username = username) try: coordinate = Coordinate.objects.get(username = username,telephone = telephone,times = '%s%s' % (username,times)) except: coordinate = Coordinate(username = user,passwd = security(passwd),telephone = telephone,times = '%s%s' % (username,times),now_time = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))) coordinate.save() coordinateTimes = CoordinateTimes(times = coordinate,current_time = datetime.now(),longitude = longitude,latitude = latitude) coordinateTimes.save() return HttpResponse('success')