Beispiel #1
0
def survey_eval_summaries(id):
    '''
    Creates new summaries which are shown in form of histograms, when called (web GUI).
    '''
    srvy = db.session.query(SurveyModel).get(id)
    if srvy is None:
        print("srvy is none")  #debug
        abort(404)

    form = SummaryForm()
    if form.validate_on_submit():
        return redirect(url_for('survey_detail', id=srvy.id))
    return render_template('srvys/evaluate.html',
                           form=form,
                           title='summaries',
                           srvy=srvy,
                           survey_id=srvy.surveyid)
Beispiel #2
0
def survey_summaries(id):
    '''
    Shows the summaries of a survey in form of histograms (web GUI).
    '''
    srvy = db.session.query(SurveyModel).get(id)
    print("hilfe")
    print(srvy)
    if srvy is None:
        abort(404)

    form = SummaryForm()
    if form.validate_on_submit():
        return redirect(url_for('survey_detail', id=srvy.id))
    return render_template('srvys/histograms.html',
                           form=form,
                           title='summaries',
                           srvy=srvy,
                           survey_id=srvy.surveyid)
def summary_index():
    form = SummaryForm()
    if form.validate_on_submit():
        table = PrettyTable()
        email = form.email.data
        requests = ip_request_for_email(email).all()
        table.add_column(u'Name', map(lambda x: x.name, requests))
        table.add_column(u'IPs', map(lambda x: ', '.join(x.ips), requests))
        table.add_column(u'Vom', map(lambda x: x.created_at.strftime('%d.%m.%Y'), requests))
        table.add_column(u'Löschlink', ['[%d]' % x for x in range(len(requests))])

        links = []
        for r in requests:
            url = url_for("main.config_destroy", request_id=r.id,
                          signed_token=r.token_destroy, _external=True)
            links.append(url)

        subject = '[Freifunk Berlin] IP-Auflistung'
        data = {'table' : table, 'links' : links, 'email': email}
        send_email(email, subject, 'summary/email.txt', data)
        return render_template('summary/success.html', email = email)

    return render_template('summary/form.html', form = form)