Ejemplo n.º 1
0
def upload_image(request):
	try:
		survey = models.SurveyInfo.objects.get(user=request.user)

		form = models.DocumentForm(request.POST, request.FILES)
		if form.is_valid():
			image = request.FILES['docfile']
			survey.user_picture = image
			survey.save()
			return views.profile(request, request.user, survey, True)
		else:
			return views.profile(request, request.user, survey, True)
	except Exception, e:
		print "********** ERROR ", str(e)
		return views.profile(request, request.user, survey, True)
Ejemplo n.º 2
0
    def test_profile_view(self):
        from django.test import RequestFactory
        from django.core.urlresolvers import reverse
        from views import profile
        factory = RequestFactory()

        rq = factory.get(reverse('profile'),
                         data={'email': '*****@*****.**'})

        response = profile(rq)
        self.assertIsNotNone(response)
        data = json.loads(response.content)
        self.assertIsNotNone(data)
Ejemplo n.º 3
0
    def test_log_distance(self):
        from models import User, AuthToken, Level, StairWell
        from django.test import RequestFactory
        from django.core.urlresolvers import reverse
        from views import log_distance, distance, profile

        u = User()
        u.email = '*****@*****.**'
        u.public_name = 'TEST'
        u.save()

        auth = AuthToken()
        auth.token_string = AuthToken.gen_token_string('*****@*****.**')
        auth.user = u
        auth.valid = True
        auth.save()

        sw = StairWell(building='ASP', shaft='south')
        sw.save()
        level1 = Level(stairwell=sw, floorNumber=1)
        level1.save()
        level2 = Level(stairwell=sw, floorNumber=2)
        level2.save()

        factory = RequestFactory()

        rq = factory.get(reverse('distance'),
                         data={
                             'qr_id_1': level1.pk,
                             'qr_id_2': level2.pk
                         })

        response = distance(rq)

        data = json.loads(response.content)
        self.assertEqual(data['distance'], 18)

        rq = factory.get(reverse('log_distance'),
                         data={
                             'token': auth.token_string,
                             'steps': 18
                         })
        response = log_distance(rq)
        data = json.loads(response.content)
        self.assertEqual(data['status'], 'OK')

        rq = factory.get(reverse('profile'), data={'token': auth.token_string})
        response = profile(rq)
        data = json.loads(response.content)
        self.assertEqual(data['status'], 'OK')
Ejemplo n.º 4
0
 def profile(self, request):
     return views.profile(request)