Skip to content

Commit

Permalink
Merge pull request #11 from utsavll0/Ojas
Browse files Browse the repository at this point in the history
Changed logic for storing calorie intake and deficit
  • Loading branch information
neha7799 authored Oct 13, 2023
2 parents a5fdb0e + 05af19e commit 0350184
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
14 changes: 3 additions & 11 deletions application.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,10 @@ def calories():
if match:
cals=int(match.group(1))
else:
cals=None
cals=0
# cals = int(cals[1][1:len(cals[1]) - 1])
burn = request.form.get('burnout')

temp = mongo.db.calories.find_one({'email': email}, {
'email', 'calories', 'burnout'})
if temp is not None:
mongo.db.calories.update_one({'email': email}, {'$set': {
'calories': temp['calories'] + cals, 'burnout': temp['burnout'] + int(burn)}})
else:
mongo.db.calories.insert_one(
{'date': now, 'email': email, 'calories': cals, 'burnout': int(burn)})
mongo.db.calories.insert_one(
{'date': now, 'email': email, 'calories': cals})
flash(f'Successfully updated the data', 'success')
return redirect(url_for('calories'))
else:
Expand Down
1 change: 0 additions & 1 deletion forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class CalorieForm(FlaskForm):
food = SelectField(
'Select Food', choices=result)

burnout = StringField('Burn Out', validators=[DataRequired()])
submit = SubmitField('Save')


Expand Down
4 changes: 0 additions & 4 deletions templates/calories.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
{{ form.food.label(class="form-control-label") }}
{{ form.food(class="form-control form-control-lg") }}
</div>
<div class="form-group">
{{ form.burnout.label(class="form-control-label") }}
{{ form.burnout(class="form-control form-control-lg") }}
</div>
</fieldset>
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
Expand Down

0 comments on commit 0350184

Please sign in to comment.