Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from collective/issue_15
implement selection of location in portlet
- Loading branch information
Showing
11 changed files
with
153 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
<dl class="portlet portletWeather" | ||
i18n:domain="collective.weather" | ||
tal:define="portal context/@@plone_portal_state/portal"> | ||
tal:define="portal context/@@plone_portal_state/portal; | ||
current_city view/current_city|nothing" | ||
tal:condition="current_city"> | ||
|
||
<dt class="portletHeader"> | ||
<span i18n:translate="">Weather</span> | ||
<span tal:content="view/data/header">Weather</span> | ||
</dt> | ||
|
||
<dd tal:content="structure portal/current-weather" /> | ||
<dd i18n:domain="collective.weather" | ||
tal:condition="current_city"> | ||
|
||
<span tal:define="city_name current_city/name|nothing" | ||
tal:content="city_name">Cordoba, Argentina | ||
</span> | ||
<div class="current-weather" | ||
tal:define="weather_info view/weather_info|nothing"> | ||
<div tal:condition="weather_info"> | ||
<tal:block tal:define="current_weather python:weather_info['weather']"> | ||
<img class="weather-icon" | ||
tal:attributes="src python:current_weather['icon']; | ||
title python:current_weather['conditions']; | ||
alt python:current_weather['conditions']" | ||
i18n:attributes="alt; title" /> | ||
<span class="weather-temp" tal:content="python:current_weather['temp']" /> | ||
</tal:block> | ||
</div> | ||
|
||
<div tal:condition="not:weather_info"> | ||
<img class="weather-icon" title="No weather information" alt="No weather information" | ||
tal:attributes="src string:++resource++collective.weather.icons/NA.png" | ||
i18n:attributes="alt; title" /> | ||
</div> | ||
</div> | ||
|
||
</dd> | ||
|
||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from collective.weather.testing import INTEGRATION_TESTING | ||
from zope.component import queryUtility | ||
from zope.schema.interfaces import IVocabularyFactory | ||
|
||
import unittest2 as unittest | ||
|
||
|
||
class VocabulariesTestCase(unittest.TestCase): | ||
|
||
layer = INTEGRATION_TESTING | ||
|
||
def setUp(self): | ||
self.portal = self.layer['portal'] | ||
|
||
def test_locations_vocabulary(self): | ||
name = 'collective.weather.Locations' | ||
util = queryUtility(IVocabularyFactory, name) | ||
self.assertIsNotNone(util) | ||
locations = util(self.portal) | ||
# as defined in the test fixture | ||
self.assertEqual(len(locations), 2) | ||
self.assertIn('Cordoba', locations) | ||
self.assertIn(u'Los Angeles', locations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from collective.weather.interfaces import IWeatherUtility | ||
from zope.component import getUtility | ||
from zope.schema.vocabulary import SimpleVocabulary | ||
|
||
|
||
def LocationsVocabulary(context): | ||
"""Creates a vocabulary to expose configured locations. | ||
""" | ||
|
||
weather_utility = getUtility(IWeatherUtility) | ||
locations = weather_utility.get_cities_list() | ||
items = [] | ||
for l in locations: | ||
items.append( | ||
SimpleVocabulary.createTerm(l['id'], l['location_id'], l['name'])) | ||
|
||
return SimpleVocabulary(items) |