def test_get_suggestions(self): now = u'ts_{0}'.format(datetime.datetime.now()) req = self.get_feedback_post_request({ 'happy': 1, 'description': now, 'url': u'http://example.com/{0}'.format(now) }) feedback = ResponseFactory(happy=True, description=now, url=u'http://example.com/{0}'.format(now)) # Try with just the feedback links = get_suggestions(feedback) assert len(links) == 1 assert links[0].provider == 'dummy' assert links[0].provider_version == 1 assert links[0].cssclass == u'document' assert links[0].summary == u'summary {0}'.format(now) assert links[0].description == u'description {0}'.format(now) assert links[0].url == feedback.url # Now with the feedback and request links = get_suggestions(feedback, req) assert len(links) == 1 assert links[0].provider == 'dummy' assert links[0].provider_version == 1 assert links[0].cssclass == u'document' assert links[0].summary == u'summary {0}'.format(now) assert links[0].description == u'description {0}'.format(now) assert links[0].url == feedback.url
def test_get_suggestions(self): now = u'ts_{0}'.format(datetime.datetime.now()) req = self.get_feedback_post_request({ 'happy': 1, 'description': now, 'url': u'http://example.com/{0}'.format(now) }) feedback = ResponseFactory( happy=True, description=now, url=u'http://example.com/{0}'.format(now) ) # Try with just the feedback links = get_suggestions(feedback) assert len(links) == 1 assert links[0].provider == 'dummy' assert links[0].provider_version == 1 assert links[0].cssclass == u'document' assert links[0].summary == u'summary {0}'.format(now) assert links[0].description == u'description {0}'.format(now) assert links[0].url == feedback.url # Now with the feedback and request links = get_suggestions(feedback, req) assert len(links) == 1 assert links[0].provider == 'dummy' assert links[0].provider_version == 1 assert links[0].cssclass == u'document' assert links[0].summary == u'summary {0}'.format(now) assert links[0].description == u'description {0}'.format(now) assert links[0].url == feedback.url
def thanks(request): feedback = None suggestions = None # FIXME: Hard-coded default product. product = u'Firefox' response_id = None # If the user is an analyzer/admin, then we let them specify # the response_id via the querystring. This makes debugging # the system easier. if ((request.user.is_authenticated() and request.user.has_perm('analytics.can_view_dashboard'))): response_id = smart_int(request.GET.get('response_id', None)) # If we don't have a response_id, then pull it from the # session where it was placed if the user had just left # feedback. if not response_id: response_id = request.session.get('response_id') if response_id: try: feedback = Response.objects.get(id=response_id) except Response.DoesNotExist: pass if feedback: product = feedback.product suggestions = get_suggestions(feedback, request) return render(request, 'feedback/thanks.html', { 'product': product, 'feedback': feedback, 'suggestions': suggestions })
def thanks_view(request): feedback = None suggestions = None response_id = None # If the user is an analyzer/admin, then we let them specify # the response_id via the querystring. This makes debugging # the system easier. if ((request.user.is_authenticated() and request.user.has_perm('analytics.can_view_dashboard'))): response_id = smart_int(request.GET.get('response_id', None)) # If we don't have a response_id, then pull it from the # session where it was placed if the user had just left # feedback. if not response_id: response_id = request.session.get('response_id') if response_id: try: feedback = Response.objects.get(id=response_id) except Response.DoesNotExist: pass if feedback: product = Product.objects.get(db_name=feedback.product) suggestions = get_suggestions(feedback, request) else: # If there's no feedback, then we just show the thanks page as if it # were for Firefox. This is a weird edge case that might happen if the # user has cookies disabled or something like that. product = Product.objects.get(db_name=u'Firefox') template = get_config(product.slug)['thanks_template'] return render(request, template, { 'product': product, 'feedback': feedback, 'suggestions': suggestions })