Hide archived terms from widget selection tree
authorThierry Florac <tflorac@ulthar.net>
Mon, 31 Aug 2020 12:47:58 +0200
changeset 121 b801eda057ff
parent 120 fe1184f57db9
child 122 c7a6f6cd50af
Hide archived terms from widget selection tree
src/pyams_thesaurus/zmi/widget/__init__.py
--- a/src/pyams_thesaurus/zmi/widget/__init__.py	Wed Mar 27 11:09:35 2019 +0100
+++ b/src/pyams_thesaurus/zmi/widget/__init__.py	Mon Aug 31 12:47:58 2020 +0200
@@ -19,7 +19,7 @@
 
 # import interfaces
 from pyams_form.interfaces.form import IFormLayer
-from pyams_thesaurus.interfaces.term import IThesaurusTerm
+from pyams_thesaurus.interfaces.term import IThesaurusTerm, STATUS_ARCHIVED
 from pyams_thesaurus.interfaces.thesaurus import IThesaurus
 from pyams_thesaurus.schema import IThesaurusTermField, IThesaurusTermsListField
 from pyams_thesaurus.zmi.widget.interfaces import IThesaurusTermWidget, IThesaurusTermsListWidget
@@ -188,9 +188,9 @@
     def get_subterms(self, term):
         for subterm in term.specifics:
             if (not self.extract_name) or (self.extract_name in subterm.extracts):
-                yield subterm
-                for another in self.get_subterms(subterm):
-                    yield another
+                if subterm.status != STATUS_ARCHIVED:
+                    yield subterm
+                    yield from self.get_subterms(subterm)
 
 
 def ThesaurusTermsTreeFieldWidget(field, request):