Ejemplo n.º 1
0
 def get(self, request, *args, **kwargs):
     in_flow, flow_id = user_in_flow(request.user)
     form = self.get_form()
     context = self.get_context_data(form=form)
     if not in_flow:
         return self.render_to_response(context)
     else:
         poll_id = get_poll_id(flow_id)
         context['poll_id'] = poll_id
         has_poll = poll_id is not None
         context['has_poll'] = has_poll
         if has_poll:
             self.template_name = 'user_in_flow.html'
             messages.info(self.request, _('Please complete the poll before you can send us a message'))
         return self.render_to_response(context)
Ejemplo n.º 2
0
    def test_can_get_poll_id_from_ureport(self):
        url = '%s/api/v1/polls/org/%s/' % (settings.UREPORT_ROOT, settings.UREPORT_ORG_ID)
        responses.add(responses.GET, url,
                      body="""
                      {
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "poll1"
    },
    {
      "id": "05c66a1e-ff50-4b46-8e7efeb699b0"
    }
  ]
}
                      """,
                      status=200,
                      content_type='application/json')
        poll_id = get_poll_id('whoslsads')
        self.assertEqual(poll_id, 'poll1')