Пример #1
0
 def get(self, request):
     if request.user.is_staff:
         return HttpResponseRedirect(reverse('profile'))
     participant = get_participant_profile(request.user)
     if participant.consent:
         return HttpResponseRedirect(reverse('profile'))
     else:
         form = ConsentForm()
         return self.render_to_response({'form':form})
Пример #2
0
 def post(self, request):
     if request.user.is_staff:
         return HttpResponseRedirect(reverse('profile'))
     form = ConsentForm(request.POST)
     if form.is_valid():
         participant = get_participant_profile(request.user)
         participant.consent = True
         participant.save()
         return HttpResponseRedirect(reverse('profile'))
     else:
         return self.render_to_response({'form':form, 'survey':survey})
Пример #3
0
 def get(self, request, username, ad_type, pk):
     if request.is_ajax()
         if not can_access_user(request.user, username):
             raise Http404
         else:
             user = get_object_or_404(User, username=username)
             participant = get_participant_profile(user)
             anon = False if request.user == user else participant.anon_data
             json_data = get_ad_data_json(ad_type, pk, anon=anon)
             return HttpResponse(json_data, content_type="application/json")
     else:
         raise Http404 
Пример #4
0
 def get(self, request, username, hour):
     if request.is_ajax()
         if not can_access_user(request.user, username):
             raise Http404
         else:
             user = get_object_or_404(User, username=username)
             participant = get_participant_profile(user)
             hour = timestamp_to_datetime(hour)
             anon = False if request.user == user else participant.anon_data
             json_data = ad_details_for_hour_json(user, hour, anon=anon)
             return HttpResponse(json_data, content_type="application/json")
     else:
         raise Http404    
Пример #5
0
 def get(self, request, username, start, end):
     if request.is_ajax()
         if not can_access_user(request.user, username):
             raise Http404
         else:
             user = get_object_or_404(User, username=username)
             participant = get_participant_profile(user)
             anon = False if request.user == user else participant.anon_data
             start = isodatestr_to_datetime(start)
             end = isodatestr_to_datetime(end)
             json_data = activity_data_json(
                      user, start, end, fbuser=participant.fbuser, anon=anon)
             return HttpResponse(json_data, content_type="application/json")
     else:
         raise Http404
Пример #6
0
 def get(self, request):
     user = request.user
     if user.is_staff:
         profile = get_staff_profile(user)
         form = StaffProfileForm(instance=profile)
         data = self._staff_data(user, profile, form)
     else:
         try:
             profile = user.get_profile()
         except:
             profile = None
         participant = get_participant_profile(user)
         if participant.consent:
             data = {'user':user, 
                 'profile':profile, 
                 'participant':participant,
                 'surveys':self._user_surveys(user)}
         else:
             return HttpResponseRedirect(reverse('participant_consent'))
     return self.render_to_response(data)