freezed / ocp8

Du gras, oui, mais de qualité!
GNU General Public License v3.0
1 stars 0 forks source link

Local & distant DB conflict #36

Open freezed opened 6 years ago

freezed commented 6 years ago

Step to reproduce

  1. A product is stored in DB without nutrition_grades
  2. A new request get this product, now, with a nutrition_grades
  3. Substitute search fails :

    1. search : http://127.0.0.1:8000/ersatz/search/?s=Original
    2. choose Ricoré Original (Nestle) - [E]
    3. Traceback :
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/ersatz/candidates/7613032655495

Django Version: 2.1.1
Python Version: 3.6.7
Installed Applications:
['account.apps.AccountConfig',
 'ersatz.apps.ErsatzConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 '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 "~/git/ocp8/.venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "~/git/ocp8/.venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = self.process_exception_by_middleware(e, request)

File "~/git/ocp8/.venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "~/git/ocp8/ersatz/views/views.py" in candidates
  25.     context = ersatz.get_substitute_context()

File "~/git/ocp8/ersatz/views/toolbox.py" in get_substitute_context
  391.             context = self.get_candidate(self.product_val['nutrition_grades'])

File "~/git/ocp8/ersatz/views/toolbox.py" in get_candidate
  411.         ersatz_candidates = {cat: list() for cat in ng_sequence[png]}

Exception Type: KeyError at /ersatz/candidates/7613032655495
Exception Value: ''