[GeoNode-users] Query recent maps in views.py
Arisandi, Donny (ICRAF)
D.Arisandi at cgiar.org
Fri Sep 22 21:59:46 PDT 2017
Hi Paolo, thanks for your advice, finally I figure it out the problem, I changed the model from : from geonode.maps.models import MapLayer to : from geonode.maps.models import Map
Best
D
-----Original Message-----
From: Paolo Corti [mailto:pcorti at gmail.com]
Sent: 22 September 2017 22:26
To: Arisandi, Donny (ICRAF)
Cc: Simone Dalmasso; geonode-users at lists.osgeo.org
Subject: Re: [GeoNode-users] Query recent maps in views.py
I think map.thumbnail_url is the right property to use.
If it does not display in your page there is something wrong with other parts of the code Did you try with the Django shell if the property is correctly set?
regards
p
On Thu, Sep 21, 2017 at 10:30 PM, Arisandi, Donny (ICRAF) <D.Arisandi at cgiar.org> wrote:
> Hi Paolo, that I was looking for. But in template, how to get the the URL and Image for the map? I tried like below script it did not work. Please advise.
>
> <h4 class="subheading">{% trans "Recent Map" %}</h4>
> {% for content in recent_maps %}
> <div class="col-md-3">
> <div class="recent-box">
> <div class="text-center">
> <a href="{{ map.detail_url }}" title="{{ map.name|escape }}">
> <img src="{{ map.thumbnail_url }}" alt="thumbnail" width="250" height="150">
> <div class="recent-abstract">
> {{ content.abstract|escape|urlize|linebreaks|safe|truncatechars:250 }}
> </div>
> <div class="recent-title">{{ content.title|escape|truncatechars:30 }}</div>
> </a>
> </div>
> </div>
> </div>
> {% endfor %}
>
> -----Original Message-----
> From: Paolo Corti [mailto:pcorti at gmail.com]
> Sent: 20 September 2017 20:45
> To: Simone Dalmasso
> Cc: Arisandi, Donny (ICRAF); geonode-users at lists.osgeo.org
> Subject: Re: [GeoNode-users] Query recent maps in views.py
>
> I think Donny would like to see thumbnails of recently update maps.
>
> If this is the case, this can be easily done with:
> Map.objects.all().order_by('-last_modified') in the views.py.
> Then use map.get_thumbnail_url in the template
>
> p
>
> On Wed, Sep 20, 2017 at 9:38 AM, Simone Dalmasso <simone.dalmasso at gmail.com> wrote:
>> Hi,
>>
>> what you need is not trivial. GeoNode doesn't have a model for
>> Thumbnails, they are managed through Links
>> (https://github.com/GeoNode/geonode/blob/2.6.x/geonode/base/models.py
>> # L892), but a Link doesn't have a timestamp for its creation, so you
>> would need something to read the files from the disk.
>>
>> Maybe the way to go could be to create your own model for recent
>> thumbnails and update their status in the db through a cron celery
>> task. So your view would easily read from it.
>>
>> Hope it helps and others ideas are welcome.
>>
>> 2017-09-20 10:35 GMT+02:00 Arisandi, Donny (ICRAF) <D.Arisandi at cgiar.org>:
>>>
>>> Dear all,
>>>
>>>
>>>
>>> I need your help to create query in views.py to show recent map thumbnail.
>>> Could you show me the sample how to do it?
>>>
>>>
>>>
>>> Thank you
>>>
>>> D
>>>
>>>
>>> _______________________________________________
>>> geonode-users mailing list
>>> geonode-users at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/geonode-users
>>>
>>
>>
>>
>> --
>> Simone
>>
>> _______________________________________________
>> geonode-users mailing list
>> geonode-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/geonode-users
>>
>
>
>
> --
> Paolo Corti
> Geospatial software developer
> web: http://www.paolocorti.net
> twitter: @capooti
> skype: capooti
--
Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti
More information about the geonode-users
mailing list