<div dir="ltr">yeah, you have to keep the <span style="font-size:12.8px">ResourceBaseAutocomplete otherwise geonode will break.</span><div>You have to add your own and it should already do what you need without need to hack into the request.</div><div><br></div><div>Hope this helps</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-22 15:01 GMT+01:00 Toni Schönbuchner <span dir="ltr"><<a href="mailto:toni.schoenbuchner@csgis.de" target="_blank">toni.schoenbuchner@csgis.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Sorry Simone,</div><div><br></div><div>I cannot see the forest because of trees.</div><span class=""><div><br></div><div><blockquote type="cite"><div dir="ltr">The 404 is because you the original one must stay, you should add your own.</div></blockquote></div><div><br></div></span>Do you mean a new resourceBase model? or a new autocomplete register Instance? <div>This is where I´m getting confused as the text_search_input from layers page is filtering against</div><div>resourceBase model. AUTOCOMPLETE_URL_RESOURCEBASE = '/autocomplete/<wbr>ResourceBaseAutocomplete/</div><div>which is what I need but simple with more fields than title (abstract + puropose).</div><span class=""><div><blockquote type="cite"><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 style="word-wrap:break-word"><div><div><blockquote type="cite"><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 style="word-wrap:break-word"><div><div><span class="m_-2825301667143541428m_-5158760982108197958m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap"> </span>search_fields=<b>[‘title‘,’abstra<wbr>ct’,’purpose'],</b></div></div></div></blockquote></div></div></blockquote></div></div></div></blockquote></div></div></blockquote></div><div><br></div></span><span class=""><div><blockquote type="cite"><div dir="ltr"><div>I don't understand why you have to modify the request, in autocomplete all is done in a 'magical' way and if you register your own and add the correct name in the relevant template then it'll just work.</div></div></blockquote><br></div></span><div>I think that´s the key point I´m asking for. How can I tell autocomplete to <b>search</b> against title, abstract and purpose</div><div><div><div>but only <b>return</b> fields where the user input is found? It´s this magic that is unclear to me.</div><div><br></div><div>To not steal your time, maybe you know of a fork where something like this has been done before?</div><div>A code snipptes would help to shorten this and get it running.</div><div><br></div><div>all the best,</div><div><br></div><div>toni</div></div><div><div class="h5"><div><br></div><div><font face="monospace" size="3"><span style="white-space:pre-wrap"><br></span></font></div><div><font face="monospace" size="3"><span style="white-space:pre-wrap"><br></span></font></div><div><blockquote type="cite"><div>Am 22.02.2017 um 14:07 schrieb Simone Dalmasso <<a href="mailto:simone.dalmasso@gmail.com" target="_blank">simone.dalmasso@gmail.com</a>>:</div><br class="m_-2825301667143541428Apple-interchange-newline"><div><div dir="ltr">The 404 is because you the original one must stay, you should add your own.<div><br></div><div>I don't understand why you have to modify the request, in autocomplete all is done in a 'magical' way and if you register your own and add the correct name in the relevant template then it'll just work.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-22 13:56 GMT+01:00 Toni Schönbuchner <span dir="ltr"><<a href="mailto:toni.schoenbuchner@csgis.de" target="_blank">toni.schoenbuchner@csgis.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Dear Simone,<div><br></div><div>thanks for your fast reply!</div><div><br><div><blockquote type="cite"><div dir="ltr">correct name, see <a href="https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296" target="_blank">https://github.com/GeoNode<wbr>/geonode/blob/master/geonode/<wbr>templates/base.html#L296</a>.</div></blockquote><div><br></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><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/static/geonode/js/search/search.js#L366" target="_blank">https://github.com/GeoNode/geo<wbr>node/blob/2.4.x/geonode/static<wbr>/geonode/js/search/search.js#<wbr>L366</a></div><div><br></div><div>Why I´m puzzled is, why do I already get a 404 when changing register as the DAL documentation suggests:</div><div><br></div><div>FROM:</div><div><br></div><div><blockquote type="cite"><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 style="word-wrap:break-word"><div><div>autocomplete_light.register(Re<wbr>sourceBase,</div><div><span class="m_-2825301667143541428m_-5158760982108197958m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap"> </span>search_fields=<b>[‘title‘,’abstra<wbr>ct’,’purpose'],</b></div><div><span class="m_-2825301667143541428m_-5158760982108197958m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap"> </span>autocomplete_js_attributes={'p<wbr>laceholder': 'Resource name..', },)</div></div></div></blockquote></div></div></blockquote><br></div><div>TO:</div><div><br></div><div><blockquote type="cite"><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 style="word-wrap:break-word"><div><div>class CustomResource(autocomplete_li<wbr>ght.AutocompleteModelBase):</div><div> search_fields = ['title', ‚abstract‘,’purpose']</div><div> model = ResourceBase</div><div><br></div><div>autocomplete_light.register(Cu<wbr>stomResource)</div></div></div></blockquote></div></div></blockquote><br></div><div><br></div><div>And if this works how would I get access to <b>user request q </b>and the <b>choices coming from my model</b> to overwrite the</div><div>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>hard for me to find a start.</div><div><br></div><div>thanks!</div><div><br></div><div>toni</div><div><br></div><div><div>
</div>
<br><div><blockquote type="cite"><div>Am 22.02.2017 um 13:46 schrieb Simone Dalmasso <<a href="mailto:simone.dalmasso@gmail.com" target="_blank">simone.dalmasso@gmail.com</a>>:</div><br class="m_-2825301667143541428m_-5158760982108197958Apple-interchange-newline"><div><div dir="ltr">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" target="_blank">https://github.com/GeoNode<wbr>/geonode/blob/master/geonode/<wbr>base/autocomplete_light_<wbr>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" target="_blank">https://github.com/GeoNode/geo<wbr>node/blob/master/geonode/templ<wbr>ates/base.html#L296</a>.<div><br></div><div> hope this helps</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-22 13:26 GMT+01:00 Toni Schönbuchner <span dir="ltr"><<a href="mailto:toni.schoenbuchner@csgis.de" target="_blank">toni.schoenbuchner@csgis.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi together,<div><br></div><div>this might be an easy one. In geonode 2.4 I have extended autocomplete registry to search in more fields</div><div>on layers left side title-search-input.</div><div><br></div><div><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/base/autocomplete_light_registry.py" target="_blank">https://github.com/GeoNode/geo<wbr>node/blob/2.4.x/geonode/base/a<wbr>utocomplete_light_registry.py</a></div><div><br></div><div><div>autocomplete_light.register(Re<wbr>sourceBase,</div><div><span class="m_-2825301667143541428m_-5158760982108197958m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap"> </span>search_fields=<b>[‘title‘,’abstra<wbr>ct’,’purpose'],</b></div><div><span class="m_-2825301667143541428m_-5158760982108197958m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap"> </span>autocomplete_js_attributes={'p<wbr>laceholder': 'Resource name..', },)</div></div><div><br></div><div>then changed the base model to return abstract and purpose content as well:</div><div><br></div><div><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/base/models.py#L342" target="_blank">https://github.com/GeoNode/geo<wbr>node/blob/2.4.x/geonode/base/m<wbr>odels.py#L342</a></div><div><div> def __unicode__(self):</div><div> return self.title + ’,’ + self.abstract + ’,’ + self.purpose</div></div><div><br></div><div><br></div><div>The result is a user can search f.e. for ‚dog‘ and autocomplete shows choices like:</div><div><b>Dog Title, Dogs Heaven, the purpose is sleep</b></div><div><b>Dogs world, Dogs Hell, the purpose is eat</b></div><div><b><br></b></div><div>All that is missing is that I do not want to show a field when the search term is not</div><div>found in it. F.e. if purpose does not has ‚dog‘ autoselect should not show it.</div><div><div><b>Dog Title, Dogs Heaven</b></div></div><div><b>…</b></div><div><b><br></b></div><div>From the documentation of DAL I assumed that the way to go is to create/register a subclass like:</div><div><br></div><div><div>class CustomResource(autocomplete_li<wbr>ght.AutocompleteModelBase):</div><div> search_fields = ['title', ‚abstract‘,’purpose']</div><div> model = ResourceBase</div><div><br></div><div>autocomplete_light.register(Cu<wbr>stomResource)</div></div><div><br></div><div>and override the httpResponse method. Unfortunately this basic step already ends in a 404.</div><div>Maybe one could bring me on the right track how to achieve filtering the return.</div><div><br></div><div>Thanks,</div><div><br></div><div>Toni</div></div><br>______________________________<wbr>_________________<br>
geonode-users mailing list<br>
<a href="mailto:geonode-users@lists.osgeo.org" target="_blank">geonode-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/geonode-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/geonode-users</a><br>
<br></blockquote></div><br><br clear="all"><span class="m_-2825301667143541428HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_-2825301667143541428m_-5158760982108197958gmail_signature" data-smartmail="gmail_signature">Simone </div>
</font></span></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-2825301667143541428gmail_signature" data-smartmail="gmail_signature">Simone </div>
</div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Simone </div>
</div>