Giter VIP home page Giter VIP logo

dylanleigh / priceandnutritiontrackingsystem Goto Github PK

View Code? Open in Web Editor NEW
108.0 12.0 27.0 1.31 MB

PANTS is a self-hosted, open-source nutrition tracker and tool for nutritional data analysis of ingredients and recipes.

License: Apache License 2.0

Makefile 0.19% Python 51.30% HTML 32.31% CSS 11.30% JavaScript 4.90%
nutrition nutrition-label nutrition-calculator nutritionist-application diet diet-calorie calorie-counter calories-tracker calorie-calculator

priceandnutritiontrackingsystem's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

priceandnutritiontrackingsystem's Issues

Error when adding the author's sample Ingredient data: user `testuserbob` doesn't exist

I did a fresh install, and tried to run the following command:

./manage.py loaddata fixtures/pants-ingredient-fixture.json

but I got the following error

 raise DeserializationError.WithData(e, label, self.object.pk, field_value)
django.core.serializers.base.DeserializationError: User matching query does not exist.: (ingredients.ingredient:pk=234) field_value was '['testuserbob']'

I think the issue has to do with this entry

{
"model": "ingredients.ingredient",
"pk": 234,
"fields": {
"kilojoules": null,
"protein": null,
"fibre": null,
"carbohydrate": null,
"fat": null,
"sugar": null,
"saturatedfat": null,
"sodium": null,
"created_at": "2020-04-14T02:28:45.077Z",
"updated_at": "2020-04-14T02:29:54.204Z",
"name": "test ing",
"slug": "test-ing",
"description": "",
"owner": [
"testuserbob"
],
"serving": null,
"introduction": "",
"notes": "",
"tags": []
}
},

since it references the user testuserbob which is not setup in my fresh install.

Removing that entry and running the command again seems to fix it. I can make a PR with this fix, but not sure if that's a bug, or expected?

Add importing of ingredients from standardized sources

Adding ingredients manually can work for basic macro nutrient tracking and inclusion into recipes, but standardized sources of nutritional information exist. These sources can provide finer detail and nutrition data not included on consumer labels (e.g. density, useful for conversion between volume and weight measures). Oftentimes this data is collected with government funding and is therefore freely available, others are crowd sourced projects.

Pants could offer importing from these sources. Either a bulk import of everything (simple) or a search and import of individual foods (more complex, but better user experience). We wouldn't have to ship this data with PANTS, but could provide an offer to automatically download the files, or links to where the files could be downloaded

I know this is a 'feature request' more than a bug or issue, but I dont think there are any issue labels setup in this repo. I'll label it if those become available.

"object 'Target' has no attribute 'ObjectDoesNotExist'" with fresh install

I did a fresh clone and install as of today according to the readme and am faced with the following error when navigating to http://127.0.0.1:8000/. Note that http://127.0.0.1:8000/adminbackend/ flawlessly works.

System Information:

  • Windows 10 Pro 64-bit
  • Python 3.7.3
AttributeError at /
type object 'Target' has no attribute 'ObjectDoesNotExist'
Request Method:
GET
Request URL:
http://127.0.0.1:8000/
Django Version:
2.2.6
Exception Type:
AttributeError
Exception Value:
type object 'Target' has no attribute 'ObjectDoesNotExist'
Exception Location:
D:\Documents\CaloriesTracker\pants\pants\targets\models.py in get_primary_target, line 85
Python Executable:
C:\Users\ComFreek\.virtualenvs\CaloriesTracker-r75ZFtn5\Scripts\python.exe
Python Version:
3.7.3
Python Path:
['D:\\Documents\\CaloriesTracker\\pants\\pants',
 'C:\\Users\\ComFreek\\.virtualenvs\\CaloriesTracker-r75ZFtn5\\Scripts\\python37.zip',
 'C:\\Users\\ComFreek\\.virtualenvs\\CaloriesTracker-r75ZFtn5\\DLLs',
 'C:\\Users\\ComFreek\\.virtualenvs\\CaloriesTracker-r75ZFtn5\\lib',
 'C:\\Users\\ComFreek\\.virtualenvs\\CaloriesTracker-r75ZFtn5\\Scripts',
 'c:\\python37\\Lib',
 'c:\\python37\\DLLs',
 'C:\\Users\\ComFreek\\.virtualenvs\\CaloriesTracker-r75ZFtn5',
 'C:\\Users\\ComFreek\\.virtualenvs\\CaloriesTracker-r75ZFtn5\\lib\\site-packages']
Server time:
Tue, 15 Oct 2019 19:42:40 +1100
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 2.2.6
Python Version: 3.7.3
Installed Applications:
['ingredients.apps.IngredientsConfig',
 'products.apps.ProductsConfig',
 'recipes.apps.RecipesConfig',
 'diary.apps.DiaryConfig',
 'targets.apps.TargetsConfig',
 'website.apps.WebsiteConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_extensions',
 'django_filters']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "D:\Documents\CaloriesTracker\pants\pants\targets\models.py" in get_primary_target
  84.          return Target.objects.get(user=user,daily_target=True)

File "C:\Users\ComFreek\.virtualenvs\CaloriesTracker-r75ZFtn5\lib\site-packages\django\db\models\manager.py" in manager_method
  82.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "C:\Users\ComFreek\.virtualenvs\CaloriesTracker-r75ZFtn5\lib\site-packages\django\db\models\query.py" in get
  408.                 self.model._meta.object_name

During handling of the above exception (Target matching query does not exist.), another exception occurred:

File "C:\Users\ComFreek\.virtualenvs\CaloriesTracker-r75ZFtn5\lib\site-packages\django\core\handlers\exception.py" in inner
  34.             response = get_response(request)

