backoffice: expand form_attachments_* in inspect (#16507) #684
Loading…
Reference in New Issue
No description provided.
Delete Branch "wip/16507-form-attachments-in-inspect"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
94120666a5
tob5f8f18ca1
b5f8f18ca1
to3e698fe7e2
WIP: backoffice: expand form_attachments_* in inspect (#16507)to backoffice: expand form_attachments_* in inspect (#16507)@ -651,3 +651,3 @@
assert resp.request.environ['PATH_INFO'].endswith(file1.filename)
file2 = attachments.created_doc[1]
file2 = attachments.created_doc[0]
Il y avait un reverse() qui est retiré, pour avoir les fichiers attachés indexés chronologiquement, il y a juste ce petit bout de test qui demande adaptation.
@ -3886,3 +3886,3 @@
'display_name': v['form_display_name'],
}
elif hasattr(v, 'inspect_keys'):
elif hasattr(v, 'inspect_keys') and not getattr(v, 'include_in_inspect', False):
Introduction de cet attribut "include_in_inspect" sans quoi le form_attachments_xxx n'apparait pas (parce qu'il a une méthode inspect_keys) et que j'ai trouvé que c'était quand même utile d'exposer la variable pour la donnée complexe "fichier".
@ -1219,2 +1221,4 @@
str: _('string'),
PicklableUpload: _('file'),
AttachmentSubstitutionProxy: _('file'),
NamedAttachmentsSubstitutionProxy: _('file'),
Pour afficher le type dans l'inspecteur, sans distinguer.
@ -219,0 +228,4 @@
try:
return super().__getattr__(name)
except AttributeError:
return getattr(self[-1], name)
On passe du
self[0]
qui visait le premier de la liste passée par .reverse() àself[-1]
maintenant que la liste n'est plus inversée.@ -219,0 +234,4 @@
yield from self[-1].inspect_keys()
if len(self.parts) > 1:
# only advertise indexed keys if there are multiple elements
yield from [str(x) for x in range(len(self.parts))]
Pour afficher uniquement form_attachments_xxx quand il y a un seul fichier attaché pour ce nom de variable, et form_attachments_xxx_0_... form_attachments_xxx_1_... etc. en plus quand il y a plusieurs fichiers attachés.
@ -219,3 +238,3 @@
def __getitem__(self, i):
return AttachmentSubstitutionProxy(self.formdata, self.parts[i])
if isinstance(i, int) or (isinstance(i, str) and misc.is_ascii_digit(i)):
Les clés retournées par inspect_keys doivent être des chaines pour être interprétées correctement par CompatibilityNamesDict, ici donc on gère soit les entiers soit les chaines avec un entier (positif).