def index(): page = request.args.get('page', 1, type=int) pagination = current_user.followed_posts().paginate( page, per_page=current_app.config['TALKS_PER_PAGE'], error_out=False) talk_list = pagination.items return render_template('talks/index.html', talks=talk_list, pagination=pagination)
def index(): #list of dictionaries meals = current_user.followed_posts().order_by(Meal.timestamp) for meal in meals: meal.date = parse_timestamp(meal.timestamp) return render_template('index.html', title='Home', meals=meals)
def index(page=1): form = PostForm() if form.validate_on_submit(): post = Post(body=form.post.data, timestamp=datetime.utcnow(), author=current_user) db.session.add(post) db.session.commit() return redirect(url_for('index')) posts = current_user.followed_posts().paginate(page, POSTS_PER_PAGE, False) return render_template('index.html', title='Home', form=form, posts=posts)
def index(page = 1): form = PostForm() if form.validate_on_submit(): post = Post(body = form.post.data, timestamp = datetime.utcnow(), author = current_user) db.session.add(post) db.session.commit() return redirect(url_for('index')) posts = current_user.followed_posts().paginate(page, POSTS_PER_PAGE, False) return render_template('index.html', title = 'Home', form = form, posts = posts)
def index(): if not current_user.is_authenticated(): abort(403) page = int(request.args.get('page', 1)) posts = current_user.followed_posts().paginate(page, POSTS_PER_PAGE, False) # page = int(request.args.get('page', 1)) # pagination = User.query.paginate(page=page, per_page=10) # return render_template('index.html', pagination=pagination) return render_template('user/index.html', user=current_user, posts=posts)
def house(): if request.method == 'GET': locations = ['Adams', 'Annenberg', 'Cabot', 'Currier', 'Dunster', 'Eliot', 'Fly-By', 'Hillel', 'Kirkland', 'Leverett', 'Lowell', 'Mather', 'Pforzheimer', 'Quincy', 'Winthrop'] return render_template("house.html", locations=locations) elif request.method == 'POST': location = request.form["location"] meals = [] posts = current_user.followed_posts().order_by(Meal.timestamp) for meal in posts: if meal.house == location: meal.date = parse_timestamp(meal.timestamp) meals.append(meal) if len(meals) > 0: return render_template("houseFriends.html", location=location, meals = meals) else: flash('No meals found for %s' % location) return redirect(url_for('house')) abort(405)