예제 #1
0
파일: views.py 프로젝트: jas0ndyq/flask-me
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
예제 #2
0
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
예제 #3
0
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)
예제 #4
0
파일: views.py 프로젝트: jas0ndyq/flask-me
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
		)