Exemple #1
0
def director_results():

    if request.method == 'GET':
        return render_template("dresults.html",
                               questions =db.get_forms())

    else:
        students = util.get_emails()
        return render_template("dresults2.html",
                               students = students)
Exemple #2
0
def index():
    form = UploadForm() if not loggedin() else NoCaptchaUploadForm()
    if form.validate_on_submit():
        filename = make_form_filename()
        while db.form_exists(filename):
            filename = make_form_filename()

        form.upload.data.save('static/forms/' + filename)
        db.add_form(form.filename.data, filename)
        flash('Your form was uploaded: %s' %
              url_for('static', filename='forms/%s' % filename))
    return render_template('forms.html',
                           form=form,
                           forms=db.get_forms(),
                           logged_in=loggedin(),
                           title='Forms')
Exemple #3
0
def form_list():
    res = []
    res_append = res.append

    for f in db.get_forms():
        res_append({
            'class': 'article',
            'img': 'doc.png',
            'url': 'https://now.2pitau.org/static/forms/%s' % f['filename'],
            'text': f['name'],
            'ts': f['ts'],
            'date_delta': clean_rd(relativedelta.relativedelta(datetime.datetime.now(), f['ts']))
        })
    return jsonify({
        'ok': 1,
        'forms': sorted(res, key=lambda x: x['ts'], reverse=True)
    })
Exemple #4
0
def index():
    lunch_form = LunchBlocks()
    version_form = VersionDescription()
    announcement_form = Announcements()

    form_btn = request.form.get('btn')

    if form_btn == LUNCH_BLOCKS_UPDATE_TITLE and lunch_form.validate_on_submit():
        week_day_name = lunch_form.week_and_day.data
        try:
            english_week_day_name = DAY_CHOICES_D[week_day_name]
            db.update_distinctions(lunch_form.blocks.data,
                                   week_day_name,
                                   english_week_day_name)
            flash('lunch blocks were updated if changes were made')
        except KeyError:
            flash('bad day name')
    elif form_btn == ADD_VERSION_TITLE and version_form.validate_on_submit():
        db.insert_version_description(version_form.version_number.data,
                                      version_form.whats_new.data,
                                      version_form.ios_supported.data,
                                      version_form.available_since.data.strftime(VERSION_RELEASED_FORMAT))
        flash('version added/modified to/in About')
    elif form_btn == ANNOUNCEMENT_TITLE and announcement_form.validate_on_submit():
        eastern = timezone('US/Eastern')
        expires_dt_et = eastern.localize(announcement_form.expires.data)
        db.add_announcement(announcement_form.announcement.data,
                            expires_dt_et,
                            announcement_form.url.data)
        sr.flushall()
        flash('Announcement added! It will appear immediately.')

    return render_template('admin.html',
                           title='Admin',
                           logged_in=loggedin(),
                           lunch_title=LUNCH_BLOCKS_UPDATE_TITLE,
                           version_title=ADD_VERSION_TITLE,
                           announcement_title=ANNOUNCEMENT_TITLE,
                           announcements=db.get_announcements(),
                           lunch_form=lunch_form,
                           version_form=version_form,
                           announcement_form=announcement_form,
                           forms=db.get_forms(),
                           js=[url_for('static', filename='js/loadJSON.js'),
                               url_for('static', filename='js/admin.js')])
Exemple #5
0
def send_forms():
    if request.method == "GET":
        return render_template("director.html",
                               students = util.get_emails(),
                               forms = db.get_forms())

    else:
        #get all the checked names from send page
        tmp = request.form.getlist('student')

        students = []
        for i in tmp:
            students.append(str(i))
        print students
        
        try:
            db.send_question(str(request.form['question']),
                             students)
        except:
            print "errrrror"


        return redirect(url_for('director'))
Exemple #6
0
#db.send_question("What?",['*****@*****.**'])
#x = db.get_results()
#print db.get_recipient(x[0])
print db.get_recipient_questions("*****@*****.**")
print db.get_recipient_questions("Patrick")
#print "answer id"
#print x
#print x[0]
#print "ready"
#db.set_answer(x[0],'3')
#print db.get_answer(x[0])
#print db.get_recipient_questions("*****@*****.**")



forms=db.get_forms()
qtype=db.get_qtype("How do you do?")
answer=db.get_answers("How do you do?")
anon=db.get_anon("How do you do?")





#print forms
#print "How do you do?"
#print qtype
#print answer
#print anon