misc: find webservice calls used in computed fields when scanning (#76466)
gitea/wcs/pipeline/head This commit looks good Details

This commit is contained in:
Frédéric Péters 2023-04-10 11:27:06 +02:00
parent ea2b64b602
commit 45bdf88ed0
2 changed files with 14 additions and 1 deletions

View File

@ -19,7 +19,7 @@ from wcs.categories import (
)
from wcs.comment_templates import CommentTemplate
from wcs.data_sources import NamedDataSource
from wcs.fields import BlockField, CommentField, PageField, StringField
from wcs.fields import BlockField, CommentField, ComputedField, PageField, StringField
from wcs.formdef import FormDef
from wcs.mail_templates import MailTemplate
from wcs.wf.form import WorkflowFormFieldsFormDef
@ -138,6 +138,8 @@ def test_export_import_dependencies(pub):
wscall.store()
wscall = NamedWsCall(name='Test sexies')
wscall.store()
wscall = NamedWsCall(name='Test in computed field')
wscall.store()
carddef = CardDef()
carddef.name = 'Test'
@ -291,6 +293,12 @@ def test_export_import_dependencies(pub):
label='X {{ webservice.test }} X {{ cards|objects:"test" }} X {{ forms|objects:"test-ter" }} X',
type='comment',
),
ComputedField(
id='3',
label='computed field',
varname='computed_field',
value_template='{{ webservice.test_in_computed_field.xxx }}',
),
]
formdef.workflow = workflow
formdef.store()
@ -304,6 +312,7 @@ def test_export_import_dependencies(pub):
('test', 'wscalls'),
('test_quater', 'wscalls'),
('test_quinquies', 'wscalls'),
('test_in_computed_field', 'wscalls'),
('test', 'cards'),
('test-bis', 'cards'),
('test-bis', 'forms'),

View File

@ -4134,6 +4134,10 @@ class ComputedField(Field):
def get_real_data_source(self):
return data_sources.get_real(self.data_source)
def get_dependencies(self):
yield from super().get_dependencies()
yield from check_wscalls(self.value_template)
register_field_class(ComputedField)