weather: add proper support for locations (#2606)

This commit is contained in:
Frédéric Péters 2013-03-21 09:52:09 +01:00
parent 7b1586b218
commit da21072e19
3 changed files with 25 additions and 3 deletions

View File

@ -24,3 +24,13 @@ class App(BaseApp):
'''Weather App, used to display the current weather'''
app_id = 'weather-app'
template_name = 'apps/weather.html'
location = None
def __init__(self, app_id, location='615702', **kwargs):
super(App, self).__init__(app_id, **kwargs)
self.location = location
def get_content_args(self):
args = super(App, self).get_content_args()
args.update({'location': self.location})
return args

View File

@ -28,13 +28,25 @@ Nouvelle application :
<form id="form-weather">
<label>Lieu</label>
<select name="location"><option>Paris</option></select>
<select name="location">
<option value="580778">Bordeaux</option>
<option value="608105">Lille</option>
<option value="609125">Lyon</option>
<option value="614274">Nice</option>
<option value="610264">Marseille</option>
<option value="612977">Montpellier</option>
<option value="613858">Nantes</option>
<option value="615702">Paris</option>
<option value="619163">Rennes</option>
<option value="627791">Strasbourg</option>
<option value="628886">Toulouse</option>
</select>
</form>
</div>
<script>
$(function(){ //DOM Ready
$('#{{app_id}} select').change(
$('#{{app_id}} > select').change(
function() {
var appid = $(this).val();
$('#dialog-confirm form').hide();

View File

@ -3,7 +3,7 @@
$(function(){ //DOM Ready
$.simpleWeather({
zipcode: '',
woeid: '615702',
woeid: '{{ location }}',
location: '',
unit: 'c',
success: function(weather) {