Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create querystring "search" operator #1

Open
wants to merge 2 commits into
base: pg-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions plone/app/querystring/profiles/default/registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@
<value key="widget">StringWidget</value>
</records>

<records interface="plone.app.querystring.interfaces.IQueryOperation"
prefix="plone.app.querystring.operation.string.search">
<value key="title" i18n:translate="">Search</value>
<value key="description"></value>
<value key="operation">plone.app.querystring.queryparser._search</value>
<value key="widget">StringWidget</value>
</records>

<records interface="plone.app.querystring.interfaces.IQueryOperation"
prefix="plone.app.querystring.operation.string.currentUser">
<value key="title" i18n:translate="">Current logged in user</value>
Expand Down
6 changes: 5 additions & 1 deletion plone/app/querystring/querybuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,13 @@ def number_of_results(self, query):

def filter_query(self, query):
text = query.get("SearchableText", None)
munge = True
if isinstance(text, dict):
if text.get("operator", "") == "search":
munge = False
text = text.get("query", "")
if text:

if text and munge:
query["SearchableText"] = self.munge_search_term(text)
return query

Expand Down
3 changes: 3 additions & 0 deletions plone/app/querystring/queryparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def parseFormquery(context, formquery, sort_on=None, sort_order=None):
def _contains(context, row):
return _equal(context, row)

def _search(context, row):
return {row.index: {'query': row.values, 'operator': 'search' }}


def _excludes(context, row):
return {row.index: {'not': row.values}}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages

version = '2.0.0'
version = '2.0.0.dev0'

long_description = open("README.rst").read() + "\n"
long_description += open("CHANGES.rst").read()
Expand Down