예제 #1
0
def today_tomorrow(day, mensae):
    if (request.method == 'POST'):
        form = QueryForm(request.form)
        return redirect(url_for(day, mensae=form.mensae.data))

    date = datetime.date.today()
    if day == 'tomorrow':
        date += datetime.timedelta(days=1)

    results = mensa.overview(mensae, day=mensanotify.date.from_date(date))
    form = QueryForm()
    form.mensae.data = mensae
    return render_template(day + '.html',
                           form=form,
                           form_action=url_for(day),
                           mensae=mensae,
                           results=results)
예제 #2
0
def today_tomorrow(day, mensae):
    if (request.method == 'POST'):
        form = QueryForm(request.form)
        return redirect(url_for(day, mensae=form.mensae.data))

    date = datetime.date.today()
    if day == 'tomorrow':
        date += datetime.timedelta(days=1)

    results = mensa.overview(mensae, day=mensanotify.date.from_date(date))
    form = QueryForm()
    form.mensae.data = mensae
    return render_template(day + '.html',
                           form=form,
                           form_action=url_for(day),
                           mensae=mensae,
                           results=results)
예제 #3
0
def search(mensae=MENSA_NAMES, query=None):
    if request.method == 'POST':
        form = QueryForm(request.form)
        q = [x.data for x in form.queries if x.data] or None
        return redirect(url_for('search', mensae=form.mensae.data, query=q))

    results = mensa.search_many(query, mensae)
    form = query_form(query, mensae)

    if not results:
        msg = 'No results'
        if query:
            msg += ' for '
            msg += ', '.join('"{}"'.format(q) for q in query)
        flash(msg, 'warn')
        results = mensa.overview(mensae)

    return render_template('results.html',
                           form=form,
                           form_action=url_for('search'),
                           mensae=mensae,
                           results=results)
예제 #4
0
def search(mensae=MENSA_NAMES, query=None):
    if request.method == 'POST':
        form = QueryForm(request.form)
        q = [x.data for x in form.queries if x.data] or None
        return redirect(url_for('search', mensae=form.mensae.data, query=q))

    results = mensa.search_many(query, mensae)
    form = query_form(query, mensae)

    if not results:
        msg = 'No results'
        if query:
            msg += ' for '
            msg += ', '.join('"{}"'.format(q) for q in query)
        flash(msg, 'warn')
        results = mensa.overview(mensae)

    return render_template('results.html',
                           form=form,
                           form_action=url_for('search'),
                           mensae=mensae,
                           results=results)