File "C:\Users\ComFreek\.virtualenvs\CaloriesTracker-r75ZFtn5\lib\site-packages\django\core\handlers\base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "C:\Users\ComFreek\.virtualenvs\CaloriesTracker-r75ZFtn5\lib\site-packages\django\core\handlers\base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\ComFreek\.virtualenvs\CaloriesTracker-r75ZFtn5\lib\site-packages\django\contrib\auth\decorators.py" in _wrapped_view
  21.                 return view_func(request, *args, **kwargs)

File "D:\Documents\CaloriesTracker\pants\pants\website\views.py" in index
  30.       'daily_target': Target.get_primary_target(user),

File "D:\Documents\CaloriesTracker\pants\pants\targets\models.py" in get_primary_target
  85.       except Target.ObjectDoesNotExist:

Exception Type: AttributeError at /
Exception Value: type object 'Target' has no attribute 'ObjectDoesNotExist'

TemplateSyntaxError at /wearpants/

Hi Dylan, your application really intrigues me, it can be the most complete I've ever seen. I followed your instructions but trying to access http://127.0.0.1:8000 it gives the following error in the rendered webpage:

TemplateSyntaxError at /wearpants/

'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
css_visuals
debugger_tags
highlighting
i18n
indent_text
l10n
log
static
syntax_color
truncate_letters
tz
widont

Any hint?

Adding an ingredient component with a weight of 0 causes a recipe to be unviewable

Adding 0 grams of an ingredient component to a recipe (possible with the api), causes that recipe to be unviewable. The program attempts to calculate the weight of the component at recipes/models.py/Component:334

if self.of_ingredient:
         weight = self.weight or self.of_ingredient.serving * self.servings

But 0 is considered false, so it goes to calculate self.of_ingredient.serving * self.servings, which is (NoneType or DecimalType) * NoneType, and NoneType does not have a multiplication operator defined.

Future front end developments

I recently became interested in building a nutrition tracing app of my own some time ago, but when I saw your project and how it had already overcome some major design hurdles I figured it might be best to lend my support to an existing project. I have experience with both django and web application development (in php, pure html/js, and vue). I was wondering what your plans for a front end are? I notice on the README it states:

Also, the django template frontend is quite basic. It is not really intended for end-user use, only for personal or debugging purposes. It does not have any forms so all data entry including diary is done via the admin interface. Ideally "customer" users should access the service through an app or a single page frontend. Future frontend work will mostly therefore be via other projects using an API (I do plan to add an Android app for my personal use).

I've looked through the code and don't see any API implemented as of yet, and it sounds as though you may not be interested in having an integrated front end developed. How can I contribute to this area? I would love to explore an improved front end but it would need to be integrated if there is no API.

Alternatively I could put together an API design document for your review? I've just completed a 4 month long course on web design and RESTful API's was one of the components. If you approve such a design document I could go ahead and write tests for such an API, and then an implementation as a separate Django app.

KeyError: 'PANTS_DJANGO_SECRET_KEY' with new install

Hi Dylan, really want to try your app out, but having an issue. I've tried several time to install on my Rpi3, but I keep getting this error when I run ./manage.py createsuperuser. I've also tried a couple of other ways of installing besides your instructions with the same result. Any hints/suggestions??

Traceback (most recent call last):
File "./manage.py", line 22, in
execute_from_command_line(sys.argv)
File "/home/pi/env/local/lib/python2.7/site-packages/django/core/management/init.py", line 364, in execute_from_command_line
utility.execute()
File "/home/pi/env/local/lib/python2.7/site-packages/django/core/management/init.py", line 308, in execute
settings.INSTALLED_APPS
File "/home/pi/env/local/lib/python2.7/site-packages/django/conf/init.py", line 56, in getattr
self._setup(name)
File "/home/pi/env/local/lib/python2.7/site-packages/django/conf/init.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/pi/env/local/lib/python2.7/site-packages/django/conf/init.py", line 110, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/pi/PriceAndNutritionTrackingSystem/pants/pants/settings.py", line 24, in
SECRET_KEY = os.environ["PANTS_DJANGO_SECRET_KEY"]
File "/home/pi/env/lib/python2.7/UserDict.py", line 40, in getitem
raise KeyError(key)
KeyError: 'PANTS_DJANGO_SECRET_KEY'

What nutrition data is available should be provided by the API, and standardized server side.

Some work exists to let recipes and ingredients have similar nutrition data stored, so that they can be referred to interchangeably. While it's possibly a separate issue to merge recipes and ingredients into just a single 'food' class, even if they are or aren't, it would help the flexibility of the system if the API could describe what nutritional value types are available. For example saturated fat is 'part of' fat content typically for a given food, as would unsaturated fat if it were added. For vegans/vegetarians/body builders tracking protein by itself is insufficient, as you would want to track the various amino acids if they were available to ensure you were getting complete proteins. If these were added to the backend, the front end would need work for every new nutritional value type that got added.

If instead the API could describe the nutritional value types, then the front end could dynamically create inputs based on the nutritional description.

Additionally, the server needs unit standardization. It may be more user friendly to display sodium in milligrams instead of grams, but its harder to maintain if the server stores that in milligrams instead of grams like all other nutrients. If the front end is up to par, then the server can simply store and work in simple units such as grams, UTC time, etc. The front end can convert grams, UTC, etc to a more user friendly unit/timezone when displaying and converting back to the basic server unit for a value before calling the api to store/update. This would allow more code reuse in the backend, and more freedom in the front end. For example I could integrate with a service that converts grams for certain known ingredients to cups/ml/volume measurements, and display a recipe in weight or volume as the user desires.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.