Projet

Général

Profil

Development #53432

Champ fichier non pré-rempli sur une action d'édition lorsque la demande est arrivée via une action de création de demande

Ajouté par Emmanuel Cazenave il y a environ 3 ans. Mis à jour il y a environ 3 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
26 avril 2021
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

Le fichier est bien présent sur la demande, accessible, mais sur l'action d'édition plouf.


Fichiers

Révisions associées

Révision d1b0510f (diff)
Ajouté par Emmanuel Cazenave il y a environ 3 ans

tests: check editing a file field in a formdata created by workflow (#53432)

Révision ae24eeb2 (diff)
Ajouté par Frédéric Péters il y a environ 3 ans

misc: create file token if it doesn't exist at all (#53432)

Historique

#1

Mis à jour par Emmanuel Cazenave il y a environ 3 ans

Je reproduis bien en local ce qui est décrit dans #53283#note-4.

A essayer de débroussailler ça me semble dérailler dans apply_field_prefills :

if has_current_value:
    # existing value, update it with the new computed value
    # if it's the same that was previously computed.
    prefill_value = v
    v = current_value
    if prefilling_current_data.get(field_key) == current_value:
        # replace value with new value computed for prefill
        v = prefill_value
    else:
        should_prefill = False

On rentre là dedans avec should_prefill à True (et v à None), on en ressort avec un should_prefill à False.

Et bien sûr avec ce bout de code je suis peut-être en train de regarder le symptôme mais pas du tout la cause, zéro hauteur de vue.

#3

Mis à jour par Frédéric Péters il y a environ 3 ans

Tu peux écrire un test ?

#4

Mis à jour par Emmanuel Cazenave il y a environ 3 ans

  • Assigné à mis à Emmanuel Cazenave
#5

Mis à jour par Emmanuel Cazenave il y a environ 3 ans

  • Fichier 0001-wip.patch 0001-wip.patch ajouté
  • Assigné à changé de Emmanuel Cazenave à Frédéric Péters
  • Patch proposed changé de Non à Oui

Ça fait juste échouer un peut-être un peu léger assert 'test.txt' in resp.text mais ça met en évidence la différence de comportement entre une demande créée "normalement" par rapport une demande arrivée via une action de création de demande.

#6

Mis à jour par Frédéric Péters il y a environ 3 ans

Merci pour le test; mineur mais ça a commencé par :

        new_formdata = formdef.data_class().select()[0]
>       assert formdata.id != new_formdata.id
E       AssertionError: assert '1' != '1'
E        +  where '1' = <_wcs_Test 'test #1-1' id:1>.id
E        +  and   '1' = <_wcs_Test 'test #1-1' id:1>.id

mais j'ai arrangé et voilà c'est ok; ce qui se passe c'est que le fichier créé par l'action n'a pas d'attribut "token" et ça le mettait hors-jeu lors u set_value().

Des petites modifs, incorporées dans ton patch :

f 063a17c16 don't rely on random ordering as it's random
f 880e676a5 tests: use a template to fill file field
f 112d2b53e tests: check form can be submitted again with file

puis la correction.

#7

Mis à jour par Emmanuel Cazenave il y a environ 3 ans

  • Statut changé de Solution proposée à Solution validée
#8

Mis à jour par Frédéric Péters il y a environ 3 ans

  • Statut changé de Solution validée à Résolu (à déployer)
commit ae24eeb294fa10269374c0b133b2c1ce07a96544
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Mon Apr 26 20:01:00 2021 +0200

    misc: create file token if it doesn't exist at all (#53432)

commit d1b0510f556fe0d87ef7ccbe3cb10fb720a67fd8
Author: Emmanuel Cazenave <ecazenave@entrouvert.com>
Date:   Mon Apr 26 18:35:21 2021 +0200

    tests: check editing a file field in a formdata created by workflow (#53432)
#9

Mis à jour par Frédéric Péters il y a environ 3 ans

  • Statut changé de Résolu (à déployer) à Solution déployée

Formats disponibles : Atom PDF