From a05d6d8b5c45326a878823e52807db5b1951a393 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Tue, 21 May 2013 21:23:53 +1000 Subject: [PATCH] Basic setup and ajax structure --- SprinklerStudio/templates/header.html | 8 +-- SprinklerStudio/urls.pyc | Bin 680 -> 680 bytes setup/__init__.py | 0 setup/models.py | 12 +++++ setup/templates/setup/index.html | 61 +++++++++++++++++++++++ setup/tests.py | 16 ++++++ setup/views.py | 1 + weather/WeatherUtils.py | 13 ++++- weather/WeatherUtils.pyc | Bin 1139 -> 1563 bytes weather/templates/sprinklers/detail.html | 17 ------- weather/templates/weather/index.html | 61 +++++++++++++++++++++++ weather/urls.py | 3 +- weather/urls.pyc | Bin 391 -> 439 bytes weather/views.py | 15 +++++- weather/views.pyc | Bin 1043 -> 1617 bytes 15 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 setup/__init__.py create mode 100644 setup/models.py create mode 100644 setup/templates/setup/index.html create mode 100644 setup/tests.py create mode 100644 setup/views.py delete mode 100644 weather/templates/sprinklers/detail.html create mode 100644 weather/templates/weather/index.html diff --git a/SprinklerStudio/templates/header.html b/SprinklerStudio/templates/header.html index 0da1e89..0623897 100755 --- a/SprinklerStudio/templates/header.html +++ b/SprinklerStudio/templates/header.html @@ -14,9 +14,9 @@ \ No newline at end of file diff --git a/SprinklerStudio/urls.pyc b/SprinklerStudio/urls.pyc index a36caacf5ebfe3f3b1b24ca227b136b0e0a03277..47f2e71a7b3f2079c6044b89ee90aac132b4d5e6 100644 GIT binary patch delta 16 YcmZ3%x`LIR`7#~^}*%vYa04=2jjsO4v delta 16 XcmZ3%x`LIR`7 +
+

Sprinklers!

+
+

Blah blah blah watering. Blah blah rain.

+ lime + + +
+
+

Finding location...

+
+
+

+
+
+ + + + + + diff --git a/setup/tests.py b/setup/tests.py new file mode 100644 index 0000000..501deb7 --- /dev/null +++ b/setup/tests.py @@ -0,0 +1,16 @@ +""" +This file demonstrates writing tests using the unittest module. These will pass +when you run "manage.py test". + +Replace this with more appropriate tests for your application. +""" + +from django.test import TestCase + + +class SimpleTest(TestCase): + def test_basic_addition(self): + """ + Tests that 1 + 1 always equals 2. + """ + self.assertEqual(1 + 1, 2) diff --git a/setup/views.py b/setup/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/setup/views.py @@ -0,0 +1 @@ +# Create your views here. diff --git a/weather/WeatherUtils.py b/weather/WeatherUtils.py index 40792e8..d4973af 100644 --- a/weather/WeatherUtils.py +++ b/weather/WeatherUtils.py @@ -19,7 +19,16 @@ def currentTemp(): response = urllib2.urlopen(queryURL) decoder = json.JSONDecoder() - data = decoder.decode(response.read())["main"]["temp"] + temperature = decoder.decode(response.read())["main"]["temp"] - return (str(data) + " Degrees") + return (str(temperature) + " Degrees") +def currentTempByLatLon(latitude, longitude): + + queryURL = weatherURL + "lat=" + str(latitude) + "&lon=" + str(longitude) + response = urllib2.urlopen(queryURL) + + decoder = json.JSONDecoder() + temperature = decoder.decode(response.read())["main"]["temp"] + + return (str(temperature) + " Degrees") \ No newline at end of file diff --git a/weather/WeatherUtils.pyc b/weather/WeatherUtils.pyc index b5527f5adf74f8b7eb4ea4a6e2d8dd0c315c06b3..4c21200dd7e4b6017f2f45afd8009a26be704ece 100644 GIT binary patch delta 413 zcmXYt%}T>S5Xb*Jo1`BmZT+C77C}5n4nBaFf~dzLn0it#rCHQkTS>MDA)#P<^B~fb z_!9aYK7&uu7jUM!%lvl!vpci9vn+o2ExioNSD)|aef$sN^@uICZ>{@E5p&?uN375d zOJ6UCR9)juYaSj=(zBDqEWYV=+LtVkO|zY_rMC)DuSw@#t5Z&R1mDv*2UWpYznp*+=IIVQT<7h zn328U_8dQTdbTqjZF4x4TR?lNO1|2mFj!pcIYsrwkAAL8DPQ@jCX+nnQJG4?FFnUW AkN^Mx delta 90 zcmbQu^O-}M`7 - sprinkler Name: {{sprinkler.name}}
- sprinkler On? {{sprinkler.status}}
- {% for entry in sprinkler_log %} - Log ID: {{entry.id}}
- Time Started: {{entry.timeOn}}
- Time Ended: {{entry.timeOff}}
- {% endfor %} -{% else %} -

No sprinklers were found with that ID.

-{% endif %} - - - diff --git a/weather/templates/weather/index.html b/weather/templates/weather/index.html new file mode 100644 index 0000000..941f06b --- /dev/null +++ b/weather/templates/weather/index.html @@ -0,0 +1,61 @@ +{% include "templates/header.html" %} + + +
+
+

Sprinklers!

+
+

Blah blah blah watering. Blah blah rain.

+ lime +
+ +
+
+

Finding location...

+
+
+

+
+
+ + + + + + diff --git a/weather/urls.py b/weather/urls.py index c72ae6d..c74bff2 100644 --- a/weather/urls.py +++ b/weather/urls.py @@ -3,5 +3,6 @@ from django.conf.urls import patterns, url from weather import views urlpatterns = patterns('', - url(r'^$', views.index, name='index') + url(r'^$', views.index, name='index'), + url(r'^ajax$', views.ajax, name='ajax') ) diff --git a/weather/urls.pyc b/weather/urls.pyc index d9a6cce00062777eaa29ce1341d04b83803add6a..718272da0fc9a7001bec36ace43e5e1f58966b43 100644 GIT binary patch delta 118 zcmZo?-p(w|{F#?adHKx1WCkeU0MZUXT%0gb+C?#yi6MoZA(e$8i;W?Ll_7X>d&3XTcQ2Ht};856Db0CIKck HMo~rpFXk3? delta 73 zcmdna+|De`{F#?)dDi5>WCkc;2ht8eTg#ee zIRuE;A+;d0A+RBHAaFp$WHlk(fXs!!rE>>@F2ojG0R%mWZLRbn7I5S_%ZvRzkF#Qj z#9@)6nj@N|r$rd6(i42=l6b8`JX7T>oTk zK1>DFf+3FCWC0GK?m)5$wZ%^K9eHMREq0!6QI3yo{s+@MR`cC6%u=+-oQ62XS*$$v z@&6+&P7)Pig$7x}H1!#A^IM!BFeHulRN-4x**i+0e0K9S6?QBY)hIn?plO%t{Y+J; zllXS?LGEqq+Bf0aDQbJud^1iyuT!MP$&IOQlK?psLwQg1r7P~pzA!~sMqH5baCP0L zF)1}bLL(Bey`cWI2T2DBC?JvCvRcBWgoOb_uQu97agG<7ZW_M9Rw;5%)8)HoPmXI4czsyw7RFB%JTiUhx<}c8SrJ z@CKy&Jr-^=Hl9DGITM>C%ukEmn|`(J*3kH`T1{5N^BoQyvAElOF)oHYR#&)Upx>bw JNK@LI{{X<5kG=o^ delta 260 zcmcb}Gnqr0`7B3jFx=tKvgV2>u}Si*O1HLkSy04I4u+|0a`)C!QH#e6`5fk})}j7f=+pNWT2lt}|59>fhII44`Ndb0