From b9adf638f11d8f32757dd209255e1ba27398a792 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Tue, 28 May 2024 14:31:48 -0400 Subject: [PATCH 01/41] form update --- instance/database.db | Bin 0 -> 20480 bytes website/__init__.py | 9 ++++---- website/auth.py | 30 +++++++++++++++++++++----- website/forms.py | 9 ++++++++ website/models.py | 9 ++++++++ website/templates/questionnaire.html | 31 +++++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 instance/database.db create mode 100644 website/forms.py create mode 100644 website/templates/questionnaire.html diff --git a/instance/database.db b/instance/database.db new file mode 100644 index 0000000000000000000000000000000000000000..63508f89ec6a946aa3b7941f4ab560b843375adb GIT binary patch literal 20480 zcmeI&O;6h}7zgmA@#(xeGoXj#gtK^UP->MoTVJ0p}P(4>Ry zGJ*E}wiBOW-(Wi~DXTk)3``Bq8|EwPDc7Jc%k2&$eevigP6&?zrC~OcS z2*UJDO>V=IO|DZn?er%8)*jcK7FLhG%;&!gQ}a)R{Nw!Rg?7?FfdB*`009U<00Izz z00bcLKMGu~Pt6ugQ~b0T)6OwJ9q=gj!yur3pSSxwIthblOmuqFv8qjrG^@33i;RAf z6mxSvBMrN0ZCMVncbmjM*xr6ha&v=-_uFIoZr@BMudB}Hi>gypB&l@g@!KKF--oE< zhrDtcJ5{GeURo_u^jRrQtiJ15jV(Kk6>pL(5yz@qj%9CJ`y`DG2j@x`>)F}D(vo=D z8tMgM%+oq`M<$K@!GY13{!CDok}}L933Kv1@ohGCtPx&m=wGvcCSGS>9cG`-E3KJ3 z*?-me^^bq0uU#j9LZj#`?6Z3vp5Kq+c0halUe~C}9N3M$1B(=gpHj+|Rx&e% z^(9g81IEvz)8k}s-=>2&9KLR+skY_xn(pNvq+hrBq-GYr3HkHnf&u{uKmY;|fB*y_ z009U<00I!0EP;=i8DZt3^@w$KeWUNYe3i4oNvF#^Wi2|Sil(pW=}CjMY#-E=T0K1C zb#BU)?(VYd88SB|UDi7t*EK4vLrvL`4O2B`YI5!wo@*)^Qw`mfrR2P#B6*w{s>jM+ zS(TNuVY!$VX9Vq{RbXA(XNNR8^f%t7M+K{H*c+J$j|{I?IS$|Sf_ES4wze!8M#s}U zh3cBiSXouM(oxG2RXI0QMKj8>n{;TJCQD^zR>~?*MkKvDb7f|BWJZJFeJ)woO#Vv9 zU**3}))Hej5P$##AOHafKmY;|fB*y_0D(ytSj?`7caAnPg{(F=>Zl?8{XhBBKMDjO z009U<00Izz00bZa0SG_<0uwBN{r?0nE~W+n2tWV=5P$##AOHafKmY;|xDogPw(UCo literal 0 HcmV?d00001 diff --git a/website/__init__.py b/website/__init__.py index 8d24a3dd..e523c2f2 100644 --- a/website/__init__.py +++ b/website/__init__.py @@ -6,7 +6,6 @@ db = SQLAlchemy() DB_NAME = "database.db" - def create_app(): app = Flask(__name__) app.config['SECRET_KEY'] = 'hjshjhdjah kjshkjdhjs' @@ -14,12 +13,13 @@ def create_app(): db.init_app(app) from .views import views - from .auth import auth + from .auth import auth, questionnaire app.register_blueprint(views, url_prefix='/') - app.register_blueprint(auth, url_prefix='/') + app.register_blueprint(auth, url_prefix='/auth') + app.register_blueprint(questionnaire, url_prefix='/questionnaire') - from .models import User, Note + from .models import User, Note, QuestionnaireResponse with app.app_context(): db.create_all() @@ -34,7 +34,6 @@ def load_user(id): return app - def create_database(app): if not path.exists('website/' + DB_NAME): db.create_all(app=app) diff --git a/website/auth.py b/website/auth.py index 8c65752e..3932affc 100644 --- a/website/auth.py +++ b/website/auth.py @@ -1,12 +1,12 @@ from flask import Blueprint, render_template, request, flash, redirect, url_for -from .models import User +from .models import User, QuestionnaireResponse from werkzeug.security import generate_password_hash, check_password_hash -from . import db ##means from __init__.py import db +from . import db from flask_login import login_user, login_required, logout_user, current_user - +from .forms import QuestionnaireForm auth = Blueprint('auth', __name__) - +questionnaire = Blueprint('questionnaire', __name__) @auth.route('/login', methods=['GET', 'POST']) def login(): @@ -56,7 +56,7 @@ def sign_up(): flash('Password must be at least 7 characters.', category='error') else: new_user = User(email=email, first_name=first_name, password=generate_password_hash( - password1, method='sha256')) + password1, method='pbkdf2:sha256')) db.session.add(new_user) db.session.commit() login_user(new_user, remember=True) @@ -64,3 +64,23 @@ def sign_up(): return redirect(url_for('views.home')) return render_template("sign_up.html", user=current_user) + + +@questionnaire.route('/questionnaire', methods=['GET', 'POST']) +@login_required +def show_questionnaire(): + form = QuestionnaireForm() + if form.validate_on_submit(): + response = QuestionnaireResponse( + user_id=current_user.id, + question1=form.question1.data, + question2=form.question2.data, + question3=form.question3.data + # Add more fields as needed + ) + db.session.add(response) + db.session.commit() + flash('Thank you for completing the questionnaire!', 'success') + return redirect(url_for('views.home')) # Adjust as needed + + return render_template('questionnaire.html', form=form) diff --git a/website/forms.py b/website/forms.py new file mode 100644 index 00000000..e1cd40b8 --- /dev/null +++ b/website/forms.py @@ -0,0 +1,9 @@ +from flask_wtf import FlaskForm +from wtforms import StringField, SubmitField +from wtforms.validators import DataRequired + +class QuestionnaireForm(FlaskForm): + question1 = StringField('Question 1', validators=[DataRequired()]) + question2 = StringField('Question 2', validators=[DataRequired()]) + question3 = StringField('Question 3', validators=[DataRequired()]) + submit = SubmitField('Submit') \ No newline at end of file diff --git a/website/models.py b/website/models.py index 79c17e6f..e3af232e 100644 --- a/website/models.py +++ b/website/models.py @@ -16,3 +16,12 @@ class User(db.Model, UserMixin): password = db.Column(db.String(150)) first_name = db.Column(db.String(150)) notes = db.relationship('Note') + +class QuestionnaireResponse(db.Model): + id = db.Column(db.Integer, primary_key=True) + user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False) + question1 = db.Column(db.String(200), nullable=False) + question2 = db.Column(db.String(200), nullable=False) + question3 = db.Column(db.String(200), nullable=False) + # Add more fields for additional questions + user = db.relationship('User', backref=db.backref('responses', lazy=True)) diff --git a/website/templates/questionnaire.html b/website/templates/questionnaire.html new file mode 100644 index 00000000..9824bf9f --- /dev/null +++ b/website/templates/questionnaire.html @@ -0,0 +1,31 @@ + + + + + Questionnaire + + + +
+

Questionnaire

