def pieces_by_date(): start = request.form.get('start') if start: start_date = datetime.datetime.strptime(start, '%Y-%m-%d').date() else: start_date = date.today() - timedelta(days=3) days = request.form.get('days', 2, type=int) html = '' for i in xrange(days): target_day = start_date - timedelta(days=i) pieces_data = Content.get_content_by_date(target_day) test = get_template_attribute('other.html', 'test') html += test(pieces_data) return html
def index(): index_show = Content.query.order_by(Content.pub_date.desc()).all() vote_stat = '' if current_user.is_authenticated(): vote_stat = VoteStat.query.filter_by(user_id=current_user.id).all() pieces_data = [] start_date = None for delta in xrange(0, 5): target_day = date.today() - timedelta(days=delta) pieces_data.append(Content.get_content_by_date(target_day)) start_date = target_day.strftime('%Y-%m-%d') return render_template('index.html', index_show=index_show, pieces_data=pieces_data, start_date=start_date, timedelta=timedelta, vote_stat=vote_stat)
def index(): index_show = Content.query.order_by(Content.pub_date.desc()).all() vote_stat = '' if current_user.is_authenticated(): vote_stat = VoteStat.query.filter_by(user_id=current_user.id).all() pieces_data = [] start_date = None for delta in xrange(0, 5): target_day = date.today() - timedelta(days=delta) pieces_data.append(Content.get_content_by_date(target_day)) start_date = target_day.strftime('%Y-%m-%d') return render_template('index.html', index_show=index_show, pieces_data = pieces_data, start_date = start_date, timedelta = timedelta, vote_stat = vote_stat )