Project

General

Profile

Bug #57720

'FileWithPreviewWidget' object has no attribute 'field'

Added by Frédéric Péters (absent jusqu’au 12/12) about 2 months ago. Updated about 2 months ago.

Status:
Solution déployée
Priority:
Normal
Target version:
-
Start date:
10 Oct 2021
Due date:
% Done:

0%

Estimated time:
Patch proposed:
Yes
Planning:
No

Description

Champ fichier en option de workflow,

Exception:
  type = '<class 'AttributeError'>', value = ''FileWithPreviewWidget' object has no attribute 'field''

Stack trace (most recent call first):
  File "/usr/lib/python3/dist-packages/wcs/qommon/form.py", line 779, in set_value
   777                 exception=e,
   778             )
>  779             self.value = None
   780 
   781     def add_media(self):

  locals: 
     self = <FileWithPreviewWidget at 7f6415ffbc18: f1>
     value = '\n      '

  File "/usr/lib/python3/dist-packages/wcs/qommon/form.py", line 753, in __init__
   751             self.add(FileWidget, 'file', render_br=False, attrs=attrs)
   752         if value:
>  753             self.set_value(value)
   754 
   755     def is_image(self):

  locals: 
     attrs = {'data-url': '/tmp-upload?storage=default'}
     kwargs = {'title': 'Catalogue', 'hint': None, 'required': True, 'render_br': False, 'allow_portfolio_picking': False, 'id': 'f1', 'form': <wcs.qommon.form.Form object at 0x7f6415457da0>}
     name = 'f1'
     self = <FileWithPreviewWidget at 7f6415ffbc18: f1>
     value = '\n      '

  File "/usr/lib/python3/dist-packages/quixote/form/form.py", line 235, in add
   233             kwargs['id'] = name
   234         kwargs['form'] = self
>  235         widget = widget_class(name, *args, **kwargs)
   236         self._names[name] = widget
   237         if isinstance(widget, SubmitWidget):

  locals: 
     args = ()
     kwargs = {'title': 'Catalogue', 'hint': None, 'required': True, 'render_br': False, 'value': '\n      ', 'file_type': [], 'max_file_size': None, 'allow_portfolio_picking': False, 'automatic_image_resize': False, 'storage': 'default', 'id': 'f1', 'form': <wcs.qommon.form.Form object at 0x7f6415457da0>}
     name = 'f1'
     self = <wcs.qommon.form.Form object at 0x7f6415457da0>
     widget_class = <class 'wcs.qommon.form.FileWithPreviewWidget'>

  File "/usr/lib/python3/dist-packages/wcs/qommon/form.py", line 285, in add
   283             advanced = True
   284             del kwargs['advanced']
>  285         QuixoteForm.add(self, widget_class, name, *args, **kwargs)
   286         widget = self._names[name]
   287         if 'id' not in kwargs and 'id' in widget.attrs:

  locals: 
     advanced = False
     args = ()
     kwargs = {'title': 'Catalogue', 'hint': None, 'required': True, 'render_br': False, 'value': '\n      ', 'file_type': [], 'max_file_size': None, 'allow_portfolio_picking': False, 'automatic_image_resize': False, 'storage': 'default'}
     name = 'f1'
     self = <wcs.qommon.form.Form object at 0x7f6415457da0>
     widget_class = <class 'wcs.qommon.form.FileWithPreviewWidget'>

  File "/usr/lib/python3/dist-packages/wcs/fields.py", line 655, in add_to_form
   653         else:
   654             hint = self.hint
>  655         form.add(self.widget_class, 'f%s' % self.id, title=self.label, hint=hint, **kwargs)
   656         widget = form.get_widget('f%s' % self.id)
   657         widget.field = self

  locals: 
     form = <wcs.qommon.form.Form object at 0x7f6415457da0>
     hint = None
     k = 'storage'
     kwargs = {'required': True, 'render_br': False, 'value': '\n      ', 'file_type': [], 'max_file_size': None, 'allow_portfolio_picking': False, 'automatic_image_resize': False, 'storage': 'default'}
     self = <FileField 1 'Catalogue'>
     value = '\n      '

  File "/usr/lib/python3/dist-packages/wcs/formdef.py", line 674, in add_fields_to_form
   672             if not field.add_to_form:
   673                 continue
>  674             widget = field.add_to_form(form, value)
   675             widget.is_hidden = not (visible)
   676             widget.field = field

  locals: 
     displayed_fields = None
     field = <FileField 1 'Catalogue'>
     form = <wcs.qommon.form.Form object at 0x7f6415457da0>
     form_data = {'1': '\n      '}
     on_page = True
     page = None
     self = <WorkflowVariablesFieldsFormDef 'Options du workflow «\xa0Réservation Journée Job Eté Etudiants\xa0»' id:None>
     transient_formdata = None
     value = '\n      '
     visible = True

  File "/usr/lib/python3/dist-packages/wcs/admin/forms.py", line 1636, in workflow_variables
  1634         form = Form(enctype='multipart/form-data')
  1635         self.formdef.workflow.variables_formdef.add_fields_to_form(
> 1636             form, form_data=self.formdef.get_variable_options_for_form()
  1637         )
  1638         form.add_submit('submit', _('Submit'))

  locals: 
     form = <wcs.qommon.form.Form object at 0x7f6415457da0>
     self = <wcs.admin.forms.FormDefPage object at 0x7f64161277b8>

[...]

PATH_INFO       '/backoffice/forms/180/workflow-variables'

Files

Associated revisions

Revision 87b31ed0 (diff)
Added by Frédéric Péters (absent jusqu’au 12/12) about 2 months ago

misc: do not crash on invalid file value in workflow variables (#57720)

History

#1

Updated by Frédéric Péters (absent jusqu’au 12/12) about 2 months ago

  • Assignee set to Frédéric Péters (absent jusqu’au 12/12)
  • Status changed from Nouveau to En cours
#3

Updated by Lauréline Guerin about 2 months ago

  • Status changed from Solution proposée to Solution validée
#4

Updated by Frédéric Péters (absent jusqu’au 12/12) about 2 months ago

  • Status changed from Solution validée to Résolu (à déployer)
commit 87b31ed09d65a2a770f832327d07cdee499900d1
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Sat Oct 16 13:54:21 2021 +0200

    misc: do not crash on invalid file value in workflow variables (#57720)
#5

Updated by Frédéric Péters (absent jusqu’au 12/12) about 2 months ago

  • Status changed from Résolu (à déployer) to Solution déployée

Also available in: Atom PDF