1919# Some rights reserved, see README and LICENSE.
2020
2121from AccessControl import ClassSecurityInfo
22+ from bika .lims import api
2223from Products .Archetypes .Registry import registerWidget
2324from Products .Archetypes .Widget import TypesWidget
2425
25- try :
26- from zope .component .hooks import getSite
27- except Exception :
28- # Plone < 4.3
29- from zope .app .component .hooks import getSite
30-
3126
3227class RejectionWidget (TypesWidget ):
3328 _properties = TypesWidget ._properties .copy ()
@@ -53,22 +48,8 @@ def isVisible(self, instance, mode='view', default=None, field=None):
5348
5449 def rejectionOptionsList (self ):
5550 "Return a sorted list with the options defined in bikasetup"
56- plone = getSite ()
57- settings = plone .bika_setup
58- # RejectionReasons will return something like:
59- # [{'checkbox': u'on', 'textfield-2': u'b', 'textfield-1': u'c', 'textfield-0': u'a'}]
60- if len (settings .RejectionReasons ) > 0 :
61- reject_reasons = settings .RejectionReasons [0 ]
62- else :
63- return []
64- sorted_keys = sorted (reject_reasons .keys ())
65- if 'checkbox' in sorted_keys :
66- sorted_keys .remove ('checkbox' )
67- # Building the list with the values only because the keys are not needed any more
68- items = []
69- for key in sorted_keys :
70- items .append (reject_reasons [key ].strip ())
71- return items
51+ setup = api .get_senaite_setup ()
52+ return setup .getRejectionReasons ()
7253
7354 def isRejectionEnabled (self , dd ):
7455 """
0 commit comments