Esempio n. 1
0
def index(request):
    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
    if survey_user is None:
        url = '%s?next=%s' % (reverse(select_user), reverse(index))
        return HttpResponseRedirect(url)

    # Check if the user has filled user profile
    profile = pollster_utils.get_user_profile(request.user.id,
                                              survey_user.global_id)
    if profile is None:
        messages.add_message(request, messages.INFO,
                             _('You have to fill your profile data first.'))
        url = reverse('apps.survey.views.profile_index')
        url_next = reverse('apps.survey.views.index')
        url = '%s?gid=%s&next=%s' % (url, survey_user.global_id, url_next)
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname('weekly')
    except:
        raise Exception(
            "The survey application requires a published survey with the shortname 'weekly'"
        )

    next = None
    if 'next' not in request.GET:
        next = reverse(thanks)

    return pollster_views.survey_run(request, survey.shortname, next=next)
Esempio n. 2
0
def index(request):
    # this is the index for a actual survey-taking
    # it falls back to 'group management' if no 'gid' is provided.
    # i.e. it expects gid to be part of the request!

    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
    if survey_user is None:
        return HttpResponseRedirect(reverse(group_management))

    # Check if the user has filled user profile
    profile = pollster_utils.get_user_profile(request.user.id, survey_user.global_id)
    if profile is None:
        messages.add_message(request, messages.INFO, 
            _(u'Before we take you to the symptoms questionnaire, please complete the short background questionnaire below. You will only have to complete this once.'))
        url = reverse('apps.survey.views.profile_index')
        url_next = reverse('apps.survey.views.index')
        url = '%s?gid=%s&next=%s' % (url, survey_user.global_id, url_next)
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname('weekly')
    except:
        raise Exception("The survey application requires a published survey with the shortname 'weekly'")

    next = None
    if 'next' not in request.GET:
        next = reverse(group_management) # is this necessary? Or would it be the default?

    return pollster_views.survey_run(request, survey.shortname, next=next)
Esempio n. 3
0
def index(request):
    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
    if survey_user is None:
        url = "%s?next=%s" % (reverse(select_user), reverse(index))
        return HttpResponseRedirect(url)

    # Check if the user has filled user profile
    profile = pollster_utils.get_user_profile(request.user.id, survey_user.global_id)
    if profile is None:
        messages.add_message(request, messages.INFO, _("You have to fill your profile data first."))
        url = reverse("apps.survey.views.profile_index")
        url_next = reverse("apps.survey.views.index")
        url = "%s?gid=%s&next=%s" % (url, survey_user.global_id, url_next)
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname("weekly")
    except:
        raise Exception("The survey application requires a published survey with the shortname 'weekly'")

    next = None
    if "next" not in request.GET:
        next = reverse(thanks)

    return pollster_views.survey_run(request, survey.shortname, next=next)
Esempio n. 4
0
File: views.py Progetto: pfhm/hrpt
def profile_index(request):
    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
    if survey_user is None:
        url = "%s?next=%s" % (reverse(select_user), reverse(profile_index))
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname("intake")
    except:
        raise Exception("The survey application requires a published survey with the shortname 'intake'")

    next = None
    if "next" not in request.GET:
        next = reverse(thanks_profile)

    return pollster_views.survey_run(request, survey.shortname, next=next)
Esempio n. 5
0
def profile_index(request):
    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
    if survey_user is None:
        url = '%s?next=%s' % (reverse(select_user), reverse(profile_index))
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname('intake')
    except:
        raise Exception(
            "The survey application requires a published survey with the shortname 'intake'"
        )

    next = None
    if 'next' not in request.GET:
        next = reverse(thanks_profile)

    return pollster_views.survey_run(request, survey.shortname, next=next)
Esempio n. 6
0
def profile_index(request):
    # this renders an 'intake' survey
    # it expects gid to be part of the request.

    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
    if survey_user is None:
        url = '%s?next=%s' % (reverse(select_user), reverse(profile_index))
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname('intake')
    except:
        raise Exception("The survey application requires a published survey with the shortname 'intake'")

    next = None
    if 'next' not in request.GET:
        next = reverse(thanks_profile)

    return pollster_views.survey_run(request, survey.shortname, next=next)
Esempio n. 7
0
def index(request):
    # this is the index for a actual survey-taking
    # it falls back to 'group management' if no 'gid' is provided.
    # i.e. it expects gid to be part of the request!

    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
    if survey_user is None:
        return HttpResponseRedirect(reverse(group_management))

    # Check if the user has filled user profile
    profile = pollster_utils.get_user_profile(request.user.id,
                                              survey_user.global_id)
    if profile is None:
        messages.add_message(
            request, messages.INFO,
            _(u'Before we take you to the symptoms questionnaire, please complete the short background questionnaire below. You will only have to complete this once.'
              ))
        url = reverse('apps.survey.views.profile_index')
        url_next = reverse('apps.survey.views.index')
        url = '%s?gid=%s&next=%s' % (url, survey_user.global_id, url_next)
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname('weekly')
    except:
        raise Exception(
            "The survey application requires a published survey with the shortname 'weekly'"
        )

    next = None
    if 'next' not in request.GET:
        next = reverse(
            group_management)  # is this necessary? Or would it be the default?

    return pollster_views.survey_run(request, survey.shortname, next=next)
Esempio n. 8
0
File: views.py Progetto: pfhm/hrpt
def index(request):
    try:
        survey_user = get_active_survey_user(request)
    except ValueError:
        raise Http404()
        # pass
    # return render_to_response('survey/utvardering.html',{'person': survey_user}, context_instance=RequestContext(request))
    if survey_user is None:
        url = "%s?next=%s" % (reverse(select_user), reverse(index))
        return HttpResponseRedirect(url)

    # Check if the user has filled user profile
    profile = pollster_utils.get_user_profile(request.user.id, survey_user.global_id)
    if profile is None:
        messages.add_message(
            request,
            messages.INFO,
            _(
                "Before we take you to the symptoms questionnaire, please complete the short background questionnaire below. You will only have to complete this once."
            ),
        )
        url = reverse("apps.survey.views.profile_index")
        url_next = reverse("apps.survey.views.index")
        url = "%s?gid=%s&next=%s" % (url, survey_user.global_id, url_next)
        return HttpResponseRedirect(url)

    try:
        survey = pollster.models.Survey.get_by_shortname("weekly")
    except:
        raise Exception("The survey application requires a published survey with the shortname 'weekly'")

    next = None
    if "next" not in request.GET:
        next = reverse(thanks)

    return pollster_views.survey_run(request, survey.shortname, next=next)