<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear Simone,<div class=""><br class=""></div><div class="">thanks for your fast reply!</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div dir="ltr" class="">correct name, see <a href="https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296" class="">https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296</a>.</div></blockquote><div class=""><br class=""></div>I think this template is for the top search, right? I´m working on the left side menu which should be here:</div><div class=""><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/static/geonode/js/search/search.js#L366" class="">https://github.com/GeoNode/geonode/blob/2.4.x/geonode/static/geonode/js/search/search.js#L366</a></div><div class=""><br class=""></div><div class="">Why I´m puzzled is, why do I already get a 404 when changing register as the DAL documentation suggests:</div><div class=""><br class=""></div><div class="">FROM:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class="">autocomplete_light.register(<wbr class="">ResourceBase,</div><div class=""><span class="m_7830546296618264870Apple-tab-span" style="white-space: pre-wrap;">      </span>search_fields=<b class="">[‘title‘,’<wbr class="">abstract’,’purpose'],</b></div><div class=""><span class="m_7830546296618264870Apple-tab-span" style="white-space: pre-wrap;">   </span>autocomplete_js_attributes={'<wbr class="">placeholder': 'Resource name..', },)</div></div></div></blockquote></div></div></blockquote><br class=""></div><div class="">TO:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div class="" style="word-wrap: break-word;"><div class=""><div class="">class CustomResource(autocomplete_<wbr class="">light.AutocompleteModelBase):</div><div class="">    search_fields = ['title', ‚abstract‘,’purpose']</div><div class="">    model = ResourceBase</div><div class=""><br class=""></div><div class="">autocomplete_light.register(<wbr class="">CustomResource)</div></div></div></blockquote></div></div></blockquote><br class=""></div><div class=""><br class=""></div><div class="">And if this works how would I get access to <b class="">user request q </b>and the <b class="">choices coming from my model</b> to overwrite the</div><div class="">http response. Sorry for asking again but even if DAL says it´s build for easy use it has so many options that it´s</div><div class="">hard for me to find a start.</div><div class=""><br class=""></div><div class="">thanks!</div><div class=""><br class=""></div><div class="">toni</div><div class=""><br class=""></div><div class=""><div class="">
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Am 22.02.2017 um 13:46 schrieb Simone Dalmasso <<a href="mailto:simone.dalmasso@gmail.com" class="">simone.dalmasso@gmail.com</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi, definitely the second way is the one to go with. You can see what there's already in geonode and make your own <a href="https://github.com/GeoNode/geonode/blob/master/geonode/base/autocomplete_light_registry.py" class="">https://github.com/GeoNode/geonode/blob/master/geonode/base/autocomplete_light_registry.py</a> and call it from the template using the correct name, see <a href="https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296" class="">https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296</a>.<div class=""><br class=""></div><div class=""> hope this helps</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2017-02-22 13:26 GMT+01:00 Toni Schönbuchner <span dir="ltr" class=""><<a href="mailto:toni.schoenbuchner@csgis.de" target="_blank" class="">toni.schoenbuchner@csgis.de</a>></span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi together,<div class=""><br class=""></div><div class="">this might be an easy one. In geonode 2.4 I have extended autocomplete registry to search in more fields</div><div class="">on layers left side title-search-input.</div><div class=""><br class=""></div><div class=""><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/base/autocomplete_light_registry.py" target="_blank" class="">https://github.com/GeoNode/<wbr class="">geonode/blob/2.4.x/geonode/<wbr class="">base/autocomplete_light_<wbr class="">registry.py</a></div><div class=""><br class=""></div><div class=""><div class="">autocomplete_light.register(<wbr class="">ResourceBase,</div><div class=""><span class="m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap">      </span>search_fields=<b class="">[‘title‘,’<wbr class="">abstract’,’purpose'],</b></div><div class=""><span class="m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap">     </span>autocomplete_js_attributes={'<wbr class="">placeholder': 'Resource name..', },)</div></div><div class=""><br class=""></div><div class="">then changed the base model to return abstract and purpose content as well:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/base/models.py#L342" target="_blank" class="">https://github.com/GeoNode/<wbr class="">geonode/blob/2.4.x/geonode/<wbr class="">base/models.py#L342</a></div><div class=""><div class="">    def __unicode__(self):</div><div class="">        return self.title + ’,’ + self.abstract + ’,’ + self.purpose</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The result is a user can search f.e. for ‚dog‘ and autocomplete shows choices like:</div><div class=""><b class="">Dog Title, Dogs Heaven, the purpose is sleep</b></div><div class=""><b class="">Dogs world, Dogs Hell, the purpose is eat</b></div><div class=""><b class=""><br class=""></b></div><div class="">All that is missing is that I do not want to show a field when the search term is not</div><div class="">found in it. F.e. if purpose does not has ‚dog‘ autoselect should not show it.</div><div class=""><div class=""><b class="">Dog Title, Dogs Heaven</b></div></div><div class=""><b class="">…</b></div><div class=""><b class=""><br class=""></b></div><div class="">From the documentation of DAL I assumed that the way to go is to create/register a subclass like:</div><div class=""><br class=""></div><div class=""><div class="">class CustomResource(autocomplete_<wbr class="">light.AutocompleteModelBase):</div><div class="">    search_fields = ['title', ‚abstract‘,’purpose']</div><div class="">    model = ResourceBase</div><div class=""><br class=""></div><div class="">autocomplete_light.register(<wbr class="">CustomResource)</div></div><div class=""><br class=""></div><div class="">and override the httpResponse method. Unfortunately this basic step already ends in a 404.</div><div class="">Maybe one could bring me on the right track how to achieve filtering the return.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Toni</div></div><br class="">______________________________<wbr class="">_________________<br class="">
geonode-users mailing list<br class="">
<a href="mailto:geonode-users@lists.osgeo.org" class="">geonode-users@lists.osgeo.org</a><br class="">
<a href="https://lists.osgeo.org/mailman/listinfo/geonode-users" rel="noreferrer" target="_blank" class="">https://lists.osgeo.org/<wbr class="">mailman/listinfo/geonode-users</a><br class="">
<br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature" data-smartmail="gmail_signature">Simone </div>
</div>
</div></blockquote></div><br class=""></div></div></body></html>