Exemplo n.º 1
0
	def apply_limits(self, request, object_list):
		if request:
			my = object_list.filter(user__username__iexact=request.GET.get('user'))
			others = object_list.exclude(user__username__iexact=request.GET.get('user'))
			others = others.filter(private=False) #remove private routes from list of others' routes
			routes = (my | others).distinct()
			if request.GET.get('filterwords') != None:
				routes = getHandlers.filterRouteKeywords(routes, request.GET.get('filterwords'))
			if request.GET.get('bounds') != None:
				routes = getHandlers.routesWithinBounds(routes, request.GET.get('bounds'))
			return routes
		else:
			return object_list.none()
Exemplo n.º 2
0
	def testGetRoutesWithinBounds(self):
		boundsString = '0.000000,0.000000,1.5,1.5'
		testUser = User.objects.create(username='******', email='*****@*****.**', pwHash=auth.encryptPass('james', 'password'), lastLogin=dt.now())

		testRoute = Route.objects.create(user=testUser, name='route 1', private=True, mapThumbnail='thumb')
		PathPoint.objects.create(route=testRoute, orderNum=0, lat=Decimal('2.000000'), lng=Decimal('2.000000'))

		testRouteTwo = Route.objects.create(user=testUser, name='route 2', private=True, mapThumbnail='thumb')
		PathPoint.objects.create(route=testRouteTwo, orderNum=0, lat=Decimal('1.000000'), lng=Decimal('1.000000'))

		testRouteThree = Route.objects.create(user=testUser, name='route 3', private=True, mapThumbnail='thumb')
		PathPoint.objects.create(route=testRouteThree, orderNum=0, lat=Decimal('-1.000000'), lng=Decimal('1.000000'))

		routes = Route.objects.filter(user__username__iexact='james2')

		self.assertEqual(getHandlers.routesWithinBounds(routes, boundsString).count(), 1) 
Exemplo n.º 3
0
    def testGetRoutesWithinBounds(self):
        boundsString = '0.000000,0.000000,1.5,1.5'
        testUser = User.objects.create(username='******',
                                       email='*****@*****.**',
                                       pwHash=auth.encryptPass(
                                           'james', 'password'),
                                       lastLogin=dt.now())

        testRoute = Route.objects.create(user=testUser,
                                         name='route 1',
                                         private=True,
                                         mapThumbnail='thumb')
        PathPoint.objects.create(route=testRoute,
                                 orderNum=0,
                                 lat=Decimal('2.000000'),
                                 lng=Decimal('2.000000'))

        testRouteTwo = Route.objects.create(user=testUser,
                                            name='route 2',
                                            private=True,
                                            mapThumbnail='thumb')
        PathPoint.objects.create(route=testRouteTwo,
                                 orderNum=0,
                                 lat=Decimal('1.000000'),
                                 lng=Decimal('1.000000'))

        testRouteThree = Route.objects.create(user=testUser,
                                              name='route 3',
                                              private=True,
                                              mapThumbnail='thumb')
        PathPoint.objects.create(route=testRouteThree,
                                 orderNum=0,
                                 lat=Decimal('-1.000000'),
                                 lng=Decimal('1.000000'))

        routes = Route.objects.filter(user__username__iexact='james2')

        self.assertEqual(
            getHandlers.routesWithinBounds(routes, boundsString).count(), 1)