From e78b46ac6df345954f253cb14c3a655e438e319b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Tue, 21 Oct 2014 21:41:19 -0200 Subject: [PATCH] Add thumbnail image in map infowin --- sigi/apps/metas/views.py | 5 ++++- sigi/settings/base.py | 5 +++++ sigiStatic/js/metas/mapa.js | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sigi/apps/metas/views.py b/sigi/apps/metas/views.py index f6e0cd7..8004f34 100644 --- a/sigi/apps/metas/views.py +++ b/sigi/apps/metas/views.py @@ -22,6 +22,8 @@ from sigi.apps.utils import to_ascii from sigi.apps.financeiro.models import Desembolso from sigi.apps.metas.templatetags.mapa_tags import descricao_servicos from functools import reduce +from easy_thumbnails.templatetags.thumbnail import thumbnail_url +import time JSON_FILE_NAME = os.path.join(MEDIA_ROOT, 'apps/metas/map_data.json') @@ -282,7 +284,6 @@ def gera_map_data_file(cronjob=False): Caso cronjob seja True, retorna log de tempo gasto na geração ou a mensagem do erro que impediu a gravação do arquivo. ''' - import time start = time.time() casas = {} @@ -296,6 +297,8 @@ def gera_map_data_file(cronjob=False): casa = { 'nome': c.nome + ', ' + c.municipio.uf.sigla, 'icone': '/static/img/mapmarker.png', + 'thumb': thumbnail_url(c.foto, 'small'), + 'foto': (c.foto.url if c.foto else ''), 'lat': str(c.municipio.latitude), 'lng': str(c.municipio.longitude), 'estado': c.municipio.uf.sigla, diff --git a/sigi/settings/base.py b/sigi/settings/base.py index f43e1c2..d05abfa 100644 --- a/sigi/settings/base.py +++ b/sigi/settings/base.py @@ -140,5 +140,10 @@ THUMBNAIL_PROCESSORS = ( 'image_cropping.thumbnail_processors.crop_corners', ) + thumbnail_settings.THUMBNAIL_PROCESSORS +THUMBNAIL_ALIASES = { + '': { + 'small': {'size': (300, 225), 'crop': True,}, + }, +} IMAGE_CROPPING_SIZE_WARNING = True IMAGE_CROPPING_THUMB_SIZE = (800, 600) diff --git a/sigiStatic/js/metas/mapa.js b/sigiStatic/js/metas/mapa.js index 78e9e7b..91c81b3 100644 --- a/sigiStatic/js/metas/mapa.js +++ b/sigiStatic/js/metas/mapa.js @@ -43,7 +43,12 @@ icon: '/static/img/mapmarker.png' } var mark = new google.maps.Marker(markData); - var infoWin = new google.maps.InfoWindow({content: '' + municipio.nome + '

' + municipio.info }); + var infoWin = new google.maps.InfoWindow({content: + '' + municipio.nome + '

' + + municipio.info + '

' + + '' + + '' + + '' }); linkMarkMessage(mark, infoWin, map); municipio['mapmark'] = mark; municipio['infowindow'] = infoWin;