Skip to content

Commit

Permalink
Added enrolled plans feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi2019194 committed Nov 25, 2023
1 parent 759ef71 commit f9142a4
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 23 deletions.
53 changes: 35 additions & 18 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,14 @@ def bmi_calci():

return render_template("bmi_cal.html", bmi=bmi, bmi_category=bmi_category)

@app.route('/plans', methods=['GET', 'POST'])
def plans():

if(session.get('email')):
email = get_session = session.get('email')
enrolled_plans = list(mongo.db.plans.find({'Email': email}))
return render_template("plans.html",enrolled_plans=enrolled_plans)


@app.route('/chatbot', methods=['GET', 'POST'])
def chatbot():
Expand Down Expand Up @@ -677,10 +685,11 @@ def yoga():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "yoga"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
# return redirect(url_for('dashboard'))
else:
return redirect(url_for('dashboard'))
Expand All @@ -702,10 +711,11 @@ def swim():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "swimming"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
# return redirect(url_for('dashboard'))
else:
return redirect(url_for('dashboard'))
Expand All @@ -727,10 +737,11 @@ def abbs():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "abbs"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
else:
return redirect(url_for('dashboard'))
return render_template('abbs.html', title='Abbs Smash!', form=form)
Expand All @@ -751,10 +762,11 @@ def belly():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "belly"
mongo.db.user.insertOne({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
# return redirect(url_for('dashboard'))
else:
return redirect(url_for('dashboard'))
Expand All @@ -776,10 +788,11 @@ def core():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "core"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
else:
return redirect(url_for('dashboard'))
return render_template('core.html', title='Core Conditioning', form=form)
Expand All @@ -800,10 +813,11 @@ def gym():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "gym"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
# return redirect(url_for('dashboard'))
else:
return redirect(url_for('dashboard'))
Expand All @@ -825,10 +839,11 @@ def walk():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "walk"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
# return redirect(url_for('dashboard'))
else:
return redirect(url_for('dashboard'))
Expand All @@ -850,10 +865,11 @@ def dance():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "dance"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
# return redirect(url_for('dashboard'))
else:
return redirect(url_for('dashboard'))
Expand All @@ -875,10 +891,11 @@ def hrx():
if form.validate_on_submit():
if request.method == 'POST':
enroll = "hrx"
mongo.db.user.insert_one({'Email': email, 'Status': enroll})
mongo.db.plans.insert_one({'Email': email, 'Status': enroll})
enrolled_plans = list(mongo.db.plans.find({'Email':email}))
flash(f' You have succesfully enrolled in our {enroll} plan!',
'success')
return render_template('new_dashboard.html', form=form)
return render_template('new_dashboard.html', form=form, enrolled_plans=enrolled_plans)
# return redirect(url_for('dashboard'))
else:
return redirect(url_for('dashboard'))
Expand Down
2 changes: 1 addition & 1 deletion templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<a class="nav-item nav-link" href="/workout">Burnout</a>
<a class="nav-item nav-link" href="/chatbot">FitnessBot</a>
<a class="nav-item nav-link" href="{{url_for('bmi_calci')}}">BMI Calculator</a>
<!-- <a class="nav-item nav-link" href="{{url_for('chatbot')}}">FitnessBot</a> -->
<a class="nav-item nav-link" href="{{url_for('plans')}}">Enrolled Plans</a>
<a class="nav-item nav-link" href="{{url_for('friends')}}">Friends</a>
<a class="nav-item nav-link btn btn-link" href="{{ url_for('user_profile') }}">Profile</button>
</div>
Expand Down
16 changes: 12 additions & 4 deletions templates/new_dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
<div id="dashboard-data card">
<h5 class="card-header">Your Activities</h5>
<div class="card-body">
<p class="border-bottom mb-4 h6" id="enroll_legend"></p>
<p class="card-text" id="enroll"></p> <br>
<p class="border-bottom mb-4 h6" id="enroll_legend">Enrolled Plans</p>
<p class="card-text" id="enroll">
{% set unique_plans = [] %}
{% for plan in enrolled_plans %}
{% if plan['Status'] not in unique_plans %}
{{ plan['Status'] }}<br>
{% set _ = unique_plans.append(plan['Status']) %}
{% endif %}
{% endfor %}
</p>
<br>
<p class="border-bottom mb-4 h6" id="calories_legend"></p>
</div>
</div>


{% endblock %}
{% endblock %}
22 changes: 22 additions & 0 deletions templates/plans.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "layout.html" %}
{% block content %}

<div id="dashboard-data card">
<h5 class="card-header">Your Activities</h5>
<div class="card-body">
<p class="border-bottom mb-4 h6" id="enroll_legend">Enrolled Plans</p>
<p class="card-text" id="enroll">
{% set unique_plans = [] %}
{% for plan in enrolled_plans %}
{% if plan['Status'] not in unique_plans %}
{{ plan['Status'] }}<br>
{% set _ = unique_plans.append(plan['Status']) %}
{% endif %}
{% endfor %}
</p>
<br>
<p class="border-bottom mb-4 h6" id="calories_legend"></p>
</div>
</div>

{% endblock %}

0 comments on commit f9142a4

Please sign in to comment.