Exemplo n.º 1
0
def _survey_process_send(organisation, workflow, request, organisationsurvey):
    indicators = request.form.getlist('indicator')

    #FIXME: need to actually send

    dqsurveys.advanceSurvey(organisationsurvey)
    flash('Successfully sent survey to donor.', 'success')
Exemplo n.º 2
0
def __survey_process(organisation, workflow, request, 
                     organisationsurvey, published_accepted):

    indicators = dqindicators.indicators(app.config["INDICATOR_GROUP"])
    form_indicators = request.form.getlist('indicator')

    workflow_id = workflow.Workflow.id
    currentworkflow_deadline = organisationsurvey.currentworkflow_deadline

    for indicator in indicators:
        data = {
            'organisationsurvey_id': organisationsurvey.id,
            'indicator_id': str(indicator.id),
            'workflow_id': workflow_id,
        }

        if indicator.id not in form_indicators:
            # It's an IATI indicator...
            data['published_status'] = dqsurveys.publishedStatusByName('always').id
            data['published_format'] = dqsurveys.publishedFormatByName('iati').id
        else:
            data['published_status'] = request.form.get(str(indicator.id)+"-published")

            if indicator.indicator_noformat:
                data['published_format'] = dqsurveys.publishedFormatByName('document').id
            else:
                data['published_format'] = request.form.get(str(indicator.id) + "-publishedformat")      

            if indicator.indicator_ordinal:
                data['ordinal_value'] = request.form.get(str(indicator.id) + "-ordinal_value")
            else:
                data['ordinal_value'] = None

        data['published_comment'] = request.form.get(str(indicator.id)+"-comments")
        data['published_source'] = request.form.get(str(indicator.id)+"-source")
        data['published_accepted'] = published_accepted(str(indicator.id))
        
        surveydata = dqsurveys.addSurveyData(data)
    
    if 'submit' in request.form:
        if workflow.Workflow.id == organisationsurvey.currentworkflow_id:
        # save data, change currentworkflow_id to leadsto
            dqsurveys.advanceSurvey(organisationsurvey)
            flash('Successfully submitted survey data', 'success')
        else:
            flash("Your survey data was updated.", 'warning')
    else:
        time_remaining_notice = getTimeRemainingNotice(
            organisationsurvey.currentworkflow_deadline)

        flash('Note: your survey has not yet been submitted. '
              + time_remaining_notice, 'warning')