Esempio n. 1
0
def section_script_change(request, id):
    """Update survey question for the logged in user

    **Attributes**:

        * ``form`` - ScriptForm
        * ``template`` - survey/section_script_change.html
    """
    section = get_object_or_404(Section_template, pk=id, survey__user=request.user)
    form = ScriptForm(request.POST or None, instance=section)
    if request.method == 'POST':
        if form.is_valid():
            obj = form.save()
            request.session["msg"] = _('script updated.')
            return HttpResponseRedirect(redirect_url_to_survey_list + '%s/#row%s' % (obj.survey_id, obj.id))
        else:
            request.session["err_msg"] = True

    data = {
        'form': form,
        'survey_id': section.survey_id,
        'section_id': section.id,
        'err_msg': request.session.get('err_msg'),
        'action': 'update',
    }
    request.session["msg"] = ''
    request.session['err_msg'] = ''
    return render_to_response('survey/section_script_change.html', data, context_instance=RequestContext(request))
Esempio n. 2
0
def section_script_change(request, id):
    """Update survey question for the logged in user

    **Attributes**:

        * ``form`` - ScriptForm
        * ``template`` - frontend/survey/section_script_change.html

    **Logic Description**:

        *
    """
    section = get_object_or_404(Section_template, pk=int(id), survey__user=request.user)

    form = ScriptForm(instance=section)
    if request.method == "POST":
        form = ScriptForm(request.POST, instance=section)
        if form.is_valid():
            obj = form.save()
            request.session["msg"] = _("script updated.")
            return HttpResponseRedirect(redirect_url_to_survey_list + "%s/#row%s" % (obj.survey_id, obj.id))
        else:
            request.session["err_msg"] = True

    template = "frontend/survey/section_script_change.html"
    data = {
        "form": form,
        "survey_id": section.survey_id,
        "section_id": section.id,
        "err_msg": request.session.get("err_msg"),
        "action": "update",
    }
    request.session["msg"] = ""
    request.session["err_msg"] = ""
    return render_to_response(template, data, context_instance=RequestContext(request))
Esempio n. 3
0
def section_script_change(request, id):
    """Update survey question for the logged in user

    **Attributes**:

        * ``form`` - ScriptForm
        * ``template`` - frontend/survey/section_script_change.html

    **Logic Description**:

        *
    """
    section = get_object_or_404(Section_template,
                                pk=int(id),
                                survey__user=request.user)

    form = ScriptForm(instance=section)
    if request.method == 'POST':
        form = ScriptForm(request.POST, instance=section)
        if form.is_valid():
            obj = form.save()
            request.session["msg"] = _('script updated.')
            return HttpResponseRedirect('/survey/%s/#row%s' %
                                        (obj.survey_id, obj.id))
        else:
            request.session["err_msg"] = True

    template = 'frontend/survey/section_script_change.html'
    data = {
        'form': form,
        'survey_id': section.survey_id,
        'section_id': section.id,
        'module': current_view(request),
        'err_msg': request.session.get('err_msg'),
        'action': 'update',
    }
    request.session["msg"] = ''
    request.session['err_msg'] = ''
    return render_to_response(template,
                              data,
                              context_instance=RequestContext(request))
Esempio n. 4
0
def section_script_change(request, id):
    """Update survey question for the logged in user

    **Attributes**:

        * ``form`` - ScriptForm
        * ``template`` - frontend/survey/section_script_change.html

    **Logic Description**:

        *
    """
    section = get_object_or_404(
        Section_template, pk=int(id), survey__user=request.user)

    form = ScriptForm(instance=section)
    if request.method == 'POST':
        form = ScriptForm(request.POST, instance=section)
        if form.is_valid():
            obj = form.save()
            request.session["msg"] = _('script updated.')
            return HttpResponseRedirect('/survey/%s/#row%s'
                % (obj.survey_id, obj.id))
        else:
            request.session["err_msg"] = True

    template = 'frontend/survey/section_script_change.html'
    data = {
        'form': form,
        'survey_id': section.survey_id,
        'section_id': section.id,
        'module': current_view(request),
        'err_msg': request.session.get('err_msg'),
        'action': 'update',
    }
    request.session["msg"] = ''
    request.session['err_msg'] = ''
    return render_to_response(template, data,
        context_instance=RequestContext(request))