savoirfairelinux / sous-chef

Sous-Chef is a web application to help organizations to plan and deliver meals, and to manage clients files.
GNU Affero General Public License v3.0
67 stars 45 forks source link

Error when trying to change the name of a meal #843

Open JeanFrancoisFournier opened 5 years ago

JeanFrancoisFournier commented 5 years ago

Expected Behaviour

Through the Admin, We should be able to change name of any ingredients, components (dishes&recipes) and restricted items (restriction categories).

Actual Behaviour

When trying to rename one, we got this error message:

Request Method: POST

http://localhost:8000/admin/meal/component/1619/change/ 1.11.17 TooManyFieldsSent The number of GET/POST parameters exceeded settings.DATA_UPLOAD_MAX_NUMBER_FIELDS. /usr/local/lib/python3.5/site-packages/django/http/multipartparser.py in parse, line 181 /usr/local/bin/python 3.5.6 ['/code/src', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/site-packages'] Thu, 7 Feb 2019 15:15:50 -0500

JeanFrancoisFournier commented 5 years ago

The easy work around to this was to delete the Component and recreate it with the new name. Annoying but efficient.

manumilou commented 5 years ago

Django has an arbitrary limit on fields than can be submitted through a form. It can be increased. I am surprised though, because the limit is pretty high by default I believe. @JeanFrancoisFournier How many ingredients in the meal you try to submit ?

JeanFrancoisFournier commented 5 years ago

I think it has to do with the fact that during the CM process, every time we confirm the ingredients for the recipe of the day, a menu_component listing the ingredients used for that day. It also adds these ingredients in the component (dishes and recipes) with a mention that these ingredients were used on that date. See image below.

image

As the year progresses, we may serve a recipe 12 times or more with 12 to 20 different ingredients. This means that the component (dishes and recipe) becomes longer and longer. I think that's why we reached Django's limit on recipes that are served often and are ingredients heavy.

JeanFrancoisFournier commented 5 years ago

and to answer your questions there is (as of today and until we serve the vegetable lasagna again) 251 ingredients listed in the recipe. Of these, only 7 are used to load the recipe in the UI and all the others were created by the application.

manumilou commented 5 years ago

OK JF, I understand. So there is no point in increasing the limit of fields, except as a temporary bandaid, we'd better fix the underlying problem. In my mind, the problem occurs because we try to use the same concept (`Component) to serve two different purposes:

  1. As generic recipes, to be loaded and modified during the KC
  2. To trace back which ingredients were used for a given day. Maybe, also used to print the list of ingredients later in the KC, can't remember at the moment.

Any suggestions on how to fix that ?

Couple of questions for you: