Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to log complete nutritional plan #506

Closed
rolandgeider opened this issue Aug 30, 2020 · 10 comments · Fixed by #540
Closed

Add option to log complete nutritional plan #506

rolandgeider opened this issue Aug 30, 2020 · 10 comments · Fixed by #540
Milestone

Comments

@rolandgeider
Copy link
Member

At the moment, it is possible to log all entries for a meal. It should also be possible to log the calories for all meals for a day.

This is really simple, instead of just adding the ingredients for a meal, we need to loop through all meals in a plan and add those (since this will duplicade code, a bit of refactoring will be needed as well).

@oconnelc
Copy link
Contributor

oconnelc commented Oct 4, 2020

If this is still open, I'd like to take a crack at it.

@oconnelc
Copy link
Contributor

oconnelc commented Oct 4, 2020

Is the plan to place a button on the "Nutrition plan" view to log the entire plan? If so, how does the total calories get logged?

I see similar logic in the NutritionPlan's get_nutritional_values method; it appears that the method iterates over the meals and sums up all of the values. Is this doing what this ticket is describing or is this similar code that needs to be refactored?

@rolandgeider
Copy link
Member Author

rolandgeider commented Oct 4, 2020

Yes it should be placed there. The calories are summed by the log and the plan, you only need to add the ingredients and units (e.g. 100g of bread, 2 slices of cheese, etc)

Take a look at

def log_meal(request, meal_pk):
to see how it is done for a single meal. For the whole plan you'd need to iterate over each meal in it

@oconnelc
Copy link
Contributor

oconnelc commented Oct 4, 2020

Awsome! I'll take a look at it today.

@oconnelc
Copy link
Contributor

oconnelc commented Oct 4, 2020

I just wanted to make sure I'm going in the right direction. I've added a link at the bottom of the plan to log the entire plan:

image

Right now it's just "Log this Plan".

If this looks good, I'll go ahead and hook it up to the back end and push up a PR when I'm done.

@oconnelc
Copy link
Contributor

oconnelc commented Oct 4, 2020

I think I have what this ticket is asking for. I've included a gif screenshot of how to log an entire plan. If this is what is desired, then all I have left is to update the unit test. If there's anything else that needs to be done to complete this ticket, please let me know.

NutritionDemo

@rolandgeider
Copy link
Member Author

Nice work! You can open a PR after updating the tests

@oconnelc
Copy link
Contributor

oconnelc commented Oct 8, 2020

Pull request #540 is now available

@rolandgeider rolandgeider linked a pull request Oct 8, 2020 that will close this issue
3 tasks
@oconnelc
Copy link
Contributor

oconnelc commented Oct 8, 2020

I'm participating in Hacktoberfest. According to the site this project is not participating. I was wondering if a maintainer could add the "hacktoberfest-accepted" label to the PR. This way the whole project doesn't have to participate and I can get credit.

If you'd like to have the project participate, a maintainer can add the topic "hacktoberfest" to the project

If not, no worries, I was happy to help with this project.

@rolandgeider
Copy link
Member Author

Hacktoberfest, I completely forgot about that! I'll clean up the issues a bit and add the tag

@rolandgeider rolandgeider added this to the 2.0 milestone Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants