Bug #49871
ValueError: the name "element'" is already used
Statut:
Nouveau
Priorité:
Normal
Assigné à:
-
Version cible:
-
Début:
05 janvier 2021
Echéance:
% réalisé:
0%
Temps estimé:
Patch proposed:
Non
Planning:
Non
Description
https://sentry.entrouvert.org/entrouvert/nfrance/issues/26966/
ValueError: the name "element'" is already used ... File "wcs/forms/common.py", line 536, in status form = self.get_workflow_form(user) File "wcs/backoffice/management.py", line 2677, in get_workflow_form form = super(FormBackOfficeStatusPage, self).get_workflow_form(user) File "wcs/forms/common.py", line 323, in get_workflow_form form = self.filled.get_workflow_form(user, displayed_fields=submitted_fields) File "wcs/formdata.py", line 573, in get_workflow_form return wf_status.get_action_form(self, user, displayed_fields=displayed_fields) File "wcs/workflows.py", line 1524, in get_action_form item.fill_form(form, filled, user, displayed_fields=displayed_fields) File "wcs/wf/form.py", line 172, in fill_form self.formdef.add_fields_to_form(form, displayed_fields=displayed_fields) File "wcs/formdef.py", line 602, in add_fields_to_form widget = field.add_to_form(form, value) File "wcs/fields.py", line 538, in add_to_form form.add(self.widget_class, 'f%s' % self.id, title=self.label, hint=hint, **kwargs) File "wcs/qommon/form.py", line 342, in add QuixoteForm.add(self, widget_class, name, *args, **kwargs) File "quixote/form/form.py", line 235, in add widget = widget_class(name, *args, **kwargs) File "wcs/qommon/form.py", line 1380, in __init__ self.add(CheckboxWidget, name, title=title, value=checked, **element_kwargs) File "quixote/form/widget.py", line 770, in add raise ValueError('the name %r is already used' % name)
Le kwargs lors de widget = widget_class(name, *args, **kwargs)
:
{form: <wcs.qommon.form.Form object at 0x7f1d885a45c0>, hint: None, id: 'f1', inline: False, max_choices: 3, options: [['[', '[', '['], ['{', '{', '{'], ["'", "'", "'"], ['i', 'i', 'i'], ['d', 'd', 'd'], ["'", "'", "'"], [':', ':', ':'], [' ', ' ', ' '], ['0', '0', '0'], [',', ',', ','], [' ', ' ', ' '], ["'", "'", "'"], ['t', 't', 't'], ['e', 'e', 'e'], ['x', 'x', 'x'], ['t', 't', 't'], ["'", "'", "'"]], options_with_attributes: [['[', '[', '[', {"id":"'['","text":"'['"}]]}
Un problème à la base sur les options, liste crée sur base de la chaine "[{'id': 0, 'text': [".
(et ça fait une case à cocher par caractère et ça passe dans
else: _, title, key = option[:3] name = 'element%s' % str(key)
et c'est ainsi qu'arrive la trace avec deux fois "element'" ajouté, lorsque le deuxième caractère apostrophe est rencontré.