Added themes support on site root to handle advanced search on themes
authorThierry Florac <tflorac@ulthar.net>
Wed, 27 Jan 2021 15:49:44 +0100
changeset 178 7040403e9c95
parent 177 6d6b3d90e1a7
child 179 aac520985071
Added themes support on site root to handle advanced search on themes
src/pyams_content_es/root/zmi/search.py
src/pyams_content_es/root/zmi/templates/advanced-search.pt
--- a/src/pyams_content_es/root/zmi/search.py	Tue Jan 12 13:38:54 2021 +0100
+++ b/src/pyams_content_es/root/zmi/search.py	Wed Jan 27 15:49:44 2021 +0100
@@ -125,6 +125,9 @@
         if data.get('tags'):
             tags = [intids.register(term) for term in data['tags']]
             params &= Q('terms', tags=tags)
+        if data.get('themes'):
+            themes = [intids.register(term) for term in data['themes']]
+            params &= Q('terms', **{'themes.terms': themes})
         if data.get('collections'):
             collections = [intids.register(collection) for collection in data['collections']]
             params &= Q('terms', collections=collections)
--- a/src/pyams_content_es/root/zmi/templates/advanced-search.pt	Tue Jan 12 13:38:54 2021 +0100
+++ b/src/pyams_content_es/root/zmi/templates/advanced-search.pt	Wed Jan 27 15:49:44 2021 +0100
@@ -184,20 +184,16 @@
 									</div>
 								</div>
 							</div>
-							<fieldset tal:condition="'tags' in view.widgets">
-								<legend class="switcher" i18n:translate="">Tags</legend>
-								<div class="input"
-									 tal:define="widget view.widgets['tags']">
-									<input tal:replace="structure widget.render()" />
-								</div>
-							</fieldset>
-							<fieldset tal:condition="'collections' in view.widgets">
-								<legend class="switcher" i18n:translate="">Collections</legend>
-								<div class="input"
-									 tal:define="widget view.widgets['collections']">
-									<input tal:replace="structure widget.render()" />
-								</div>
-							</fieldset>
+							<tal:loop repeat="fieldname ('tags', 'themes', 'collections')">
+								<fieldset tal:condition="fieldname in view.widgets">
+									<tal:var define="widget view.widgets[fieldname]">
+										<legend class="switcher">${widget.label}</legend>
+										<div class="input">
+											<input tal:replace="structure widget.render()" />
+										</div>
+									</tal:var>
+								</fieldset>
+							</tal:loop>
 						</fieldset>
 					</tal:loop>
 					<div class="widgets-suffix"