Пример #1
0
	def testGetNotesWithinBounds(self):
		boundsString = '0.000000,0.000000,1.5,1.5'
		testUser = User.objects.create(username='******', email='*****@*****.**', pwHash=auth.encryptPass('james', 'password'), lastLogin=dt.now())
		testNote = Note.objects.create(title='test note', user=testUser, lat='1.000000', lng='1.000000', private=True, content='this is a note')
		testNote = Note.objects.create(title='test note 2', user=testUser, lat='2.000000', lng='2.000000', private=True, content='this is a note')

		notes = Note.objects.filter(user__username__iexact='james2')
		self.assertEqual(getHandlers.notesWithinBounds(notes, boundsString).count(), 1) 
Пример #2
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
			notes = (my | others).distinct()
			#implement this for note searching if decide to do in future
			# if request.GET.get('filterwords') != None:
			# 	routes = getHandlers.filterRouteKeywords(routes, request.GET.get('filterwords'))
			if request.GET.get('bounds') != None:
				notes = getHandlers.notesWithinBounds(notes, request.GET.get('bounds'))
			return notes
		else:
			return object_list.none()
Пример #3
0
    def testGetNotesWithinBounds(self):
        boundsString = '0.000000,0.000000,1.5,1.5'
        testUser = User.objects.create(username='******',
                                       email='*****@*****.**',
                                       pwHash=auth.encryptPass(
                                           'james', 'password'),
                                       lastLogin=dt.now())
        testNote = Note.objects.create(title='test note',
                                       user=testUser,
                                       lat='1.000000',
                                       lng='1.000000',
                                       private=True,
                                       content='this is a note')
        testNote = Note.objects.create(title='test note 2',
                                       user=testUser,
                                       lat='2.000000',
                                       lng='2.000000',
                                       private=True,
                                       content='this is a note')

        notes = Note.objects.filter(user__username__iexact='james2')
        self.assertEqual(
            getHandlers.notesWithinBounds(notes, boundsString).count(), 1)