def demo(): demoID = '513a07ec9c7c840007acfc52' #me! posts = Track.objects(author=demoID) analysis = Analysis.objects(author=demoID).first() return render_template("demo.html", title = 'Demo', posts = posts, analysis = analysis)
def user(name): user = User.objects(name = name).first() if user == None: flash('User ' + name + ' not found.') return redirect(url_for('index')) if g.user == user: posts = Track.objects(author=user) analysis = Analysis.objects(author=g.user).first() return render_template('user.html', user = user, posts = posts, analysis = analysis) flash('You can only look at your own profile.') return redirect(url_for('index'))
def index(): form = TrackForm() if form.validate_on_submit(): tracking = Track ( weight = form.weight.data, happy = form.happy.data, diet = form.diet.data, exercise = form.exercise.data, floss = form.floss.data, meditation = form.meditation.data, note = form.note.data, timestamp = datetime.utcnow(), author = g.user.to_dbref()) tracking.save() flash('Your post is now live!') calculate_weightAvg_async(g.user.to_dbref()) return redirect(url_for('index')) posts = Track.objects(author=g.user) analysis = Analysis.objects(author=g.user).first() return render_template("index.html", title = 'Home', form = form, posts = posts, analysis = analysis)