make (old) state query (loops.organize.stateful) work again correctly with new action stuff in loops.expert
This commit is contained in:
parent
6c64ba5158
commit
667174aca5
3 changed files with 23 additions and 6 deletions
|
@ -171,7 +171,7 @@ Querying objects by state
|
||||||
>>> from loops.organize.stateful.browser import StateQuery
|
>>> from loops.organize.stateful.browser import StateQuery
|
||||||
>>> view = StateQuery(stateQuery, TestRequest())
|
>>> view = StateQuery(stateQuery, TestRequest())
|
||||||
|
|
||||||
>>> view.statesDefinitions
|
>>> view.rcStatesDefinitions
|
||||||
{'concept': [], 'resource': [...StatesDefinition..., ...StatesDefinition...]}
|
{'concept': [], 'resource': [...StatesDefinition..., ...StatesDefinition...]}
|
||||||
|
|
||||||
>>> input = {'state.resource.classification_quality': ['verified']}
|
>>> input = {'state.resource.classification_quality': ['verified']}
|
||||||
|
|
|
@ -32,6 +32,7 @@ from loops.browser.common import BaseView
|
||||||
from loops.browser.concept import ConceptView
|
from loops.browser.concept import ConceptView
|
||||||
from loops.expert.query import And, Or, State, Type, getObjects
|
from loops.expert.query import And, Or, State, Type, getObjects
|
||||||
from loops.expert.browser.search import search_template
|
from loops.expert.browser.search import search_template
|
||||||
|
from loops.security.common import checkPermission
|
||||||
from loops.util import _
|
from loops.util import _
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,6 +78,8 @@ class StateQuery(BaseView):
|
||||||
|
|
||||||
template = ViewPageTemplateFile('view_macros.pt')
|
template = ViewPageTemplateFile('view_macros.pt')
|
||||||
|
|
||||||
|
form_action = 'execute_search_action'
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def search_macros(self):
|
def search_macros(self):
|
||||||
return search_template.macros
|
return search_template.macros
|
||||||
|
@ -86,7 +89,7 @@ class StateQuery(BaseView):
|
||||||
return self.template.macros['query']
|
return self.template.macros['query']
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def statesDefinitions(self):
|
def rcStatesDefinitions(self):
|
||||||
result = {}
|
result = {}
|
||||||
result['resource'] = [component.getUtility(IStatesDefinition, name=n)
|
result['resource'] = [component.getUtility(IStatesDefinition, name=n)
|
||||||
for n in self.globalOptions('organize.stateful.resource', ())]
|
for n in self.globalOptions('organize.stateful.resource', ())]
|
||||||
|
@ -94,6 +97,12 @@ class StateQuery(BaseView):
|
||||||
for n in self.globalOptions('organize.stateful.concept', ())]
|
for n in self.globalOptions('organize.stateful.concept', ())]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def statesDefinitions(self):
|
||||||
|
# TODO: extend to handle concept states as well
|
||||||
|
return [component.getUtility(IStatesDefinition, name=n)
|
||||||
|
for n in self.globalOptions('organize.stateful.resource', ())]
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def selectedStates(self):
|
def selectedStates(self):
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -102,6 +111,10 @@ class StateQuery(BaseView):
|
||||||
result[k] = v
|
result[k] = v
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def showActions(self):
|
||||||
|
return checkPermission('loops.ManageSite', self.context)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def results(self):
|
def results(self):
|
||||||
conceptCriteria = {}
|
conceptCriteria = {}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<h1 i18n:translate="">Select Objects by State</h1>
|
<h1 i18n:translate="">Select Objects by State</h1>
|
||||||
<br />
|
<br />
|
||||||
<table class="listing"
|
<table class="listing"
|
||||||
tal:define="defs item/statesDefinitions">
|
tal:define="defs item/rcStatesDefinitions">
|
||||||
<tr>
|
<tr>
|
||||||
<th i18n:translate="">Object Type</th>
|
<th i18n:translate="">Object Type</th>
|
||||||
<th i18n:translate="">Workflow</th>
|
<th i18n:translate="">Workflow</th>
|
||||||
|
@ -46,9 +46,13 @@
|
||||||
</table>
|
</table>
|
||||||
<input type="submit" name="button.search" value="Search" class="submit"
|
<input type="submit" name="button.search" value="Search" class="submit"
|
||||||
i18n:attributes="value" />
|
i18n:attributes="value" />
|
||||||
|
<tal:results condition="request/search_submitted|nothing">
|
||||||
|
<input type="hidden" name="form.action"
|
||||||
|
tal:attributes="value item/form_action" />
|
||||||
|
<h2 i18n:translate="">Search results</h2>
|
||||||
|
<metal:results use-macro="item/search_macros/results" />
|
||||||
|
<metal:actions use-macro="item/search_macros/actions" />
|
||||||
|
</tal:results>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<tal:results condition="request/search_submitted|nothing">
|
|
||||||
<metal:results use-macro="item/search_macros/results" />
|
|
||||||
</tal:results>
|
|
||||||
</metal:query>
|
</metal:query>
|
||||||
|
|
Loading…
Add table
Reference in a new issue