Esempio n. 1
0
File: day.py Progetto: setomits/mow
def day_page(year, month, day, page = 1):
    if page < 1:
        return redirect(url_for('day_page',
                                year = year, month = month, day = day))

    try:
        posted_on = datetime(year, month, day)
    except ValueError:
        return abort(400)
    else:
        g.posted_on = posted_on
        g.page = page
        g.entries = Entry.fetch_day_entries(
            posted_on = posted_on,
            page = page,
            limit = g.entries_per_page)

        if g.entries_per_page * (page - 1) + len(g.entries) < \
           Entry.n_day_entries(posted_on):
            g.has_older = True
        else:
            g.has_older = False
        g.has_newer = True if page > 1 else False

        return render_template('day_page.html')