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
 | 
			
		||||
  >>> view = StateQuery(stateQuery, TestRequest())
 | 
			
		||||
 | 
			
		||||
  >>> view.statesDefinitions
 | 
			
		||||
  >>> view.rcStatesDefinitions
 | 
			
		||||
  {'concept': [], 'resource': [...StatesDefinition..., ...StatesDefinition...]}
 | 
			
		||||
 | 
			
		||||
  >>> input = {'state.resource.classification_quality': ['verified']}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,6 +32,7 @@ from loops.browser.common import BaseView
 | 
			
		|||
from loops.browser.concept import ConceptView
 | 
			
		||||
from loops.expert.query import And, Or, State, Type, getObjects
 | 
			
		||||
from loops.expert.browser.search import search_template
 | 
			
		||||
from loops.security.common import checkPermission
 | 
			
		||||
from loops.util import _
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -77,6 +78,8 @@ class StateQuery(BaseView):
 | 
			
		|||
 | 
			
		||||
    template = ViewPageTemplateFile('view_macros.pt')
 | 
			
		||||
 | 
			
		||||
    form_action = 'execute_search_action'
 | 
			
		||||
 | 
			
		||||
    @Lazy
 | 
			
		||||
    def search_macros(self):
 | 
			
		||||
        return search_template.macros
 | 
			
		||||
| 
						 | 
				
			
			@ -86,7 +89,7 @@ class StateQuery(BaseView):
 | 
			
		|||
        return self.template.macros['query']
 | 
			
		||||
 | 
			
		||||
    @Lazy
 | 
			
		||||
    def statesDefinitions(self):
 | 
			
		||||
    def rcStatesDefinitions(self):
 | 
			
		||||
        result = {}
 | 
			
		||||
        result['resource'] = [component.getUtility(IStatesDefinition, name=n)
 | 
			
		||||
                for n in self.globalOptions('organize.stateful.resource', ())]
 | 
			
		||||
| 
						 | 
				
			
			@ -94,6 +97,12 @@ class StateQuery(BaseView):
 | 
			
		|||
                for n in self.globalOptions('organize.stateful.concept', ())]
 | 
			
		||||
        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
 | 
			
		||||
    def selectedStates(self):
 | 
			
		||||
        result = {}
 | 
			
		||||
| 
						 | 
				
			
			@ -102,6 +111,10 @@ class StateQuery(BaseView):
 | 
			
		|||
                result[k] = v
 | 
			
		||||
        return result
 | 
			
		||||
 | 
			
		||||
    @Lazy
 | 
			
		||||
    def showActions(self):
 | 
			
		||||
        return checkPermission('loops.ManageSite', self.context)
 | 
			
		||||
 | 
			
		||||
    @Lazy
 | 
			
		||||
    def results(self):
 | 
			
		||||
        conceptCriteria = {}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@
 | 
			
		|||
      <h1 i18n:translate="">Select Objects by State</h1>
 | 
			
		||||
      <br />
 | 
			
		||||
      <table class="listing"
 | 
			
		||||
             tal:define="defs item/statesDefinitions">
 | 
			
		||||
             tal:define="defs item/rcStatesDefinitions">
 | 
			
		||||
        <tr>
 | 
			
		||||
          <th i18n:translate="">Object Type</th>
 | 
			
		||||
          <th i18n:translate="">Workflow</th>
 | 
			
		||||
| 
						 | 
				
			
			@ -46,9 +46,13 @@
 | 
			
		|||
      </table>
 | 
			
		||||
      <input type="submit" name="button.search" value="Search" class="submit"
 | 
			
		||||
             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>
 | 
			
		||||
  </div>
 | 
			
		||||
  <tal:results condition="request/search_submitted|nothing">
 | 
			
		||||
    <metal:results use-macro="item/search_macros/results" />
 | 
			
		||||
  </tal:results>
 | 
			
		||||
</metal:query>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue