Development #80760
alerter l'usager si un statut de workflow contient plusiers l'actions "Formulaire" avec le même identifiant
Start date:
01 September 2023
Due date:
% Done:
0%
Estimated time:
Patch proposed:
No
Planning:
No
Description
Pour éviter les situations où l'usager duplique l'action "Formulaire" sans modifier l'identifiant et qui peuvent donner des erreurs 500 car 2 formulaires s'affichent dans le statut de la demande.
La trace produite par wcs dans ces cas:
août 31 17:07:56 VJGRC uwsgi[3699961]: Exception: août 31 17:07:56 VJGRC uwsgi[3699961]: type = '<class 'ValueError'>', value = 'form already has 'fmodif_1' widget' août 31 17:07:56 VJGRC uwsgi[3699961]: Stack trace (most recent call first): août 31 17:07:56 VJGRC uwsgi[3699961]: File "/usr/lib/python3/dist-packages/quixote/form/form.py", line 230, in add août 31 17:07:56 VJGRC uwsgi[3699961]: 228 def add(self, widget_class, name, *args, **kwargs): août 31 17:07:56 VJGRC uwsgi[3699961]: 229 if name in self._names: août 31 17:07:56 VJGRC uwsgi[3699961]: > 230 raise ValueError("form already has '%s' widget" % name) août 31 17:07:56 VJGRC uwsgi[3699961]: 231 # add 'id' attribute if not already present août 31 17:07:56 VJGRC uwsgi[3699961]: 232 if 'id' not in kwargs: août 31 17:07:56 VJGRC uwsgi[3699961]: locals: août 31 17:07:56 VJGRC uwsgi[3699961]: args = () août 31 17:07:56 VJGRC uwsgi[3699961]: kwargs = {'title': 'Je souhaite annuler mon créneau', 'hint': '', 'required': False, 'render_br': False} août 31 17:07:56 VJGRC uwsgi[3699961]: name = 'fmodif_1' août 31 17:07:56 VJGRC uwsgi[3699961]: self = <wcs.qommon.form.Form object at 0x7fcda5b378e0> août 31 17:07:56 VJGRC uwsgi[3699961]: widget_class = <class 'wcs.qommon.form.CheckboxWidget'> août 31 17:07:56 VJGRC uwsgi[3699961]: File "/usr/lib/python3/dist-packages/wcs/qommon/form.py", line 375, in add août 31 17:07:56 VJGRC uwsgi[3699961]: 373 if self.use_tabs: août 31 17:07:56 VJGRC uwsgi[3699961]: 374 tab = kwargs.pop('tab', None) août 31 17:07:56 VJGRC uwsgi[3699961]: > 375 QuixoteForm.add(self, widget_class, name, *args, **kwargs) août 31 17:07:56 VJGRC uwsgi[3699961]: 376 widget = self._names[name] août 31 17:07:56 VJGRC uwsgi[3699961]: 377 if 'id' not in kwargs and 'id' in widget.attrs: août 31 17:07:56 VJGRC uwsgi[3699961]: locals: août 31 17:07:56 VJGRC uwsgi[3699961]: advanced = False août 31 17:07:56 VJGRC uwsgi[3699961]: args = () août 31 17:07:56 VJGRC uwsgi[3699961]: default_value = Ellipsis août 31 17:07:56 VJGRC uwsgi[3699961]: kwargs = {'title': 'Je souhaite annuler mon créneau', 'hint': '', 'required': False, 'render_br': False} août 31 17:07:56 VJGRC uwsgi[3699961]: name = 'fmodif_1' août 31 17:07:56 VJGRC uwsgi[3699961]: self = <wcs.qommon.form.Form object at 0x7fcda5b378e0> août 31 17:07:56 VJGRC uwsgi[3699961]: widget_class = <class 'wcs.qommon.form.CheckboxWidget'> août 31 17:07:56 VJGRC uwsgi[3699961]: File "/usr/lib/python3/dist-packages/wcs/fields.py", line 899, in add_to_form août 31 17:07:56 VJGRC uwsgi[3699961]: 897 else: août 31 17:07:56 VJGRC uwsgi[3699961]: 898 hint = get_publisher().translate(self.hint or '') août 31 17:07:56 VJGRC uwsgi[3699961]: > 899 form.add(self.widget_class, 'f%s' % self.id, title=self.label, hint=hint, **kwargs) août 31 17:07:56 VJGRC uwsgi[3699961]: 900 widget = form.get_widget('f%s' % self.id) août 31 17:07:56 VJGRC uwsgi[3699961]: 901 widget.field = self août 31 17:07:56 VJGRC uwsgi[3699961]: locals: août 31 17:07:56 VJGRC uwsgi[3699961]: form = <wcs.qommon.form.Form object at 0x7fcda5b378e0> août 31 17:07:56 VJGRC uwsgi[3699961]: hint = '' août 31 17:07:56 VJGRC uwsgi[3699961]: kwargs = {'required': False, 'render_br': False} août 31 17:07:56 VJGRC uwsgi[3699961]: self = <BoolField modif_1 'Je souhaite annuler mon créneau'> août 31 17:07:56 VJGRC uwsgi[3699961]: value = None août 31 17:07:56 VJGRC uwsgi[3699961]: File "/usr/lib/python3/dist-packages/wcs/formdef.py", line 832, in add_fields_to_form août 31 17:07:56 VJGRC uwsgi[3699961]: 830 if not field.add_to_form: août 31 17:07:56 VJGRC uwsgi[3699961]: 831 continue août 31 17:07:56 VJGRC uwsgi[3699961]: > 832 widget = field.add_to_form(form, value) août 31 17:07:56 VJGRC uwsgi[3699961]: 833 widget.is_hidden = not (visible) août 31 17:07:56 VJGRC uwsgi[3699961]: 834 widget.field = field août 31 17:07:56 VJGRC uwsgi[3699961]: locals: août 31 17:07:56 VJGRC uwsgi[3699961]: displayed_fields = [<BoolField modif_6 'Je souhaite annuler mon créneau'>, <TextField modif_8 "Justification de l'annulation">, <BoolField modif_7 'Je souhaite changer > août 31 17:07:56 VJGRC uwsgi[3699961]: field = <BoolField modif_1 'Je souhaite annuler mon créneau'> août 31 17:07:56 VJGRC uwsgi[3699961]: form = <wcs.qommon.form.Form object at 0x7fcda5b378e0> août 31 17:07:56 VJGRC uwsgi[3699961]: form_data = None août 31 17:07:56 VJGRC uwsgi[3699961]: hidden_varnames = set() août 31 17:07:56 VJGRC uwsgi[3699961]: on_page = True août 31 17:07:56 VJGRC uwsgi[3699961]: page = None août 31 17:07:56 VJGRC uwsgi[3699961]: self = <WorkflowFormFieldsFormDef 'Action «\xa0formulaire\xa0» dans le workflow «\xa0EAC 2022\xa0»' id:None> août 31 17:07:56 VJGRC uwsgi[3699961]: transient_formdata = None août 31 17:07:56 VJGRC uwsgi[3699961]: value = None août 31 17:07:56 VJGRC uwsgi[3699961]: visible = True août 31 17:07:56 VJGRC uwsgi[3699961]: File "/usr/lib/python3/dist-packages/wcs/wf/form.py", line 295, in fill_form août 31 17:07:56 VJGRC uwsgi[3699961]: 293 ] août 31 17:07:56 VJGRC uwsgi[3699961]: 294 août 31 17:07:56 VJGRC uwsgi[3699961]: > 295 self.formdef.add_fields_to_form(form, displayed_fields=displayed_fields) août 31 17:07:56 VJGRC uwsgi[3699961]: 296 if 'submit' not in form._names and not self.hide_submit_button: août 31 17:07:56 VJGRC uwsgi[3699961]: 297 form.add_submit('submit', _('Submit'))
History
Updated by Frédéric Péters 3 months ago
Je serais pour dire que non (pas alerter) et que plutôt ça fonctionne.