Coverage for gws-app/gws/plugin/model_widget/file_list/__init__.py: 0%

12 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""File list widget. 

2 

3A feature list widget for related features that hold files. ``toFileField`` 

4names the ``file`` field of the related model that holds the file. The 

5button options are the same as for the ``featureList`` widget. 

6 

7Example:: 

8 

9 fields+ { 

10 name "docs" 

11 type "relatedFeatureList" 

12 toModel "model_document" 

13 toColumn "poi_id" 

14 widget { 

15 type "fileList" 

16 toFileField "documentFile" 

17 withNewButton true 

18 withUnlinkButton true 

19 } 

20 } 

21""" 

22 

23import gws 

24import gws.base.model.widget 

25import gws.plugin.model_widget.feature_list as feature_list 

26 

27 

28@gws.ext.config.modelWidget('fileList') 

29class Config(feature_list.Config): 

30 """List of related files.""" 

31 

32 toFileField: str 

33 """File field of the related model that holds the file.""" 

34 

35 

36@gws.ext.props.modelWidget('fileList') 

37class Props(gws.base.model.widget.Props): 

38 withNewButton: bool 

39 withLinkButton: bool 

40 withEditButton: bool 

41 withUnlinkButton: bool 

42 withDeleteButton: bool 

43 toFileField: str 

44 

45 

46@gws.ext.object.modelWidget('fileList') 

47class Object(feature_list.Object): 

48 """File list widget object.""" 

49 

50 def props(self, user): 

51 return gws.u.merge( 

52 super().props(user), 

53 toFileField=self.cfg('toFileField'), 

54 )