+
+ {{ form.hidden_tag() }} +
+ {{ form.question1.label }}
+ {{ form.question1(size=40) }}
+
+
+ {{ form.question2.label }}
+ {{ form.question2(size=40) }}
+
+
+ {{ form.question3.label }}
+ {{ form.question3(size=40) }}
+
+
+ {{ form.submit() }} +
+
+
+ + From 17b8e8e3afd8486e96d8fe0b6fa850ac3c26ddda Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Wed, 29 May 2024 14:47:13 -0400 Subject: [PATCH 02/41] wWWW --- instance/database.db | Bin 20480 -> 20480 bytes website/__init__.py | 2 +- website/templates/base.html | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instance/database.db b/instance/database.db index 63508f89ec6a946aa3b7941f4ab560b843375adb..8aa887a47e1d9a7e7685760c703e90a1a2506ab5 100644 GIT binary patch delta 85 zcmZozz}T>Wae_1>*F+g-My`zsEA*N8A8i&ixWTU>!^p}YY|NOFR%v8lWTI delta 42 ucmZozz}T>Wae_1>>qHr6M%Il9EA%%DJ3Qi_I6;h!mjMU_HVZmD0dWBm1`JUE diff --git a/website/__init__.py b/website/__init__.py index e523c2f2..fd669a4b 100644 --- a/website/__init__.py +++ b/website/__init__.py @@ -17,7 +17,7 @@ def create_app(): app.register_blueprint(views, url_prefix='/') app.register_blueprint(auth, url_prefix='/auth') - app.register_blueprint(questionnaire, url_prefix='/questionnaire') + app.register_blueprint(questionnaire, url_prefix='/') from .models import User, Note, QuestionnaireResponse diff --git a/website/templates/base.html b/website/templates/base.html index fbbd3854..b1f76362 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -31,7 +31,7 @@ From fb77eaeaab0dcdd0422910efd0f9f9a18c5fead5 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Wed, 29 May 2024 15:33:47 -0400 Subject: [PATCH 05/41] multiple choice --- instance/database.db | Bin 20480 -> 20480 bytes main.py | 2 +- website/auth.py | 11 ++++------- website/forms.py | 10 +++++----- website/models.py | 3 --- website/templates/home.html | 18 +++++++++--------- website/views.py | 17 ++--------------- 7 files changed, 21 insertions(+), 40 deletions(-) diff --git a/instance/database.db b/instance/database.db index 8aa887a47e1d9a7e7685760c703e90a1a2506ab5..428001372af043ae8a90dd6eabce2d6ac8e056f8 100644 GIT binary patch delta 74 zcmZozz}T>Wae_1>_e2?IM(&LXOYAwA_-`=qf91ciSWae_1>*F+g-My`zsOYGSg`M)yof88u-aFKuF1SxJ#Mm7dcet!P)@^Sz} C4Gg>h diff --git a/main.py b/main.py index 45d99ebf..a50e760a 100644 --- a/main.py +++ b/main.py @@ -3,4 +3,4 @@ app = create_app() if __name__ == '__main__': - app.run(debug=True) + app.run(debug=True) \ No newline at end of file diff --git a/website/auth.py b/website/auth.py index 3932affc..fc361a78 100644 --- a/website/auth.py +++ b/website/auth.py @@ -27,14 +27,12 @@ def login(): return render_template("login.html", user=current_user) - @auth.route('/logout') @login_required def logout(): logout_user() return redirect(url_for('auth.login')) - @auth.route('/sign-up', methods=['GET', 'POST']) def sign_up(): if request.method == 'POST': @@ -65,7 +63,6 @@ def sign_up(): return render_template("sign_up.html", user=current_user) - @questionnaire.route('/questionnaire', methods=['GET', 'POST']) @login_required def show_questionnaire(): @@ -73,14 +70,14 @@ def show_questionnaire(): if form.validate_on_submit(): response = QuestionnaireResponse( user_id=current_user.id, - question1=form.question1.data, - question2=form.question2.data, - question3=form.question3.data + question1=','.join(form.question1.data), + question2=','.join(form.question2.data), + question3=','.join(form.question3.data) # Add more fields as needed ) db.session.add(response) db.session.commit() flash('Thank you for completing the questionnaire!', 'success') - return redirect(url_for('views.home')) # Adjust as needed + return redirect(url_for('views.home')) return render_template('questionnaire.html', form=form) diff --git a/website/forms.py b/website/forms.py index e1cd40b8..4b2d7f4b 100644 --- a/website/forms.py +++ b/website/forms.py @@ -1,9 +1,9 @@ from flask_wtf import FlaskForm -from wtforms import StringField, SubmitField +from wtforms import RadioField, SubmitField from wtforms.validators import DataRequired class QuestionnaireForm(FlaskForm): - question1 = StringField('Question 1', validators=[DataRequired()]) - question2 = StringField('Question 2', validators=[DataRequired()]) - question3 = StringField('Question 3', validators=[DataRequired()]) - submit = SubmitField('Submit') \ No newline at end of file + question1 = RadioField('Question 1', choices=[('option1', 'Option 1'), ('option2', 'Option 2'), ('option3', 'Option 3')], validators=[DataRequired()]) + question2 = RadioField('Question 2', choices=[('option1', 'Option 1'), ('option2', 'Option 2'), ('option3', 'Option 3')], validators=[DataRequired()]) + question3 = RadioField('Question 3', choices=[('option1', 'Option 1'), ('option2', 'Option 2'), ('option3', 'Option 3')], validators=[DataRequired()]) + submit = SubmitField('Submit') diff --git a/website/models.py b/website/models.py index e3af232e..bc20b10c 100644 --- a/website/models.py +++ b/website/models.py @@ -2,14 +2,12 @@ from flask_login import UserMixin from sqlalchemy.sql import func - class Note(db.Model): id = db.Column(db.Integer, primary_key=True) data = db.Column(db.String(10000)) date = db.Column(db.DateTime(timezone=True), default=func.now()) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) - class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) email = db.Column(db.String(150), unique=True) @@ -23,5 +21,4 @@ class QuestionnaireResponse(db.Model): question1 = db.Column(db.String(200), nullable=False) question2 = db.Column(db.String(200), nullable=False) question3 = db.Column(db.String(200), nullable=False) - # Add more fields for additional questions user = db.relationship('User', backref=db.backref('responses', lazy=True)) diff --git a/website/templates/home.html b/website/templates/home.html index 9b4fdb3d..2f7f4e9d 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -4,17 +4,17 @@

Questionnaire

{{ form.hidden_tag() }} -
- {{ form.question1.label }}
- {{ form.question1(size=40) }}
+
+
+ {{ form.question1 }}
-
- {{ form.question2.label }}
- {{ form.question2(size=40) }}
+
+
+ {{ form.question2 }}
-
- {{ form.question3.label }}
- {{ form.question3(size=40) }}
+
+
+ {{ form.question3 }}
{{ form.submit() }} diff --git a/website/views.py b/website/views.py index acc6202a..14566848 100644 --- a/website/views.py +++ b/website/views.py @@ -1,9 +1,9 @@ -from flask import Blueprint, render_template, request, flash, redirect, jsonify +from flask import Blueprint, render_template, request, flash, redirect, jsonify, url_for from flask_login import login_required, current_user from .models import QuestionnaireResponse +from .forms import QuestionnaireForm from . import db import json -from .forms import QuestionnaireForm views = Blueprint('views', __name__) @@ -17,7 +17,6 @@ def home(): question1=form.question1.data, question2=form.question2.data, question3=form.question3.data - # Add more fields as needed ) db.session.add(response) db.session.commit() @@ -25,15 +24,3 @@ def home(): return redirect(url_for('views.home')) return render_template("home.html", user=current_user, form=form) - -@views.route('/delete-note', methods=['POST']) -def delete_note(): - note = json.loads(request.data) # this function expects a JSON from the INDEX.js file - noteId = note['noteId'] - note = Note.query.get(noteId) - if note: - if note.user_id == current_user.id: - db.session.delete(note) - db.session.commit() - - return jsonify({}) From eb7feb853d674def336d38a9eea5d58a1511d227 Mon Sep 17 00:00:00 2001 From: atipre Date: Wed, 29 May 2024 15:39:34 -0400 Subject: [PATCH 06/41] login fixed --- instance/database.db | Bin 20480 -> 20480 bytes website/templates/base.html | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/instance/database.db b/instance/database.db index 428001372af043ae8a90dd6eabce2d6ac8e056f8..07f066b515575eeb5ac3bf84c9371fa67c541a55 100644 GIT binary patch delta 252 zcmZozz}T>Wae_1>??f4AM&6AHOZd5%`EnWfEBLH=fYHaN0sgj(OY?z#AnQCHWZed|)o@S9~Zjoka zWNDaUVVInnYH692l9*&*Xl`nfY-pUCl$xAkW@>7YVv(9;X=s*|V&n)md-HcWUPdlv z{yhx**Z5!X@7XMj?nW?_%Kp%724@7f}5g femNPSqZy^8rJ3^!N;32F3?Y;egfgCd!(Rgc_VGWae_1>_e2?IM(&LXOZYjM_`WmnSMYt`EU56BZ}WFKUPcZk{%Z{U*Z5y- f7Bo1;zxkTJo&Zqj1_S?B{u@A{GyIcp_-gHome Logout {% else %} - Login + Login Sign Up {% endif %}
From 6da3b6d8a009abd48099f3fe4edf86e3ba7edbea Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Wed, 29 May 2024 15:40:11 -0400 Subject: [PATCH 07/41] button --- website/templates/home.html | 32 +++++++++---------- website/templates/questionnaire.html | 47 ++++++++++------------------ 2 files changed, 32 insertions(+), 47 deletions(-) diff --git a/website/templates/home.html b/website/templates/home.html index 2f7f4e9d..fc704b8a 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -1,23 +1,21 @@ {% extends "base.html" %} {% block title %}Home{% endblock %} {% block content %} -

Questionnaire

- - {{ form.hidden_tag() }} -
-
- {{ form.question1 }} +

Welcome!

+ +
+
+

Welcome to the homepage!

-
-
- {{ form.question2 }} +
+ {% include 'questionnaire.html' %}
-
-
- {{ form.question3 }} -
-
- {{ form.submit() }} -
- +
{% endblock %} diff --git a/website/templates/questionnaire.html b/website/templates/questionnaire.html index d1f3d685..44af1927 100644 --- a/website/templates/questionnaire.html +++ b/website/templates/questionnaire.html @@ -1,31 +1,18 @@ - - - - - Questionnaire - - - -
-

Questionnaire

-
- {{ form.hidden_tag() }} -
- {{ form.question1.label }}
- {{ form.question1(size=40) }}
-
-
- {{ form.question2.label }}
- {{ form.question2(size=40) }}
-
-
- {{ form.question3.label }}
- {{ form.question3(size=40) }}
-
-
- {{ form.submit() }} -
-
+
+ {{ form.hidden_tag() }} +
+
+ {{ form.question1 }}
- - \ No newline at end of file +
+
+ {{ form.question2 }} +
+
+
+ {{ form.question3 }} +
+
+ {{ form.submit() }} +
+
From 603eaefbf3528eeccd033a8ca81302aa50fb2f38 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Wed, 29 May 2024 15:43:03 -0400 Subject: [PATCH 08/41] w --- website/templates/home.html | 7 ++----- website/templates/questionnaire.html | 7 ++++++- website/views.py | 9 +++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/website/templates/home.html b/website/templates/home.html index fc704b8a..066dfc2c 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -4,18 +4,15 @@

Welcome!

Welcome to the homepage!

-
- {% include 'questionnaire.html' %} -
{% endblock %} diff --git a/website/templates/questionnaire.html b/website/templates/questionnaire.html index 44af1927..b1fb0c78 100644 --- a/website/templates/questionnaire.html +++ b/website/templates/questionnaire.html @@ -1,4 +1,8 @@ -
+{% extends "base.html" %} +{% block title %}Questionnaire{% endblock %} +{% block content %} +

Questionnaire

+ {{ form.hidden_tag() }}

@@ -16,3 +20,4 @@ {{ form.submit() }}
+{% endblock %} diff --git a/website/views.py b/website/views.py index 14566848..1ab2a35f 100644 --- a/website/views.py +++ b/website/views.py @@ -10,6 +10,11 @@ @views.route('/', methods=['GET', 'POST']) @login_required def home(): + return render_template("home.html", user=current_user) + +@views.route('/questionnaire', methods=['GET', 'POST']) +@login_required +def questionnaire(): form = QuestionnaireForm() if form.validate_on_submit(): response = QuestionnaireResponse( @@ -21,6 +26,6 @@ def home(): db.session.add(response) db.session.commit() flash('Thank you for completing the questionnaire!', 'success') - return redirect(url_for('views.home')) + return redirect(url_for('views.questionnaire')) - return render_template("home.html", user=current_user, form=form) + return render_template("questionnaire.html", user=current_user, form=form) From 44944dbf21ced483e607647c4d246fc1ef61c8b1 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Wed, 29 May 2024 16:07:10 -0400 Subject: [PATCH 09/41] w --- instance/database.db | Bin 20480 -> 20480 bytes website/templates/home.html | 7 +++++-- website/templates/split.html | 35 +++++++++++++++++++++++++++++++++++ website/views.py | 10 +++++++--- 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 website/templates/split.html diff --git a/instance/database.db b/instance/database.db index 07f066b515575eeb5ac3bf84c9371fa67c541a55..c7cbfd5a333d537c514ba50d511dd592d009e180 100644 GIT binary patch delta 71 zcmZozz}T>Wae_1>-$WT_M!t;+OYC`A_~$b4f91cyzl(qFW^Wae_1>??f4AM&6AHOYFIr`FAn!f91cyziYFg!5aR_yZqe%^xF*y diff --git a/website/templates/home.html b/website/templates/home.html index 066dfc2c..81b0afb0 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -1,14 +1,17 @@ {% extends "base.html" %} {% block title %}Home{% endblock %} {% block content %} -

Welcome!

+

Welcome, {{ user.first_name }}!

diff --git a/website/templates/split.html b/website/templates/split.html new file mode 100644 index 00000000..81ea4033 --- /dev/null +++ b/website/templates/split.html @@ -0,0 +1,35 @@ +{% extends "base.html" %} +{% block title %}Workout Split{% endblock %} +{% block content %} +
+

Workout Split

+
+ +

Workout 1, Workout 2, etc.

+
+
+ +

Workout 1, Workout 2, etc.

+
+
+ +

Workout 1, Workout 2, etc.

+
+
+ +

Workout 1, Workout 2, etc.

+
+
+ +

Workout 1, Workout 2, etc.

+
+
+ +

Workout 1, Workout 2, etc.

+
+
+ +

Workout 1, Workout 2, etc.

+
+
+{% endblock %} diff --git a/website/views.py b/website/views.py index 1ab2a35f..f15ed9a4 100644 --- a/website/views.py +++ b/website/views.py @@ -1,13 +1,12 @@ -from flask import Blueprint, render_template, request, flash, redirect, jsonify, url_for +from flask import Blueprint, render_template, request, flash, redirect, url_for from flask_login import login_required, current_user from .models import QuestionnaireResponse from .forms import QuestionnaireForm from . import db -import json views = Blueprint('views', __name__) -@views.route('/', methods=['GET', 'POST']) +@views.route('/', methods=['GET']) @login_required def home(): return render_template("home.html", user=current_user) @@ -29,3 +28,8 @@ def questionnaire(): return redirect(url_for('views.questionnaire')) return render_template("questionnaire.html", user=current_user, form=form) + +@views.route('/split', methods=['GET']) +@login_required +def split(): + return render_template("split.html", user=current_user) From 59bc0daecbd965edf6a3e33c6212bf24b43ab94a Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Wed, 29 May 2024 18:55:45 -0400 Subject: [PATCH 10/41] w --- instance/database.db | Bin 20480 -> 20480 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/instance/database.db b/instance/database.db index c7cbfd5a333d537c514ba50d511dd592d009e180..8c5d338f843a3c1bf82cda2186b2a6945ba3d6d5 100644 GIT binary patch delta 50 zcmV-20L}k^paFoO0gxL350M;00S~cYq(2S?4}bs<^$*w&x(}TXfU^-GZVv(*1(Tmo I8Wae_1>-$WT_M!t;+OYC`A_~$b4f91cyzl(qFWgLwlK~5o4Q>Dc From cbe00e22bc75a3558b5a849a29da913f60d387e1 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 12:23:26 -0400 Subject: [PATCH 11/41] tracker --- website/templates/base.html | 15 +-------------- website/templates/home.html | 3 +++ website/templates/tracker.html | 35 ++++++++++++++++++++++++++++++++++ website/views.py | 5 +++++ 4 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 website/templates/tracker.html diff --git a/website/templates/base.html b/website/templates/base.html index 00cb243c..cf37f0bd 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -74,18 +74,5 @@ integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous" > - -{% block javascript %} - -{% endblock %} - - + diff --git a/website/templates/home.html b/website/templates/home.html index 81b0afb0..cf94c62e 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -12,6 +12,9 @@

Welcome, {{ user.first_name }}!

+
diff --git a/website/templates/tracker.html b/website/templates/tracker.html new file mode 100644 index 00000000..2862e768 --- /dev/null +++ b/website/templates/tracker.html @@ -0,0 +1,35 @@ +{% extends "base.html" %} +{% block title %}Workout Tracker{% endblock %} +{% block content %} +
+

Workout Tracker

+
+ +

Day 1, Day 2, etc.

+
+
+ +

Day 1, Day 2, etc.

+
+
+ +

Day 1, Day 2, etc.

+
+
+ +

Day 1, Day 2, etc.

+
+
+ +

Day 1, Day 2, etc.

+
+
+ +

Day 1, Day 2, etc.

+
+
+ +

Day 1, Day 2, etc.

+
+
+{% endblock %} diff --git a/website/views.py b/website/views.py index f15ed9a4..77681d87 100644 --- a/website/views.py +++ b/website/views.py @@ -33,3 +33,8 @@ def questionnaire(): @login_required def split(): return render_template("split.html", user=current_user) + +@views.route('/tracker', methods=['GET']) +@login_required +def tracker(): + return render_template("tracker.html", user=current_user) \ No newline at end of file From bb9b97a0a9deb63748b79a302300c9f85e05e5b3 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 13:06:06 -0400 Subject: [PATCH 12/41] w --- instance/database.db | Bin 20480 -> 20480 bytes website/forms.py | 10 +++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/instance/database.db b/instance/database.db index 8c5d338f843a3c1bf82cda2186b2a6945ba3d6d5..0054ae95a29d6ac38cc89d0e27b2eabf68a73788 100644 GIT binary patch delta 75 zcmZozz}T>Wae_3Xz(g5mMuCk9OY8;M_>&pWae_1>|3n#QM*fWnOYHer`5PGczw+PU-^D+dzhSeWLLUF*2LA>CB7hCX diff --git a/website/forms.py b/website/forms.py index 4b2d7f4b..464e71c1 100644 --- a/website/forms.py +++ b/website/forms.py @@ -3,7 +3,11 @@ from wtforms.validators import DataRequired class QuestionnaireForm(FlaskForm): - question1 = RadioField('Question 1', choices=[('option1', 'Option 1'), ('option2', 'Option 2'), ('option3', 'Option 3')], validators=[DataRequired()]) - question2 = RadioField('Question 2', choices=[('option1', 'Option 1'), ('option2', 'Option 2'), ('option3', 'Option 3')], validators=[DataRequired()]) - question3 = RadioField('Question 3', choices=[('option1', 'Option 1'), ('option2', 'Option 2'), ('option3', 'Option 3')], validators=[DataRequired()]) + question1 = RadioField('How many days a week would you like to workout?', choices=[('option1', '1'), ('option2', '2'), ('option3', '3'), + ('option4', '4'), ('option5', '5'), + ('option6', '6'), ('option7', '7')], validators=[DataRequired()]) + question2 = RadioField('What body parts would you NOT like to exercise?', choices=[('option1', 'Chest'), ('option2', 'Back'), ('option3', 'Arms') + , ('option4', 'Shoulders'), ('option5', 'Legs')], validators=[DataRequired()]) + question3 = RadioField('Which body part would you like to focus on?', choices=[('option1', 'Chest'), ('option2', 'Back'), ('option3', 'Arms') + , ('option4', 'Shoulders'), ('option5', 'Legs')], validators=[DataRequired()]) submit = SubmitField('Submit') From dc5ba0adbc83057c1685077568f70c6afa5dc04b Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 13:37:17 -0400 Subject: [PATCH 13/41] multi --- .DS_Store | Bin 0 -> 6148 bytes main.py | 2 +- website/.DS_Store | Bin 0 -> 6148 bytes website/__init__.py | 15 +++++++-- website/auth.py | 1 - website/forms.py | 16 ++++------ website/templates/base.html | 3 +- website/templates/question2.html | 11 +++++++ website/templates/questionnaire.html | 12 ++------ website/views.py | 44 +++++++++++++++------------ 10 files changed, 59 insertions(+), 45 deletions(-) create mode 100644 .DS_Store create mode 100644 website/.DS_Store create mode 100644 website/templates/question2.html diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7784241d244e05937acf91b79e0a0d2d497fb76e GIT binary patch literal 6148 zcmeHKTZ_{`6h71K+LT4;gTg)rd|haDt0=yNY<&|Eqw9l8&6uzoHk&EA7)mMRS^to~ z#NXpLmx|l2?3;+5Q|5eU&LuPRCCqe)NQ6ytpJ+rx9-7A95b7Gyaou*L=REsBVV;pu zO{r|Fh0J%d+3`0rpx@nqT1rV$MZdg1B@y{17kO6IlgW3{+w1S&8h8Wm!21xLt2V0R zx~amre5ZS_mCEJDj^$~Vw)4@Q6IIl4R-~mV$dVK(@84!cqS{b3MN*mC$OgQjH=K_S zSF7oCa^ydp9!Ek|-uUUO`9*$Ns4tdEfv?WUZHF893S(pHgYO2|NXUOS*tn zQbOmz3OYk(2z>^v;9t^9#1;A_GV}=7&E|!h&DK13b3aFAk*neikqs3vS(pK4fEl=n z0k>s%2R9{hoEcyS{yPTr{@|l&3>d1|$kj*jA(|2ReQf{(hn+=u QApA$b(7=ir_@fN`07IpCGynhq literal 0 HcmV?d00001 diff --git a/main.py b/main.py index a50e760a..45d99ebf 100644 --- a/main.py +++ b/main.py @@ -3,4 +3,4 @@ app = create_app() if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file + app.run(debug=True) diff --git a/website/.DS_Store b/website/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..199134a07976a74a30cd645e24591086c8d910ea GIT binary patch literal 6148 zcmeHKOHRWu5PdEcBO~I#4da8z!f+jD|lmDC27(n z2%#Bi{2XWA*m<_>7=W2?ic??;AfgM7Vip4?@5OsI3N6AjE=P`QAZC)jo6wvv zqMb0p4Qf2%0jt6I*PZy7ku?e~wrUUKV~26bxHZSL#y#@xXhyd?u`#1c_ON7jVU$>P z88{>3ttH3+qb){+Cw5!nd3dl+-*!4?S5pO40af6K6p$^N7EL^AsS2n9s=!tO*&i%j zFbUXrbXx}tcLgAh+3bvU`B@Z>4VVOMJn{|Acq-9TO}JthPiMOgaY?|&qo>1!%ZCX) zn{Y!hu6O3QE*vKDsHG~P3Un1X@Q+hD|Ihc||GOl8QUz3jf2DvKFD@5zeo{DFdmkrf tt)*Yl#U!rrxTUb-j$+2jQG85y#&# - + + diff --git a/website/templates/question2.html b/website/templates/question2.html new file mode 100644 index 00000000..1f22b8e6 --- /dev/null +++ b/website/templates/question2.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} +{% block title %}Question 2{% endblock %} +{% block content %} +

Question 2: {{ days }}

+
+ {{ form.hidden_tag() }} +
+ {{ form.submit() }} +
+
+{% endblock %} diff --git a/website/templates/questionnaire.html b/website/templates/questionnaire.html index b1fb0c78..ede167fd 100644 --- a/website/templates/questionnaire.html +++ b/website/templates/questionnaire.html @@ -5,16 +5,8 @@

Questionnaire

{{ form.hidden_tag() }}
-
- {{ form.question1 }} -
-
-
- {{ form.question2 }} -
-
-
- {{ form.question3 }} + {{ form.days.label }}
+ {{ form.days }}
{{ form.submit() }} diff --git a/website/views.py b/website/views.py index 77681d87..edf8d3c6 100644 --- a/website/views.py +++ b/website/views.py @@ -1,33 +1,37 @@ -from flask import Blueprint, render_template, request, flash, redirect, url_for +from flask import Blueprint, render_template, request, flash, redirect, url_for, session from flask_login import login_required, current_user from .models import QuestionnaireResponse -from .forms import QuestionnaireForm from . import db +from .forms import InitialQuestionForm, SecondQuestionForm +# Initialize the Blueprint views = Blueprint('views', __name__) -@views.route('/', methods=['GET']) -@login_required -def home(): - return render_template("home.html", user=current_user) - +# Define the routes within the Blueprint @views.route('/questionnaire', methods=['GET', 'POST']) -@login_required def questionnaire(): - form = QuestionnaireForm() + form = InitialQuestionForm() if form.validate_on_submit(): - response = QuestionnaireResponse( - user_id=current_user.id, - question1=form.question1.data, - question2=form.question2.data, - question3=form.question3.data - ) - db.session.add(response) - db.session.commit() - flash('Thank you for completing the questionnaire!', 'success') + days = form.days.data + session['days'] = days + return redirect(url_for('views.question2')) + return render_template('questionnaire.html', form=form) + +@views.route('/question2', methods=['GET', 'POST']) +def question2(): + days = session.get('days') + if days is None: return redirect(url_for('views.questionnaire')) + form = SecondQuestionForm() + if form.validate_on_submit(): + # Process the form data and redirect to the next question or a results page + return redirect(url_for('views.questionnaire')) # For now, redirect back to the start + return render_template('question2.html', days=days, form=form) - return render_template("questionnaire.html", user=current_user, form=form) +@views.route('/', methods=['GET']) +@login_required +def home(): + return render_template("home.html", user=current_user) @views.route('/split', methods=['GET']) @login_required @@ -37,4 +41,4 @@ def split(): @views.route('/tracker', methods=['GET']) @login_required def tracker(): - return render_template("tracker.html", user=current_user) \ No newline at end of file + return render_template("tracker.html", user=current_user) From 4de0fcd5b6cff11698ac3ff490b92eb540998cca Mon Sep 17 00:00:00 2001 From: atipre Date: Thu, 30 May 2024 14:09:45 -0400 Subject: [PATCH 14/41] Weight Tracker + graph+ --- website/templates/home.html | 13 +++++- website/templates/weight_tracker.html | 66 +++++++++++++++++++++++++++ website/views.py | 5 ++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 website/templates/weight_tracker.html diff --git a/website/templates/home.html b/website/templates/home.html index cf94c62e..7b911f9a 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -15,10 +15,21 @@

Welcome, {{ user.first_name }}!

+
-

Welcome to the homepage!

+

Welcome to PhySeek: Your Personalized Fitness Destination! + + At PhySeek, we believe that achieving your fitness goals should be personalized, convenient, and effective. That's why we've created a platform where you can embark on your fitness journey with confidence. + + Whether you're looking to build muscle, lose weight, improve endurance, or simply enhance your overall health, our custom-tailored workouts are designed to fit your unique needs and goals. Say goodbye to generic routines and hello to workouts that evolve with you. + + Track your progress effortlessly with our intuitive tools and charts, allowing you to see your achievements in real-time and stay motivated every step of the way. Whether you're a seasoned gym-goer or just starting out, PhySeek is here to support you on your path to a healthier, happier you. + + So, are you ready to unleash your full potential? Let's get started on your journey to a fitter, stronger, and more vibrant you. Welcome to PhySeek! Fill out the Questionnaire and start lifting today!

{% endblock %} diff --git a/website/templates/weight_tracker.html b/website/templates/weight_tracker.html new file mode 100644 index 00000000..e85cdcea --- /dev/null +++ b/website/templates/weight_tracker.html @@ -0,0 +1,66 @@ +{% extends "base.html" %} + +{% block title %} + Workout Split +{% endblock %} + +{% block content %} +
+

Weight Tracker

+ + + +
+ +
+
+ + + +{% endblock %} diff --git a/website/views.py b/website/views.py index edf8d3c6..ff2b28c5 100644 --- a/website/views.py +++ b/website/views.py @@ -42,3 +42,8 @@ def split(): @login_required def tracker(): return render_template("tracker.html", user=current_user) + +@views.route('/weight_tracker', methods=['GET']) +@login_required +def weight_tracker(): + return render_template("weight_tracker.html", user=current_user) From 5f23649150c503b30c124f2e874ed0e81d86ba25 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 14:10:32 -0400 Subject: [PATCH 15/41] dynamic --- website/forms.py | 7 +- website/templates/dynamic_question.html | 16 +++ website/templates/question2.html | 11 -- website/views.py | 137 +++++++++++++++++++++--- 4 files changed, 144 insertions(+), 27 deletions(-) create mode 100644 website/templates/dynamic_question.html delete mode 100644 website/templates/question2.html diff --git a/website/forms.py b/website/forms.py index e03d1423..10cf5bee 100644 --- a/website/forms.py +++ b/website/forms.py @@ -5,5 +5,8 @@ class InitialQuestionForm(FlaskForm): days = RadioField('How many days a week do you want to workout?', choices=[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7')], coerce=int) submit = SubmitField('Next') -class SecondQuestionForm(FlaskForm): - submit = SubmitField('Next') +def create_dynamic_form(question): + class DynamicForm(FlaskForm): + answer = RadioField(question['text'], choices=question['choices'], coerce=str) + submit = SubmitField('Next') + return DynamicForm diff --git a/website/templates/dynamic_question.html b/website/templates/dynamic_question.html new file mode 100644 index 00000000..be662f41 --- /dev/null +++ b/website/templates/dynamic_question.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% block title %}Dynamic Question{% endblock %} +{% block content %} +

{{ question.text }}

+ + {{ form.hidden_tag() }} +
+ {{ form.answer.label }}
+ {{ form.answer }} +
+
+ + +
+ +{% endblock %} diff --git a/website/templates/question2.html b/website/templates/question2.html deleted file mode 100644 index 1f22b8e6..00000000 --- a/website/templates/question2.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "base.html" %} -{% block title %}Question 2{% endblock %} -{% block content %} -

Question 2: {{ days }}

-
- {{ form.hidden_tag() }} -
- {{ form.submit() }} -
-
-{% endblock %} diff --git a/website/views.py b/website/views.py index edf8d3c6..f70e1c65 100644 --- a/website/views.py +++ b/website/views.py @@ -1,32 +1,141 @@ -from flask import Blueprint, render_template, request, flash, redirect, url_for, session +from flask import Blueprint, render_template, request, redirect, url_for, session from flask_login import login_required, current_user +from .forms import InitialQuestionForm, create_dynamic_form from .models import QuestionnaireResponse -from . import db -from .forms import InitialQuestionForm, SecondQuestionForm # Initialize the Blueprint views = Blueprint('views', __name__) -# Define the routes within the Blueprint +# Sample nested questions data +questions_data = { + '1': { + 'text': 'Question 2: How many times a week do you want to do cardio?', + 'choices': [('1', '1'), ('2', '2'), ('3', '3')], + 'next': { + '1': '1.1', # Follow-up questions for answer '1' + '2': '1.2', # Follow-up questions for answer '2' + '3': '1.3' # Follow-up questions for answer '3' + } + }, + '1.1': { + 'text': 'Follow-up Question 1.1: [Placeholder]', + 'choices': [('A', 'A'), ('B', 'B'), ('C', 'C')], + 'next': { + 'A': '1.1.1', + 'B': '1.1.2', + 'C': '1.1.3' + } + }, + '1.2': { + 'text': 'Follow-up Question 1.2: [Placeholder]', + 'choices': [('A', 'A'), ('B', 'B'), ('C', 'C')], + 'next': { + 'A': '1.2.1', + 'B': '1.2.2', + 'C': '1.2.3' + } + }, + '1.3': { + 'text': 'Follow-up Question 1.3: [Placeholder]', + 'choices': [('A', 'A'), ('B', 'B'), ('C', 'C')], + 'next': { + 'A': '1.3.1', + 'B': '1.3.2', + 'C': '1.3.3' + } + }, + '1.1.1': { + 'text': 'Follow-up Question 1.1.1: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.1.2': { + 'text': 'Follow-up Question 1.1.2: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.1.3': { + 'text': 'Follow-up Question 1.1.3: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.2.1': { + 'text': 'Follow-up Question 1.2.1: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.2.2': { + 'text': 'Follow-up Question 1.2.2: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.2.3': { + 'text': 'Follow-up Question 1.2.3: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.3.1': { + 'text': 'Follow-up Question 1.3.1: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.3.2': { + 'text': 'Follow-up Question 1.3.2: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + }, + '1.3.3': { + 'text': 'Follow-up Question 1.3.3: [Placeholder]', + 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], + 'next': {} + } + # Add more questions as needed +} + @views.route('/questionnaire', methods=['GET', 'POST']) def questionnaire(): form = InitialQuestionForm() if form.validate_on_submit(): days = form.days.data session['days'] = days - return redirect(url_for('views.question2')) + session['current_question'] = '1' # Start with question id '1' + session['history'] = [] # Initialize history + return redirect(url_for('views.dynamic_question')) return render_template('questionnaire.html', form=form) -@views.route('/question2', methods=['GET', 'POST']) -def question2(): - days = session.get('days') - if days is None: +@views.route('/dynamic_question', methods=['GET', 'POST']) +def dynamic_question(): + current_question_id = session.get('current_question') + if current_question_id is None: return redirect(url_for('views.questionnaire')) - form = SecondQuestionForm() - if form.validate_on_submit(): - # Process the form data and redirect to the next question or a results page - return redirect(url_for('views.questionnaire')) # For now, redirect back to the start - return render_template('question2.html', days=days, form=form) + + question = questions_data.get(current_question_id) + if question is None: + return redirect(url_for('views.questionnaire')) # Redirect to start if question not found + + DynamicForm = create_dynamic_form(question) + form = DynamicForm() + + if request.method == 'POST': + if 'next' in request.form: + if form.validate(): + answer = form.answer.data + next_question_id = question['next'].get(answer) + if next_question_id: + session['history'].append(current_question_id) + session['current_question'] = next_question_id + return redirect(url_for('views.dynamic_question')) + else: + return redirect(url_for('views.questionnaire')) # Redirect to start if no next question + elif 'back' in request.form: + if session['history']: + previous_question_id = session['history'].pop() + session['current_question'] = previous_question_id + return redirect(url_for('views.dynamic_question')) + else: + return redirect(url_for('views.questionnaire')) + + return render_template('dynamic_question.html', question=question, form=form) @views.route('/', methods=['GET']) @login_required From 2f9388fe0f5571bf5a67b89e6b297c0c10d4aa29 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 14:34:40 -0400 Subject: [PATCH 16/41] multiselect --- website/forms.py | 8 ++- website/templates/dynamic_question.html | 9 ++- website/views.py | 80 ++++--------------------- 3 files changed, 25 insertions(+), 72 deletions(-) diff --git a/website/forms.py b/website/forms.py index 10cf5bee..8b1b7382 100644 --- a/website/forms.py +++ b/website/forms.py @@ -1,5 +1,6 @@ from flask_wtf import FlaskForm -from wtforms import RadioField, SubmitField +from wtforms import RadioField, SelectMultipleField, SubmitField +from wtforms.widgets import ListWidget, CheckboxInput class InitialQuestionForm(FlaskForm): days = RadioField('How many days a week do you want to workout?', choices=[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7')], coerce=int) @@ -7,6 +8,9 @@ class InitialQuestionForm(FlaskForm): def create_dynamic_form(question): class DynamicForm(FlaskForm): - answer = RadioField(question['text'], choices=question['choices'], coerce=str) + if question.get('multi'): + answer = SelectMultipleField(question['text'], choices=question['choices'], option_widget=CheckboxInput(), widget=ListWidget(prefix_label=False)) + else: + answer = RadioField(question['text'], choices=question['choices'], coerce=str) submit = SubmitField('Next') return DynamicForm diff --git a/website/templates/dynamic_question.html b/website/templates/dynamic_question.html index be662f41..af2fd316 100644 --- a/website/templates/dynamic_question.html +++ b/website/templates/dynamic_question.html @@ -5,8 +5,13 @@

{{ question.text }}

{{ form.hidden_tag() }}
- {{ form.answer.label }}
- {{ form.answer }} + {{ form.answer.label }}
+ {% for subfield in form.answer %} +
+ {{ subfield() }} + {{ subfield.label }} +
+ {% endfor %}
diff --git a/website/views.py b/website/views.py index 60373f39..c6a95651 100644 --- a/website/views.py +++ b/website/views.py @@ -9,87 +9,29 @@ # Sample nested questions data questions_data = { '1': { - 'text': 'Question 2: How many times a week do you want to do cardio?', - 'choices': [('1', '1'), ('2', '2'), ('3', '3')], + 'text': 'Are there any muscle groups you DO NOT want to exercise?', + 'choices': [('1', 'Yes'), ('2', 'No')], 'next': { '1': '1.1', # Follow-up questions for answer '1' - '2': '1.2', # Follow-up questions for answer '2' - '3': '1.3' # Follow-up questions for answer '3' + '2': '1.2' # Follow-up questions for answer '2' } }, '1.1': { - 'text': 'Follow-up Question 1.1: [Placeholder]', - 'choices': [('A', 'A'), ('B', 'B'), ('C', 'C')], + 'text': 'Select all muscle groups you DO NOT want to exercise', + 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('A', 'Shoulders'), ('B', 'Legs')], + 'multi': True, 'next': { 'A': '1.1.1', 'B': '1.1.2', 'C': '1.1.3' } }, - '1.2': { - 'text': 'Follow-up Question 1.2: [Placeholder]', - 'choices': [('A', 'A'), ('B', 'B'), ('C', 'C')], - 'next': { - 'A': '1.2.1', - 'B': '1.2.2', - 'C': '1.2.3' - } - }, - '1.3': { - 'text': 'Follow-up Question 1.3: [Placeholder]', - 'choices': [('A', 'A'), ('B', 'B'), ('C', 'C')], - 'next': { - 'A': '1.3.1', - 'B': '1.3.2', - 'C': '1.3.3' - } - }, '1.1.1': { 'text': 'Follow-up Question 1.1.1: [Placeholder]', 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], 'next': {} }, - '1.1.2': { - 'text': 'Follow-up Question 1.1.2: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - }, - '1.1.3': { - 'text': 'Follow-up Question 1.1.3: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - }, - '1.2.1': { - 'text': 'Follow-up Question 1.2.1: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - }, - '1.2.2': { - 'text': 'Follow-up Question 1.2.2: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - }, - '1.2.3': { - 'text': 'Follow-up Question 1.2.3: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - }, - '1.3.1': { - 'text': 'Follow-up Question 1.3.1: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - }, - '1.3.2': { - 'text': 'Follow-up Question 1.3.2: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - }, - '1.3.3': { - 'text': 'Follow-up Question 1.3.3: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} - } - # Add more questions as needed + # ... other questions ... } @views.route('/questionnaire', methods=['GET', 'POST']) @@ -120,7 +62,11 @@ def dynamic_question(): if 'next' in request.form: if form.validate(): answer = form.answer.data - next_question_id = question['next'].get(answer) + if isinstance(answer, list): + # Handle multi-select answers + next_question_id = question['next'].get(answer[0]) # Choose appropriate logic for multi-select + else: + next_question_id = question['next'].get(answer) if next_question_id: session['history'].append(current_question_id) session['current_question'] = next_question_id @@ -132,8 +78,6 @@ def dynamic_question(): previous_question_id = session['history'].pop() session['current_question'] = previous_question_id return redirect(url_for('views.dynamic_question')) - else: - return redirect(url_for('views.questionnaire')) return render_template('dynamic_question.html', question=question, form=form) From 15251db76fed6db16a94fb80e39fbfaeaa7629e8 Mon Sep 17 00:00:00 2001 From: atipre Date: Thu, 30 May 2024 14:36:19 -0400 Subject: [PATCH 17/41] Weight Tracker + how to update weight --- website/templates/weight_tracker.html | 66 ++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/website/templates/weight_tracker.html b/website/templates/weight_tracker.html index e85cdcea..86be3752 100644 --- a/website/templates/weight_tracker.html +++ b/website/templates/weight_tracker.html @@ -9,10 +9,15 @@

Weight Tracker

- + + +
+
+ +
@@ -20,19 +25,68 @@

Weight Tracker

// Initialize an empty array to store weight data let weights = []; - // Function to add weight data - function addWeight() { + // Function to add or update weight data + function addOrUpdateWeight() { const weightInput = document.getElementById('weightInput'); const weight = parseFloat(weightInput.value); if (!isNaN(weight)) { - weights.push(weight); + const today = new Date().toLocaleDateString(); + let weightUpdated = false; + weights.forEach(entry => { + if (entry.date === today) { + entry.weight = weight; + weightUpdated = true; + } + }); + if (!weightUpdated) { + weights.push({ weight: weight, date: today }); + } weightInput.value = ''; // Clear input field updateChart(); + updateWeightLog(); + } else { + alert('Please enter a valid weight.'); + } + } + + // Function to undo the last weight entry + function undoWeight() { + if (weights.length > 0) { + weights.pop(); + updateChart(); + updateWeightLog(); + } + } + + // Function to update the weight when input field changes + function updateWeight() { + const weightInput = document.getElementById('weightInput'); + const weight = parseFloat(weightInput.value); + if (!isNaN(weight)) { + // Update the weight log without adding a new entry + updateWeightLog(); + // Update the chart with the updated weight + const today = new Date().toLocaleDateString(); + weights.forEach(entry => { + if (entry.date === today) { + entry.weight = weight; + } + }); + updateChart(); } else { alert('Please enter a valid weight.'); } } + // Function to update the weight log + function updateWeightLog() { + const weightLog = document.getElementById('weightLog'); + weightLog.innerHTML = ''; + weights.forEach((entry, index) => { + weightLog.innerHTML += `Day ${index + 1} (${entry.date}): ${entry.weight} lbs
`; + }); + } + // Function to update the chart function updateChart() { const ctx = document.getElementById('weightChart').getContext('2d'); @@ -40,8 +94,8 @@

Weight Tracker

const data = { labels: labels, datasets: [{ - label: 'Weight (kg)', - data: weights, + label: 'Weight (lbs)', + data: weights.map(entry => entry.weight), backgroundColor: 'rgba(54, 162, 235, 0.2)', borderColor: 'rgba(54, 162, 235, 1)', borderWidth: 1 From db66c7a3fe20c0ecf66f7ae85cdc445346144006 Mon Sep 17 00:00:00 2001 From: atipre Date: Thu, 30 May 2024 14:42:32 -0400 Subject: [PATCH 18/41] Fixed update weight button --- website/templates/weight_tracker.html | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/website/templates/weight_tracker.html b/website/templates/weight_tracker.html index 86be3752..4d4418d9 100644 --- a/website/templates/weight_tracker.html +++ b/website/templates/weight_tracker.html @@ -24,6 +24,10 @@

Weight Tracker

{% endblock %} From 622b15adbaac6c639e9933632d5fe1d087fd4a59 Mon Sep 17 00:00:00 2001 From: atipre Date: Thu, 30 May 2024 15:00:18 -0400 Subject: [PATCH 19/41] Fixed undo weight --- website/templates/weight_tracker.html | 88 ++++++++++++--------------- 1 file changed, 39 insertions(+), 49 deletions(-) diff --git a/website/templates/weight_tracker.html b/website/templates/weight_tracker.html index 4d4418d9..ab73d88c 100644 --- a/website/templates/weight_tracker.html +++ b/website/templates/weight_tracker.html @@ -9,8 +9,9 @@

Weight Tracker

- - + + +
@@ -24,61 +25,53 @@

Weight Tracker

{% endblock %} From 2e4236ac2d4eda37e95fee8a2d29f15fd6ba4e58 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 15:00:41 -0400 Subject: [PATCH 20/41] q1 changes --- website/templates/split.html | 74 +++++++++++++++++++++--------------- website/views.py | 27 ++++++++----- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/website/templates/split.html b/website/templates/split.html index 81ea4033..2f562244 100644 --- a/website/templates/split.html +++ b/website/templates/split.html @@ -1,35 +1,47 @@ {% extends "base.html" %} {% block title %}Workout Split{% endblock %} {% block content %} -
-

Workout Split

-
- -

Workout 1, Workout 2, etc.

-
-
- -

Workout 1, Workout 2, etc.

-
-
- -

Workout 1, Workout 2, etc.

-
-
- -

Workout 1, Workout 2, etc.

-
-
- -

Workout 1, Workout 2, etc.

-
-
- -

Workout 1, Workout 2, etc.

-
-
- -

Workout 1, Workout 2, etc.

-
-
+

Your Customized Workout Split

+ +

Based on your preferences, here is your workout plan:

+ +
    + {% for key, answer in responses.items() %} +
  • Question {{ key }}: {{ answer }}
  • + {% endfor %} +
+ +

Workout Plan:

+{% if '1.1' in responses %} +

You have selected to not work on the following muscle groups:

+
    + {% if 'A' in responses['1.1'] %} +
  • Chest
  • + {% endif %} + {% if 'B' in responses['1.1'] %} +
  • Back
  • + {% endif %} + {% if 'C' in responses['1.1'] %} +
  • Arms
  • + {% endif %} + {% if 'D' in responses['1.1'] %} +
  • Shoulders
  • + {% endif %} + {% if 'E' in responses['1.1'] %} +
  • Legs
  • + {% endif %} +
+{% else %} +

Full Body Workout

+{% endif %} + + + + {% endblock %} diff --git a/website/views.py b/website/views.py index c6a95651..668711fa 100644 --- a/website/views.py +++ b/website/views.py @@ -13,17 +13,19 @@ 'choices': [('1', 'Yes'), ('2', 'No')], 'next': { '1': '1.1', # Follow-up questions for answer '1' - '2': '1.2' # Follow-up questions for answer '2' + '2': 'end' # Redirect to workout split for answer '2' } }, '1.1': { 'text': 'Select all muscle groups you DO NOT want to exercise', - 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('A', 'Shoulders'), ('B', 'Legs')], + 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('D', 'Shoulders'), ('E', 'Legs')], 'multi': True, 'next': { - 'A': '1.1.1', - 'B': '1.1.2', - 'C': '1.1.3' + 'A': 'end', + 'B': 'end', + 'C': 'end', + 'D': 'end', + 'E': 'end' } }, '1.1.1': { @@ -42,6 +44,7 @@ def questionnaire(): session['days'] = days session['current_question'] = '1' # Start with question id '1' session['history'] = [] # Initialize history + session['responses'] = {} # Initialize responses return redirect(url_for('views.dynamic_question')) return render_template('questionnaire.html', form=form) @@ -62,12 +65,15 @@ def dynamic_question(): if 'next' in request.form: if form.validate(): answer = form.answer.data + session['responses'][current_question_id] = answer if isinstance(answer, list): # Handle multi-select answers - next_question_id = question['next'].get(answer[0]) # Choose appropriate logic for multi-select + next_question_id = question['next'].get(answer[0], None) # Choose appropriate logic for multi-select else: - next_question_id = question['next'].get(answer) - if next_question_id: + next_question_id = question['next'].get(answer, None) + if next_question_id == 'end': + return redirect(url_for('views.split')) # Redirect to workout split tab at the end of the branch + elif next_question_id: session['history'].append(current_question_id) session['current_question'] = next_question_id return redirect(url_for('views.dynamic_question')) @@ -89,7 +95,10 @@ def home(): @views.route('/split', methods=['GET']) @login_required def split(): - return render_template("split.html", user=current_user) + # Use session['responses'] to customize the workout split + responses = session.get('responses', {}) + # Process responses to customize the workout split + return render_template("split.html", user=current_user, responses=responses) @views.route('/tracker', methods=['GET']) @login_required From 24fd354626ac5b2d0b6c8ed54df3a450f7c2194c Mon Sep 17 00:00:00 2001 From: atipre Date: Thu, 30 May 2024 15:44:24 -0400 Subject: [PATCH 21/41] Trying to get weight to store --- instance/database.db | Bin 20480 -> 24576 bytes website/__init__.py | 23 ++++++++++++++--------- website/auth.py | 2 ++ website/models.py | 8 ++++++++ website/weight_tracker.py | 24 ++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 website/weight_tracker.py diff --git a/instance/database.db b/instance/database.db index 0054ae95a29d6ac38cc89d0e27b2eabf68a73788..36ef2639ad37c76ada2e2f6a073e6ffe51b7a4e4 100644 GIT binary patch delta 187 zcmZozz}Rqrae}m3B?npaX(iOgnm4svx2aa9O$bni` z5m0dR@plYS@bd@aP#+&11uo8%#FEtb#FUiOl*#+};x{Yu-gjc-1vyS&v!KC6{)rPb E0Rh!Dk^lez delta 61 zcmZoTz}T>Wae}m<00RR9D-go~^F$qEQ2_?MtP8ySKNwhe6&d(t`Oovk^D1r@6j;l% JS&{d?697&k3@!iw diff --git a/website/__init__.py b/website/__init__.py index dc6cad7d..ce1ac23c 100644 --- a/website/__init__.py +++ b/website/__init__.py @@ -3,38 +3,49 @@ from os import path from flask_login import LoginManager +# Create SQLAlchemy instance db = SQLAlchemy() DB_NAME = "database.db" -from flask_login import current_user - def create_app(): app = Flask(__name__) app.config['SECRET_KEY'] = 'hjshjhdjah kjshkjdhjs' app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}' + + # Initialize SQLAlchemy with the Flask app db.init_app(app) + # Import blueprints from .views import views from .auth import auth + from .weight_tracker import weight_tracker_bp # Import the weight tracker blueprint + # Register blueprints app.register_blueprint(views, url_prefix='/') app.register_blueprint(auth, url_prefix='/auth') + app.register_blueprint(weight_tracker_bp, url_prefix='/weight') # Register the weight tracker blueprint - from .models import User, Note, QuestionnaireResponse + # Import models + from .models import User, Note, QuestionnaireResponse, WeightEntry with app.app_context(): + # Create database tables if they don't exist db.create_all() + # Initialize LoginManager login_manager = LoginManager() login_manager.login_view = 'auth.login' login_manager.init_app(app) + # Define the user loader function @login_manager.user_loader def load_user(id): return User.query.get(int(id)) + # Inject current_user into templates @app.context_processor def inject_user(): + from flask_login import current_user return dict(user=current_user) return app @@ -43,9 +54,3 @@ def create_database(app): if not path.exists('website/' + DB_NAME): db.create_all(app=app) print('Created Database!') - - -def create_database(app): - if not path.exists('website/' + DB_NAME): - db.create_all(app=app) - print('Created Database!') diff --git a/website/auth.py b/website/auth.py index 40d322a3..55abaf57 100644 --- a/website/auth.py +++ b/website/auth.py @@ -80,3 +80,5 @@ def show_questionnaire(): return redirect(url_for('views.home')) return render_template('questionnaire.html', form=form) + + diff --git a/website/models.py b/website/models.py index bc20b10c..7d34233b 100644 --- a/website/models.py +++ b/website/models.py @@ -22,3 +22,11 @@ class QuestionnaireResponse(db.Model): question2 = db.Column(db.String(200), nullable=False) question3 = db.Column(db.String(200), nullable=False) user = db.relationship('User', backref=db.backref('responses', lazy=True)) + +class WeightEntry(db.Model): + id = db.Column(db.Integer, primary_key=True) + weight = db.Column(db.Float, nullable=False) + date_added = db.Column(db.DateTime(timezone=True), default=func.now()) + user_id = db.Column(db.Integer, db.ForeignKey('user.id')) + + user = db.relationship('User', backref=db.backref('weight_entries', lazy=True)) \ No newline at end of file diff --git a/website/weight_tracker.py b/website/weight_tracker.py new file mode 100644 index 00000000..60be58b6 --- /dev/null +++ b/website/weight_tracker.py @@ -0,0 +1,24 @@ +from flask import Blueprint, render_template, request, flash, redirect, url_for +from flask_login import login_required, current_user +from .models import WeightEntry +from . import db +from datetime import datetime as dt + +weight_tracker_bp = Blueprint('weight_tracker', __name__) + +@weight_tracker_bp.route('/weight-tracker', methods=['GET', 'POST']) +@login_required +def weight_tracker(): + if request.method == 'POST': + weight = float(request.form.get('weight')) + new_weight_entry = WeightEntry(user_id=current_user.id, weight=weight) + db.session.add(new_weight_entry) + db.session.commit() + flash('Weight added successfully!', category='success') + return redirect(url_for('weight_tracker.weight_tracker')) + + return render_template('weight_tracker.html') + +# Add routes for editing and deleting weight entries if needed + +# Example model definition for WeightEntry From 08b88640b7c292ff71e247e5b225269849c8ed1e Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 15:44:43 -0400 Subject: [PATCH 22/41] dynamic m --- website/templates/split.html | 39 +++--------------- website/views.py | 79 ++++++++++++++++++++++++++++-------- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/website/templates/split.html b/website/templates/split.html index 2f562244..85cd0ef3 100644 --- a/website/templates/split.html +++ b/website/templates/split.html @@ -5,43 +5,14 @@

Your Customized Workout Split

Based on your preferences, here is your workout plan:

+

Workout Plan:

+

Days per week: {{ days }}

    - {% for key, answer in responses.items() %} -
  • Question {{ key }}: {{ answer }}
  • + {% for group in included_groups %} +
  • {{ group }}
  • {% endfor %}
-

Workout Plan:

-{% if '1.1' in responses %} -

You have selected to not work on the following muscle groups:

-
    - {% if 'A' in responses['1.1'] %} -
  • Chest
  • - {% endif %} - {% if 'B' in responses['1.1'] %} -
  • Back
  • - {% endif %} - {% if 'C' in responses['1.1'] %} -
  • Arms
  • - {% endif %} - {% if 'D' in responses['1.1'] %} -
  • Shoulders
  • - {% endif %} - {% if 'E' in responses['1.1'] %} -
  • Legs
  • - {% endif %} -
-{% else %} -

Full Body Workout

-{% endif %} - - - +

{{ message }}

{% endblock %} diff --git a/website/views.py b/website/views.py index 668711fa..7a7ed45b 100644 --- a/website/views.py +++ b/website/views.py @@ -13,7 +13,7 @@ 'choices': [('1', 'Yes'), ('2', 'No')], 'next': { '1': '1.1', # Follow-up questions for answer '1' - '2': 'end' # Redirect to workout split for answer '2' + '2': 'end_condition1' # Redirect to workout split for answer '2' } }, '1.1': { @@ -21,21 +21,51 @@ 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('D', 'Shoulders'), ('E', 'Legs')], 'multi': True, 'next': { - 'A': 'end', - 'B': 'end', - 'C': 'end', - 'D': 'end', - 'E': 'end' + 'A': 'end_condition2', + 'B': 'end_condition2', + 'C': 'end_condition2', + 'D': 'end_condition2', + 'E': 'end_condition2' } }, - '1.1.1': { - 'text': 'Follow-up Question 1.1.1: [Placeholder]', - 'choices': [('X', 'X'), ('Y', 'Y'), ('Z', 'Z')], - 'next': {} + '2': { + 'text': 'Are there any muscle groups you DO NOT want to exercise?', + 'choices': [('1', 'Yes'), ('2', 'No')], + 'next': { + '1': '2.1', # Follow-up questions for answer '1' + '2': 'end_condition3' # Redirect to workout split for answer '2' + } }, + '2.1': { + 'text': 'Select all muscle groups you DO NOT want to exercise', + 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('D', 'Shoulders'), ('E', 'Legs')], + 'multi': True, + 'next': { + 'A': 'end_condition3', + 'B': 'end_condition3', + 'C': 'end_condition3', + 'D': 'end_condition3', + 'E': 'end_condition3' + } + }, + '2.2': { + 'text': 'Do you want to workout on back to back days?', + 'choices': [('1', 'Yes'), ('2', 'No')], + 'next': { + '1': 'end_condition3', + '2': 'end_condition3' + } + } # ... other questions ... } +conditions_messages = { + 'condition1': 'Message for condition 1', + 'condition2': 'Message for condition 2', + 'condition3': 'Message for condition 3', + # Add more conditions and messages as needed +} + @views.route('/questionnaire', methods=['GET', 'POST']) def questionnaire(): form = InitialQuestionForm() @@ -45,6 +75,7 @@ def questionnaire(): session['current_question'] = '1' # Start with question id '1' session['history'] = [] # Initialize history session['responses'] = {} # Initialize responses + session['condition'] = '' # Initialize condition return redirect(url_for('views.dynamic_question')) return render_template('questionnaire.html', form=form) @@ -65,13 +96,13 @@ def dynamic_question(): if 'next' in request.form: if form.validate(): answer = form.answer.data + # Ensure answer is stored as a list + if not isinstance(answer, list): + answer = [answer] session['responses'][current_question_id] = answer - if isinstance(answer, list): - # Handle multi-select answers - next_question_id = question['next'].get(answer[0], None) # Choose appropriate logic for multi-select - else: - next_question_id = question['next'].get(answer, None) - if next_question_id == 'end': + next_question_id = question['next'].get(answer[0], None) + if next_question_id and next_question_id.startswith('end_condition'): + session['condition'] = next_question_id.replace('end_', '') return redirect(url_for('views.split')) # Redirect to workout split tab at the end of the branch elif next_question_id: session['history'].append(current_question_id) @@ -97,8 +128,20 @@ def home(): def split(): # Use session['responses'] to customize the workout split responses = session.get('responses', {}) - # Process responses to customize the workout split - return render_template("split.html", user=current_user, responses=responses) + condition = session.get('condition', 'condition1') # Default to condition1 + days = session.get('days', 0) + muscle_groups = { + 'A': 'Chest', + 'B': 'Back', + 'C': 'Arms', + 'D': 'Shoulders', + 'E': 'Legs' + } + excluded_groups = responses.get('1.1', []) + included_groups = [muscle_groups[key] for key in muscle_groups if key not in excluded_groups] + message = conditions_messages.get(condition, 'Default message') + + return render_template("split.html", user=current_user, included_groups=included_groups, days=days, message=message) @views.route('/tracker', methods=['GET']) @login_required From b3ef1eebc3a1a5c2676046938ac3f2cc67e345c4 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Thu, 30 May 2024 15:57:49 -0400 Subject: [PATCH 23/41] trackerstorage --- instance/database.db | Bin 24576 -> 28672 bytes website/.DS_Store | Bin 6148 -> 6148 bytes website/__init__.py | 1 + website/forms.py | 1 + website/models.py | 13 ++++-- website/templates/weight_tracker.html | 35 ++++++++++------ website/views.py | 55 +++++++++++++++----------- 7 files changed, 67 insertions(+), 38 deletions(-) diff --git a/instance/database.db b/instance/database.db index 36ef2639ad37c76ada2e2f6a073e6ffe51b7a4e4..45e8988b4d5c57b7a91cef2570f926b7b4936660 100644 GIT binary patch delta 187 zcmZoTz}WDBae}mqH%6Nnr-PtP8ySKN#4!OBncN`Oovk^D6QlyiB!ku~2NHo}wr(0|Nsi1A_nqLncEBLp%`bF%)cG$h@2xEX55L%4Eoc zNlz|h5@BL+oNUIVwpoqInXx{pytp7KCqD^j&W@yloXp}91A}XfOw25-Z0sED9NZkS z!5R7G!6k_$rNvH(MbRK$NPd1!5{#Xg6qcD<9xou`oS#>cn3KFu;EWfLsCKP3F)`3lFf}o*)lsOnGy<|sjLm9mIXOg?^{s>A zvvYFu^1FbJ0|G{%N5KH(X=KnnS&><6awap+WEEy%?y}&byqx^JbfAjKh0G?hf(+#h zsX+gyGh~2+sDz=2A(0`OAsZ-K1Pl*J_IdxoU}E9t&Fmcf9Kg^8hTwPR$^0UY96&pn MKz4185Lv?v0I^D9MF0Q* delta 95 zcmZoMXfc=|#>B)qu~2NHo}wrx0|Nsi1A_nqLo!1m5N9x?GQ@8zT+YbIx!H*&mT__= v8_(qBYzC7h+23t!C}G~r&cV+C)V^7e<2&

Weight Tracker

- - - + + + + + - +
@@ -23,11 +25,24 @@

Weight Tracker

- - - - + + + + + + diff --git a/website/templates/home.html b/website/templates/home.html index 7b911f9a..e0d6fbc2 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -2,34 +2,13 @@ {% block title %}Home{% endblock %} {% block content %}

Welcome, {{ user.first_name }}!

- -
-
-

Welcome to PhySeek: Your Personalized Fitness Destination! +

Welcome to PhySeek: Your Personalized Fitness Destination! - At PhySeek, we believe that achieving your fitness goals should be personalized, convenient, and effective. That's why we've created a platform where you can embark on your fitness journey with confidence. - - Whether you're looking to build muscle, lose weight, improve endurance, or simply enhance your overall health, our custom-tailored workouts are designed to fit your unique needs and goals. Say goodbye to generic routines and hello to workouts that evolve with you. - - Track your progress effortlessly with our intuitive tools and charts, allowing you to see your achievements in real-time and stay motivated every step of the way. Whether you're a seasoned gym-goer or just starting out, PhySeek is here to support you on your path to a healthier, happier you. - - So, are you ready to unleash your full potential? Let's get started on your journey to a fitter, stronger, and more vibrant you. Welcome to PhySeek! Fill out the Questionnaire and start lifting today!

-
-
+At PhySeek, we believe that achieving your fitness goals should be personalized, convenient, and effective. That's why we've created a platform where you can embark on your fitness journey with confidence. + +Whether you're looking to build muscle, lose weight, improve endurance, or simply enhance your overall health, our custom-tailored workouts are designed to fit your unique needs and goals. Say goodbye to generic routines and hello to workouts that evolve with you. + +Track your progress effortlessly with our intuitive tools and charts, allowing you to see your achievements in real-time and stay motivated every step of the way. Whether you're a seasoned gym-goer or just starting out, PhySeek is here to support you on your path to a healthier, happier you. + +So, are you ready to unleash your full potential? Let's get started on your journey to a fitter, stronger, and more vibrant you. Welcome to PhySeek! Fill out the Questionnaire and start lifting today!

{% endblock %} diff --git a/website/templates/weight_tracker.html b/website/templates/weight_tracker.html index 960c6d48..3672870d 100644 --- a/website/templates/weight_tracker.html +++ b/website/templates/weight_tracker.html @@ -10,11 +10,11 @@

Weight Tracker

- +
- + - +
@@ -104,16 +104,26 @@

Weight Tracker

datasets: [{ label: 'Weight (lbs)', data: weights.map(entry => entry.weight), - backgroundColor: 'rgba(54, 162, 235, 0.2)', - borderColor: 'rgba(54, 162, 235, 1)', - borderWidth: 1 + backgroundColor: 'rgba(125, 13, 195, 0.2)', // Purple color + borderColor: 'rgba(125, 13, 195, 1)', // Purple color + borderWidth: 2, + pointRadius: 5, + pointHoverRadius: 7 }] }; const options = { scales: { yAxes: [{ ticks: { - beginAtZero: true + beginAtZero: true, + fontSize: 14, + fontColor: '#7D0DC3' // Purple color + } + }], + xAxes: [{ + ticks: { + fontSize: 14, + fontColor: '#7D0DC3' // Purple color } }] } From e642e94926da0189bb7e3e5d46c4a4e4c3ca7719 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Fri, 31 May 2024 14:08:28 -0400 Subject: [PATCH 25/41] updated d --- instance/database.db | Bin 28672 -> 28672 bytes website/templates/weight_tracker.html | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instance/database.db b/instance/database.db index 3303ec46b446ce5c541a8a0a81abd5aa2c790c5c..3b32d97f3ff0f46143ed1c4fcece34e9748afe6d 100644 GIT binary patch delta 98 zcmZp8z}WDBae_3X*hCp;MzM_vOX7K0`1=|7pYR{&U(MgYSx}*#-$IIomBE;a)5yTc jMAyJn*Vs_O(89{V#LCo&;gS?Hb~zJ6h7*&I=UV~*?p_z# delta 37 tcmZp8z}WDBae_3X$V3@uMv;vPOX4}0_>VL2KjA;VSWeight Tracker ticks: { beginAtZero: true, fontSize: 14, - fontColor: '#7D0DC3' // Purple color + fontColor: '#a317be' // Purple color } }], xAxes: [{ ticks: { fontSize: 14, - fontColor: '#7D0DC3' // Purple color + fontColor: '#a317be' // Purple color } }] } From 753774b5089d69c23e2d295d04a1d38f9deaf68c Mon Sep 17 00:00:00 2001 From: atipre Date: Fri, 31 May 2024 14:20:26 -0400 Subject: [PATCH 26/41] Aesthetics --- website/templates/home.html | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/website/templates/home.html b/website/templates/home.html index e0d6fbc2..cfae24a1 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -2,13 +2,31 @@ {% block title %}Home{% endblock %} {% block content %}

Welcome, {{ user.first_name }}!

-

Welcome to PhySeek: Your Personalized Fitness Destination! -At PhySeek, we believe that achieving your fitness goals should be personalized, convenient, and effective. That's why we've created a platform where you can embark on your fitness journey with confidence. +

+

Welcome to PhySeek: Your Personalized Fitness Destination!

-Whether you're looking to build muscle, lose weight, improve endurance, or simply enhance your overall health, our custom-tailored workouts are designed to fit your unique needs and goals. Say goodbye to generic routines and hello to workouts that evolve with you. +

+ At PhySeek, we believe that achieving your fitness goals should be personalized, convenient, and effective. That's why we've created a platform where you can embark on your fitness journey with confidence. +

-Track your progress effortlessly with our intuitive tools and charts, allowing you to see your achievements in real-time and stay motivated every step of the way. Whether you're a seasoned gym-goer or just starting out, PhySeek is here to support you on your path to a healthier, happier you. +

+ Whether you're looking to build muscle, lose weight, improve endurance, or simply enhance your overall health, our custom-tailored workouts are designed to fit your unique needs and goals. Say goodbye to generic routines and hello to workouts that evolve with you. +

-So, are you ready to unleash your full potential? Let's get started on your journey to a fitter, stronger, and more vibrant you. Welcome to PhySeek! Fill out the Questionnaire and start lifting today!

+

+ Track your progress effortlessly with our intuitive tools and charts, allowing you to see your achievements in real-time and stay motivated every step of the way. +

+ +

+ Whether you're a seasoned gym-goer or just starting out, PhySeek is here to support you on your path to a healthier, happier you. +

+ +

So, are you ready to unleash your full potential?

+ +

+ Let's get started on your journey to a fitter, stronger, and more vibrant you. Welcome to PhySeek! Fill out the Questionnaire and start lifting today! +

+
{% endblock %} + From 2c713444dda53b756fbce68a6658f79e0e128b95 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Fri, 31 May 2024 14:50:16 -0400 Subject: [PATCH 27/41] w --- .DS_Store | Bin 6148 -> 6148 bytes website/.DS_Store | Bin 6148 -> 8196 bytes website/static/style.css | 32 +++++++++++++++++++----- website/templates/base.html | 19 +++----------- website/templates/dynamic_question.html | 25 ++++++++++++------ website/templates/home.html | 6 +++-- website/templates/questionnaire.html | 23 ++++++++++++++--- website/views.py | 21 +++++++++------- 8 files changed, 83 insertions(+), 43 deletions(-) diff --git a/.DS_Store b/.DS_Store index 7784241d244e05937acf91b79e0a0d2d497fb76e..4d54cc80fdad7bbfb66a0bbe5117fa5e345fd45c 100644 GIT binary patch delta 20 bcmZoMXffC@kBQyF%uq+c#C-Eorg%{RLN5j6 delta 20 bcmZoMXffC@kBQyH#6U;E)MWEgrg%{RLDU7? diff --git a/website/.DS_Store b/website/.DS_Store index f3d149a8c9a2520b918737b03775e4149c3768f5..f767faf331f79130f214c1a3021d32eb647cbc61 100644 GIT binary patch delta 157 zcmZoMXmOBWU|?W$DortDU;r^WfEYvza8E20o2aMA$iFdQH}hr%jz7$c**Q2SHn1@A zZ{}g~W1OtV$~$>JYXiH5nW2t?iTPwTHU|kdhGK>ihD0FFWJoRxF3QWv&r1iIHo1{a vd~+`ADaOs}JkOcAB)EZMt{_V`3vzsCp3E=eIoY3wgM$%bKf~sDo;l0_HXb3b delta 112 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50$jG}fU^g=(?`9qWKgP*5Lc*J4 yg-$U}Y`CzPor6P=8K@En1h|2OD@fDE!tczJ`DHvoMldizj04%gusNP*4l@9A{u5OI diff --git a/website/static/style.css b/website/static/style.css index d4fa32d1..a6944532 100644 --- a/website/static/style.css +++ b/website/static/style.css @@ -90,19 +90,39 @@ body { margin: 20px auto; padding: 20px; } - +/* style.css */ +/* Button styles */ +/* style.css */ +/* Button styles */ +/* style.css */ /* Button styles */ .btn { - background-color: #a317be; /* Purple color */ - color: #fff; - border: none; + background-color: white; /* White color by default */ + color: black; /* Black text color by default */ + border: 1px solid #a317be; /* Border color to distinguish buttons */ padding: 10px 20px; cursor: pointer; border-radius: 5px; font-size: 16px; - transition: background-color 0.3s ease; + transition: background-color 0.3s ease, color 0.3s ease; + display: block; /* Make buttons block elements for vertical alignment */ + width: auto; /* Auto width to fit content */ + text-align: left; /* Align text to the left */ + margin-bottom: 10px; /* Space between buttons */ } .btn:hover { - background-color: #a317be; /* Darker purple */ + background-color: #a317be; /* Purple color on hover */ + color: white; /* White text color on hover */ +} + +.questionnaire-btn { + margin: 5px 0; /* Space between buttons */ + background-color: white; /* White by default */ + color: black; /* Black text by default */ +} + +.questionnaire-btn:hover { + background-color: #a317be; /* Purple color on hover */ + color: white; /* White text on hover */ } diff --git a/website/templates/base.html b/website/templates/base.html index d5a94159..1b304604 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -16,7 +16,8 @@
- - - - - - + +{% endblock %} \ No newline at end of file diff --git a/website/templates/home.html b/website/templates/home.html index cfae24a1..c479315e 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -25,8 +25,10 @@

Welcome, {{ user.first_name }}!

So, are you ready to unleash your full potential?

- Let's get started on your journey to a fitter, stronger, and more vibrant you. Welcome to PhySeek! Fill out the Questionnaire and start lifting today! + Let's get started on your journey to a fitter, stronger, and more vibrant you. Welcome to PhySeek!

+
{% endblock %} - diff --git a/website/templates/questionnaire.html b/website/templates/questionnaire.html index ede167fd..efd4387b 100644 --- a/website/templates/questionnaire.html +++ b/website/templates/questionnaire.html @@ -5,11 +5,28 @@

Questionnaire

{{ form.hidden_tag() }}
- {{ form.days.label }}
- {{ form.days }} + {{ form.days.label }}
+ {% for subfield in form.days %} + + {% endfor %} +
- {{ form.submit() }} + {{ form.submit(class="btn") }}
+ + {% endblock %} diff --git a/website/views.py b/website/views.py index a826a1a6..3c8b3683 100644 --- a/website/views.py +++ b/website/views.py @@ -1,4 +1,4 @@ -from flask import Blueprint, render_template, request, redirect, url_for, session, jsonify +from flask import Blueprint, render_template, request, redirect, url_for, session, jsonify, flash from flask_login import login_required, current_user from .forms import InitialQuestionForm, create_dynamic_form from .models import User, Weight @@ -67,13 +67,14 @@ def questionnaire(): form = InitialQuestionForm() if form.validate_on_submit(): - days = form.days.data - session['days'] = days - session['current_question'] = '1' - session['history'] = [] - session['responses'] = {} - session['condition'] = '' - return redirect(url_for('views.dynamic_question')) + selected_option = form.days.data + if selected_option: + flash(f'You selected: {selected_option}') + session['days'] = selected_option + session['current_question'] = '1' # Assuming the first question is '1' + session['history'] = [] + session['responses'] = {} + return redirect(url_for('views.dynamic_question')) return render_template('questionnaire.html', form=form) @views.route('/dynamic_question', methods=['GET', 'POST']) @@ -92,7 +93,7 @@ def dynamic_question(): if request.method == 'POST': if 'next' in request.form: if form.validate(): - answer = form.answer.data + answer = request.form.get('answer') if not isinstance(answer, list): answer = [answer] session['responses'][current_question_id] = answer @@ -110,6 +111,8 @@ def dynamic_question(): if session['history']: previous_question_id = session['history'].pop() session['current_question'] = previous_question_id + if previous_question_id == '1': # Assuming the first question is '1' + return redirect(url_for('views.questionnaire')) return redirect(url_for('views.dynamic_question')) return render_template('dynamic_question.html', question=question, form=form) From 6252e6e92d09ae5a3aecb3dfc85022fadb2c1016 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Fri, 31 May 2024 15:15:19 -0400 Subject: [PATCH 28/41] w --- website/templates/dynamic_question.html | 42 ++++++++++++++++++------- website/views.py | 12 ++++--- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/website/templates/dynamic_question.html b/website/templates/dynamic_question.html index 6dc6536a..c9c14914 100644 --- a/website/templates/dynamic_question.html +++ b/website/templates/dynamic_question.html @@ -6,9 +6,9 @@

{{ question.text }}

{{ form.hidden_tag() }}
{% for subfield in form.answer %} - + {% endfor %} - +
@@ -17,16 +17,34 @@

{{ question.text }}

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/website/views.py b/website/views.py index 3c8b3683..8b871456 100644 --- a/website/views.py +++ b/website/views.py @@ -58,8 +58,8 @@ } conditions_messages = { - 'condition1': 'Message for condition 1', - 'condition2': 'Message for condition 2', + 'condition1': 'Full Body Workout', + 'condition2': 'Customized Split', 'condition3': 'Message for condition 3' } @@ -94,7 +94,9 @@ def dynamic_question(): if 'next' in request.form: if form.validate(): answer = request.form.get('answer') - if not isinstance(answer, list): + if question.get('multi'): + answer = answer.split(',') + else: answer = [answer] session['responses'][current_question_id] = answer next_question_id = question['next'].get(answer[0], None) @@ -111,9 +113,9 @@ def dynamic_question(): if session['history']: previous_question_id = session['history'].pop() session['current_question'] = previous_question_id - if previous_question_id == '1': # Assuming the first question is '1' - return redirect(url_for('views.questionnaire')) return redirect(url_for('views.dynamic_question')) + else: + return redirect(url_for('views.questionnaire')) return render_template('dynamic_question.html', question=question, form=form) From 18e9a52735a7db07404e7229bcf6686c2b4d7e89 Mon Sep 17 00:00:00 2001 From: Danny Kardhashi Date: Fri, 31 May 2024 15:24:23 -0400 Subject: [PATCH 29/41] newest --- website/views.py | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/website/views.py b/website/views.py index 8b871456..354d062f 100644 --- a/website/views.py +++ b/website/views.py @@ -28,26 +28,14 @@ } }, '2': { - 'text': 'Are there any muscle groups you DO NOT want to exercise?', - 'choices': [('1', 'Yes'), ('2', 'No')], + 'text': 'How many days a week do you want to workout?', + 'choices': [('1', '1 day'), ('2', '2 days'), ('3', '3 days'), ('4', '4 days'), ('5', '5 days'), ('6', '6 days'), ('7', '7 days')], 'next': { '1': '2.1', '2': 'end_condition3' } }, '2.1': { - 'text': 'Select all muscle groups you DO NOT want to exercise', - 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('D', 'Shoulders'), ('E', 'Legs')], - 'multi': True, - 'next': { - 'A': 'end_condition3', - 'B': 'end_condition3', - 'C': 'end_condition3', - 'D': 'end_condition3', - 'E': 'end_condition3' - } - }, - '2.2': { 'text': 'Do you want to workout on back to back days?', 'choices': [('1', 'Yes'), ('2', 'No')], 'next': { @@ -58,8 +46,8 @@ } conditions_messages = { - 'condition1': 'Full Body Workout', - 'condition2': 'Customized Split', + 'condition1': 'Message for condition 1', + 'condition2': 'Message for condition 2', 'condition3': 'Message for condition 3' } @@ -99,11 +87,18 @@ def dynamic_question(): else: answer = [answer] session['responses'][current_question_id] = answer - next_question_id = question['next'].get(answer[0], None) - if next_question_id and next_question_id.startswith('end_condition'): - session['condition'] = next_question_id.replace('end_', '') - return redirect(url_for('views.split')) - elif next_question_id: + + # Determine the next question or end condition based on all selected answers + next_question_id = None + for ans in answer: + next_id = question['next'].get(ans) + if next_id and next_id.startswith('end_condition'): + session['condition'] = next_id.replace('end_', '') + return redirect(url_for('views.split')) + elif next_id: + next_question_id = next_id + + if next_question_id: session['history'].append(current_question_id) session['current_question'] = next_question_id return redirect(url_for('views.dynamic_question')) From 58976d642aa8b54c431d9c9dba3efd05c2b32b46 Mon Sep 17 00:00:00 2001 From: dkardhashi Date: Sun, 7 Jul 2024 14:14:10 -0400 Subject: [PATCH 30/41] new ui --- .DS_Store | Bin 6148 -> 6148 bytes instance/database.db | Bin 28672 -> 28672 bytes website/.DS_Store | Bin 8196 -> 8196 bytes website/static/style.css | 36 ++++++++++++ website/templates/about.html | 7 +++ website/templates/base.html | 13 +++-- website/templates/home.html | 108 +++++++++++++++++++++++++++-------- website/templates/split.html | 24 ++++---- website/views.py | 27 +++++---- 9 files changed, 165 insertions(+), 50 deletions(-) create mode 100644 website/templates/about.html diff --git a/.DS_Store b/.DS_Store index 4d54cc80fdad7bbfb66a0bbe5117fa5e345fd45c..04fd16fbe574aeb6097c53d6c20a11fb4b464f64 100644 GIT binary patch delta 348 zcmZ9Iy$ZrW5QHZeAyEV^Vmd*42^KVZ7r~puaIxxcmF1%5&bd$IGP*1X?!{_rBQNHX1 zONTWw=rgQedYAzkLMkO=VTGeK%c)-lbr};3=`p~Vw?%fI5hvL|X%>(=Ht?{QD%_xmjbV0Pr{+zr#}5{HlXs&sTIUk5o@;HY4vP7xeHe$nqJenJMQPB Q#xB)qu~2NHo}wr#0|Nsi1A_nqLncEBLuyiaaY0hf#=_-{jI5KnSSPca w8R{sQm>X|i!kWyqvEd)nW_AvK4xskUf*jwOC-aLqasUkgnZU9+LSzjy04((t*Z=?k diff --git a/instance/database.db b/instance/database.db index 3b32d97f3ff0f46143ed1c4fcece34e9748afe6d..1bd86963907f381fd7249e2e189770021971bd12 100644 GIT binary patch delta 72 zcmZp8z}WDBae_3X_(U0JM)8daOXB%h`HLC&pYR{&U(MgoU%XjRA(3B3ij|eYn2FQK bz{o_`z#NDa3@xk-jjT+K84geG&o2Z3About PhySeek +

Welcome to PhySeek, your personalized fitness destination!

+ +{% endblock %} diff --git a/website/templates/base.html b/website/templates/base.html index 1b304604..0ca6b21e 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -15,12 +15,10 @@
- - + + + + diff --git a/website/templates/home.html b/website/templates/home.html index c479315e..2c435b1d 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -1,34 +1,94 @@ {% extends "base.html" %} -{% block title %}Home{% endblock %} +{% block title %}Dashboard{% endblock %} {% block content %} -

Welcome, {{ user.first_name }}!

+
+
+

Weight Tracker

+ +
+
+

Today's Workout

+

Loading today's workout...

+
+
-
-

Welcome to PhySeek: Your Personalized Fitness Destination!

+ {% endblock %} diff --git a/website/templates/split.html b/website/templates/split.html index 85cd0ef3..2c5e731e 100644 --- a/website/templates/split.html +++ b/website/templates/split.html @@ -3,16 +3,20 @@ {% block content %}

Your Customized Workout Split

-

Based on your preferences, here is your workout plan:

+
+

Today's Workout

+

Chest: bench press 3 x 10, lateral raise 4 x 15, tricep pushdowns 3 x 12, dips 3 x 15.

+
-

Workout Plan:

-

Days per week: {{ days }}

-
    - {% for group in included_groups %} -
  • {{ group }}
  • - {% endfor %} -
- -

{{ message }}

+
+

Rest of the Week's Workouts

+ +

Details for the rest of the week...

+
+
+

Past Workouts

+ +

Details of past workouts...

+
{% endblock %} diff --git a/website/views.py b/website/views.py index 354d062f..d28c06f4 100644 --- a/website/views.py +++ b/website/views.py @@ -6,6 +6,15 @@ views = Blueprint('views', __name__) +@views.route('/') +@login_required +def home(): + return render_template('home.html', user=current_user) + +@views.route('/about') +def about(): + return render_template('about.html') + questions_data = { '1': { 'text': 'Are there any muscle groups you DO NOT want to exercise?', @@ -114,11 +123,6 @@ def dynamic_question(): return render_template('dynamic_question.html', question=question, form=form) -@views.route('/', methods=['GET']) -@login_required -def home(): - return render_template("home.html", user=current_user) - @views.route('/split', methods=['GET']) @login_required def split(): @@ -138,11 +142,6 @@ def split(): return render_template("split.html", user=current_user, included_groups=included_groups, days=days, message=message) -@views.route('/tracker', methods=['GET']) -@login_required -def tracker(): - return render_template("tracker.html", user=current_user) - @views.route('/weight_tracker', methods=['GET', 'POST']) @login_required def weight_tracker(): @@ -161,3 +160,11 @@ def get_weights(): weights = Weight.query.filter_by(user_id=current_user.id).order_by(Weight.date).all() weights_data = [{"date": w.date.strftime("%Y-%m-%d"), "weight": w.weight} for w in weights] return jsonify(weights_data) + +import random + +@views.route('/get_todays_workout') +@login_required +def get_todays_workout(): + todays_workout = "Chest: bench press 3 x 10, lateral raise 4 x 15, tricep pushdowns 3 x 12, dips 3 x 15." + return jsonify({"todays_workout": todays_workout}) From 0500700cd7f393379f7fd96d0a73fd972d9ecc34 Mon Sep 17 00:00:00 2001 From: atipre Date: Tue, 9 Jul 2024 18:27:23 -0400 Subject: [PATCH 31/41] Cool stuff --- instance/database.db | Bin 28672 -> 28672 bytes website/templates/home.html | 83 ++++++++++++++++++++++++++++++++---- 2 files changed, 75 insertions(+), 8 deletions(-) diff --git a/instance/database.db b/instance/database.db index 1bd86963907f381fd7249e2e189770021971bd12..70aee0cad2a59fe8b992661927935198241726e1 100644 GIT binary patch delta 106 zcmZp8z}WDBae_3X + .dashboard-container { + display: flex; + flex-direction: column; + align-items: center; + height: 100vh; + justify-content: center; + } + .workout-split { + width: 50%; + height: 50%; + margin: 20px 0; + text-align: center; + background-color: #f9f9f9; + padding: 20px; + border-radius: 10px; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); + display: flex; + flex-direction: column; + justify-content: center; + } + .weight-tracker { + width: 80%; + margin: 20px 0; + text-align: center; + } + #weightTrackerButton { + width: 100%; + background-color: #fff; + color: #7d0dc3; + border: 2px solid #7d0dc3; + padding: 10px 20px; + font-size: 16px; + border-radius: 5px; + cursor: pointer; + display: flex; + flex-direction: column; + align-items: center; + } + #weightTrackerButton:hover { + background-color: #f0f0f0; + } + .canvas-container { + position: relative; + height: 150px; + width: 100%; + } + #weightTrackerText { + margin-top: 10px; + } + +
-
-

Weight Tracker

- -

Today's Workout

Loading today's workout...

+
+ +
+ + + + + diff --git a/website/templates/dynamic_question.html b/website/templates/dynamic_question.html index c9c14914..fa40e25e 100644 --- a/website/templates/dynamic_question.html +++ b/website/templates/dynamic_question.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% extends "base_questionnaire.html" %} {% block title %}Dynamic Question{% endblock %} {% block content %}

{{ question.text }}

diff --git a/website/templates/questionnaire.html b/website/templates/questionnaire.html index efd4387b..de6d9b78 100644 --- a/website/templates/questionnaire.html +++ b/website/templates/questionnaire.html @@ -1,4 +1,5 @@ {% extends "base.html" %} +{% extends "base_questionnaire.html" %} {% block title %}Questionnaire{% endblock %} {% block content %}

Questionnaire

From 117559c4b4d8628bad7eec3ecf2c31de9afdffc4 Mon Sep 17 00:00:00 2001 From: atipre Date: Tue, 9 Jul 2024 19:01:31 -0400 Subject: [PATCH 35/41] Editted boxes spacing --- website/templates/home.html | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/website/templates/home.html b/website/templates/home.html index 26dd2587..d59f6164 100644 --- a/website/templates/home.html +++ b/website/templates/home.html @@ -4,15 +4,16 @@ From 5bc22247ed97d4de7a4f129b2f9dbe5b3f9a90ad Mon Sep 17 00:00:00 2001 From: dkardhashi Date: Tue, 9 Jul 2024 19:12:35 -0400 Subject: [PATCH 36/41] w --- website/questionnaire.py | 92 ++++++++++++++++++++++++++++++++++ website/views.py | 103 +++++---------------------------------- 2 files changed, 105 insertions(+), 90 deletions(-) create mode 100644 website/questionnaire.py diff --git a/website/questionnaire.py b/website/questionnaire.py new file mode 100644 index 00000000..b6f3a044 --- /dev/null +++ b/website/questionnaire.py @@ -0,0 +1,92 @@ +from flask import session +from .forms import InitialQuestionForm, create_dynamic_form + +questions_data = { + '1': { + 'text': 'Are there any muscle groups you DO NOT want to exercise?', + 'choices': [('1', 'Yes'), ('2', 'No')], + 'next': { + '1': '1.1', + '2': 'end_condition1' + } + }, + '1.1': { + 'text': 'Select all muscle groups you DO NOT want to exercise', + 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('D', 'Shoulders'), ('E', 'Legs')], + 'multi': True, + 'next': { + 'A': 'end_condition2', + 'B': 'end_condition2', + 'C': 'end_condition2', + 'D': 'end_condition2', + 'E': 'end_condition2' + } + }, + '2': { + 'text': 'How many days a week do you want to workout?', + 'choices': [('1', '1 day'), ('2', '2 days'), ('3', '3 days'), ('4', '4 days'), ('5', '5 days'), ('6', '6 days'), ('7', '7 days')], + 'next': { + '1': '2.1', + '2': 'end_condition3' + } + }, + '2.1': { + 'text': 'Do you want to workout on back to back days?', + 'choices': [('1', 'Yes'), ('2', 'No')], + 'next': { + '1': 'end_condition3', + '2': 'end_condition3' + } + } +} + +conditions_messages = { + 'condition1': 'Message for condition 1', + 'condition2': 'Message for condition 2', + 'condition3': 'Message for condition 3' +} + +def get_next_question_and_update_session(answer, question): + next_question_id = None + if question.get('multi'): + answer = answer.split(',') + else: + answer = [answer] + session['responses'][session['current_question']] = answer + + for ans in answer: + next_id = question['next'].get(ans) + if next_id and next_id.startswith('end_condition'): + session['condition'] = next_id.replace('end_', '') + return None # End condition reached + elif next_id: + next_question_id = next_id + + if next_question_id: + session['history'].append(session['current_question']) + session['current_question'] = next_question_id + + return next_question_id + +def initialize_questionnaire(form): + selected_option = form.days.data + if selected_option: + session['days'] = selected_option + session['current_question'] = '1' # Assuming the first question is '1' + session['history'] = [] + session['responses'] = {} + return True + return False + +def get_question_and_form(): + current_question_id = session.get('current_question') + if current_question_id is None: + return None, None + + question = questions_data.get(current_question_id) + if question is None: + return None, None + + DynamicForm = create_dynamic_form(question) + form = DynamicForm() + return question, form diff --git a/website/views.py b/website/views.py index 45f77fbe..eaa1e120 100644 --- a/website/views.py +++ b/website/views.py @@ -1,8 +1,8 @@ from flask import Blueprint, render_template, request, redirect, url_for, session, jsonify, flash from flask_login import login_required, current_user -from .forms import InitialQuestionForm, create_dynamic_form from .models import User, Weight, QuestionnaireResponse from . import db +from .questionnaire import questions_data, conditions_messages, get_next_question_and_update_session, initialize_questionnaire, get_question_and_form views = Blueprint('views', __name__) @@ -15,51 +15,6 @@ def home(): def about(): return render_template('about.html') -questions_data = { - '1': { - 'text': 'Are there any muscle groups you DO NOT want to exercise?', - 'choices': [('1', 'Yes'), ('2', 'No')], - 'next': { - '1': '1.1', - '2': 'end_condition1' - } - }, - '1.1': { - 'text': 'Select all muscle groups you DO NOT want to exercise', - 'choices': [('A', 'Chest'), ('B', 'Back'), ('C', 'Arms'), ('D', 'Shoulders'), ('E', 'Legs')], - 'multi': True, - 'next': { - 'A': 'end_condition2', - 'B': 'end_condition2', - 'C': 'end_condition2', - 'D': 'end_condition2', - 'E': 'end_condition2' - } - }, - '2': { - 'text': 'How many days a week do you want to workout?', - 'choices': [('1', '1 day'), ('2', '2 days'), ('3', '3 days'), ('4', '4 days'), ('5', '5 days'), ('6', '6 days'), ('7', '7 days')], - 'next': { - '1': '2.1', - '2': 'end_condition3' - } - }, - '2.1': { - 'text': 'Do you want to workout on back to back days?', - 'choices': [('1', 'Yes'), ('2', 'No')], - 'next': { - '1': 'end_condition3', - '2': 'end_condition3' - } - } -} - -conditions_messages = { - 'condition1': 'Message for condition 1', - 'condition2': 'Message for condition 2', - 'condition3': 'Message for condition 3' -} - @views.route('/questionnaire', methods=['GET', 'POST']) @login_required def questionnaire(): @@ -68,13 +23,7 @@ def questionnaire(): form = InitialQuestionForm() if form.validate_on_submit(): - selected_option = form.days.data - if selected_option: - flash(f'You selected: {selected_option}') - session['days'] = selected_option - session['current_question'] = '1' # Assuming the first question is '1' - session['history'] = [] - session['responses'] = {} + if initialize_questionnaire(form): return redirect(url_for('views.dynamic_question')) return render_template('questionnaire.html', form=form) @@ -84,45 +33,19 @@ def dynamic_question(): if current_user.has_completed_questionnaire: return redirect(url_for('views.home')) - current_question_id = session.get('current_question') - if current_question_id is None: - return redirect(url_for('views.questionnaire')) - - question = questions_data.get(current_question_id) + question, form = get_question_and_form() if question is None: return redirect(url_for('views.questionnaire')) - - DynamicForm = create_dynamic_form(question) - form = DynamicForm() if request.method == 'POST': - if 'next' in request.form: - if form.validate(): - answer = request.form.get('answer') - if question.get('multi'): - answer = answer.split(',') - else: - answer = [answer] - session['responses'][current_question_id] = answer - - # Determine the next question or end condition based on all selected answers - next_question_id = None - for ans in answer: - next_id = question['next'].get(ans) - if next_id and next_id.startswith('end_condition'): - session['condition'] = next_id.replace('end_', '') - current_user.has_completed_questionnaire = True - db.session.commit() - return redirect(url_for('views.home')) - elif next_id: - next_question_id = next_id - - if next_question_id: - session['history'].append(current_question_id) - session['current_question'] = next_question_id - return redirect(url_for('views.dynamic_question')) - else: - return redirect(url_for('views.questionnaire')) + if 'next' in request.form and form.validate(): + answer = request.form.get('answer') + next_question_id = get_next_question_and_update_session(answer, question) + if next_question_id is None: + current_user.has_completed_questionnaire = True + db.session.commit() + return redirect(url_for('views.home')) + return redirect(url_for('views.dynamic_question')) elif 'back' in request.form: if session['history']: previous_question_id = session['history'].pop() @@ -130,7 +53,7 @@ def dynamic_question(): return redirect(url_for('views.dynamic_question')) else: return redirect(url_for('views.questionnaire')) - + return render_template('dynamic_question.html', question=question, form=form) @views.route('/split', methods=['GET']) @@ -149,7 +72,7 @@ def split(): excluded_groups = responses.get('1.1', []) included_groups = [muscle_groups[key] for key in muscle_groups if key not in excluded_groups] message = conditions_messages.get(condition, 'Default message') - + return render_template("split.html", user=current_user, included_groups=included_groups, days=days, message=message) @views.route('/weight_tracker', methods=['GET', 'POST']) From 1ed95af196180abbe856dc10e5dddf01e17ae01f Mon Sep 17 00:00:00 2001 From: atipre Date: Tue, 9 Jul 2024 19:21:27 -0400 Subject: [PATCH 37/41] Changed Dashboard to home and logout to profile --- website/templates/base.html | 4 ++-- website/templates/home.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/website/templates/base.html b/website/templates/base.html index 0ca6b21e..7b20a078 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -15,11 +15,11 @@
+
+

© 2024 Physeek Training. All rights reserved.

+
+ From 4771cc67e637c97cc25bd31d2244adbd16056624 Mon Sep 17 00:00:00 2001 From: dkardhashi Date: Tue, 9 Jul 2024 19:42:22 -0400 Subject: [PATCH 40/41] deez --- website/templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/templates/base.html b/website/templates/base.html index fc00d0d8..1e90b2c2 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -69,7 +69,7 @@
  • Workout Split
  • Weight Tracker
  • About
  • -
  • Logout
  • +
  • Profile
  • {% else %}
  • Login
  • Sign Up
  • From 2e62a2579921f32eb210d951db0cda543ef35727 Mon Sep 17 00:00:00 2001 From: dkardhashi Date: Tue, 9 Jul 2024 20:11:37 -0400 Subject: [PATCH 41/41] W --- website/templates/base.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/templates/base.html b/website/templates/base.html index 1e90b2c2..fc00d0d8 100644 --- a/website/templates/base.html +++ b/website/templates/base.html @@ -69,7 +69,7 @@
  • Workout Split
  • Weight Tracker
  • About
  • -
  • Profile
  • +
  • Logout
  • {% else %}
  • Login
  • Sign Up