| @@ 164-180 (lines=17) @@ | ||
| 161 | - _authenticator: The plone.protect authenticator. |
|
| 162 | """ |
|
| 163 | ||
| 164 | def filter_list(self, items, searchterm): |
|
| 165 | if searchterm and len(searchterm) < 3: |
|
| 166 | # Items that start with A or AA |
|
| 167 | res = [s.getObject() for s in items |
|
| 168 | if s.title.lower().startswith(searchterm)] |
|
| 169 | if not res: |
|
| 170 | # or, items that contain A or AA |
|
| 171 | res = [s.getObject() for s in items |
|
| 172 | if s.title.lower().find(searchterm) > -1] |
|
| 173 | else: |
|
| 174 | # or, items that contain searchterm. |
|
| 175 | res = [s.getObject() for s in items |
|
| 176 | if s.title.lower().find(searchterm) > -1] |
|
| 177 | return res |
|
| 178 | ||
| 179 | def __call__(self): |
|
| 180 | plone.protect.CheckAuthenticator(self.request) |
|
| 181 | bsc = getToolByName(self.context, 'bika_setup_catalog') |
|
| 182 | term = safe_unicode(self.request.get('term', '')).lower() |
|
| 183 | items = [] |
|
| @@ 147-163 (lines=17) @@ | ||
| 144 | ||
| 145 | """ |
|
| 146 | ||
| 147 | def filter_list(self, items, searchterm): |
|
| 148 | if searchterm and len(searchterm) < 3: |
|
| 149 | # Items that start with A or AA |
|
| 150 | res = [s.getObject() |
|
| 151 | for s in items |
|
| 152 | if s.title.lower().startswith(searchterm)] |
|
| 153 | if not res: |
|
| 154 | # or, items that contain A or AA |
|
| 155 | res = [s.getObject() |
|
| 156 | for s in items |
|
| 157 | if s.title.lower().find(searchterm) > -1] |
|
| 158 | else: |
|
| 159 | # or, items that contain searchterm. |
|
| 160 | res = [s.getObject() |
|
| 161 | for s in items |
|
| 162 | if s.title.lower().find(searchterm) > -1] |
|
| 163 | return res |
|
| 164 | ||
| 165 | def __call__(self): |
|
| 166 | plone.protect.CheckAuthenticator(self.request) |
|