Code Duplication    Length = 14-15 lines in 2 locations

src/senaite/core/z3cform/widgets/uidreference/widget.py 1 location

@@ 152-166 (lines=15) @@
149
                    value = attr
150
        return value
151
152
    def get_value(self):
153
        """Extract the value from the request or get it from the field
154
        """
155
        # get the processed value from the `update` method
156
        value = self.value
157
        # the value might come from the request, e.g. on object creation
158
        if isinstance(value, six.string_types):
159
            value = IDataConverter(self).toFieldValue(value)
160
        # we handle always lists in the templates
161
        if value is None:
162
            return []
163
        if not isinstance(value, (list, tuple)):
164
            value = [value]
165
        # just to be sure (paranoid)
166
        return [uid for uid in value if api.is_uid(uid)]
167
168
    def get_api_url(self):
169
        portal = api.get_portal()

src/senaite/core/z3cform/widgets/queryselect/widget.py 1 location

@@ 156-169 (lines=14) @@
153
        # return the widget attribute
154
        return getattr(self, name, default)
155
156
    def get_value(self):
157
        """Extract the value from the request or get it from the field
158
        """
159
        # get the processed value from the `update` method
160
        value = self.value
161
        # the value might come from the request, e.g. on object creation
162
        if isinstance(value, six.string_types):
163
            value = IDataConverter(self).toFieldValue(value)
164
        # we handle always lists in the templates
165
        if value is None:
166
            return []
167
        if not isinstance(value, (list, tuple)):
168
            value = [value]
169
        return value
170
171
    def get_input_widget_attributes(self):
172
        """Return input widget attributes for the ReactJS component