Mercurial > p > roundup > code
comparison roundup/cgi/actions.py @ 6638:e1588ae185dc issue2550923_computed_property
merge from default branch. Fix travis.ci so CI builds don't error out
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 21 Apr 2022 16:54:17 -0400 |
| parents | e70e2789bc2c |
| children | b336cc98d9d2 |
comparison
equal
deleted
inserted
replaced
| 6508:85db90cc1705 | 6638:e1588ae185dc |
|---|---|
| 462 Implementation note: | 462 Implementation note: |
| 463 We now store the template with the query if the template name is | 463 We now store the template with the query if the template name is |
| 464 different from 'index' | 464 different from 'index' |
| 465 """ | 465 """ |
| 466 template = self.getFromForm('template') | 466 template = self.getFromForm('template') |
| 467 if template and template != 'index': | 467 if template and template not in ['index', 'index|search']: |
| 468 return req.indexargs_url('', {'@template': template})[1:] | 468 return req.indexargs_url('', {'@template': template})[1:] |
| 469 return req.indexargs_url('', {})[1:] | 469 return req.indexargs_url('', {})[1:] |
| 470 | 470 |
| 471 def getFromForm(self, name): | 471 def getFromForm(self, name): |
| 472 for key in ('@' + name, ':' + name): | 472 for key in ('@' + name, ':' + name): |
| 1431 % {'column': html_escape(cname), | 1431 % {'column': html_escape(cname), |
| 1432 'class': request.classname}) | 1432 'class': request.classname}) |
| 1433 | 1433 |
| 1434 # full-text search | 1434 # full-text search |
| 1435 if request.search_text: | 1435 if request.search_text: |
| 1436 matches = self.db.indexer.search( | 1436 indexer = self.db.indexer |
| 1437 re.findall(r'\b\w{2,25}\b', request.search_text), klass) | 1437 if self.db.indexer.query_language: |
| 1438 try: | |
| 1439 matches = indexer.search( | |
| 1440 [request.search_text], klass) | |
| 1441 except Exception as e: | |
| 1442 error = " ".join(e.args) | |
| 1443 self.client.add_error_message(error) | |
| 1444 self.client.response_code = 400 | |
| 1445 # trigger error reporting. NotFound isn't right but... | |
| 1446 raise exceptions.NotFound(error) | |
| 1447 else: | |
| 1448 matches = indexer.search( | |
| 1449 re.findall(r'\b\w{%s,%s}\b' % (indexer.minlength, | |
| 1450 indexer.maxlength), | |
| 1451 request.search_text), klass) | |
| 1438 else: | 1452 else: |
| 1439 matches = None | 1453 matches = None |
| 1440 | 1454 |
| 1441 header = self.client.additional_headers | 1455 header = self.client.additional_headers |
| 1442 header['Content-Type'] = 'text/csv; charset=%s' % self.client.charset | 1456 header['Content-Type'] = 'text/csv; charset=%s' % self.client.charset |
| 1596 % {'column': html_escape(cname), | 1610 % {'column': html_escape(cname), |
| 1597 'class': request.classname}) | 1611 'class': request.classname}) |
| 1598 | 1612 |
| 1599 # full-text search | 1613 # full-text search |
| 1600 if request.search_text: | 1614 if request.search_text: |
| 1601 matches = self.db.indexer.search( | 1615 indexer = self.db.indexer |
| 1602 re.findall(r'\b\w{2,25}\b', request.search_text), klass) | 1616 if indexer.query_language: |
| 1617 try: | |
| 1618 matches = indexer.search( | |
| 1619 [request.search_text], klass) | |
| 1620 except Exception as e: | |
| 1621 error = " ".join(e.args) | |
| 1622 self.client.add_error_message(error) | |
| 1623 self.client.response_code = 400 | |
| 1624 # trigger error reporting. NotFound isn't right but... | |
| 1625 raise exceptions.NotFound(error) | |
| 1626 else: | |
| 1627 matches = indexer.search( | |
| 1628 re.findall(r'\b\w{%s,%s}\b' % (indexer.minlength, | |
| 1629 indexer.maxlength), | |
| 1630 request.search_text), | |
| 1631 klass) | |
| 1603 else: | 1632 else: |
| 1604 matches = None | 1633 matches = None |
| 1605 | 1634 |
| 1606 h = self.client.additional_headers | 1635 h = self.client.additional_headers |
| 1607 h['Content-Type'] = 'text/csv; charset=%s' % self.client.charset | 1636 h['Content-Type'] = 'text/csv; charset=%s' % self.client.charset |
