More basic layout stuff

This commit is contained in:
Josh Stewart 2013-05-24 15:14:19 +10:00
parent a05d6d8b5c
commit d96559c2cc
15 changed files with 79 additions and 4 deletions

Binary file not shown.

View File

@ -137,6 +137,7 @@ INSTALLED_APPS = (
# 'django.contrib.admindocs',
'weather',
'sprinklers',
'setup',
)
# A sample logging configuration. The only tangible logging

Binary file not shown.

View File

@ -10,10 +10,12 @@
<div id="content">
{% if sprinkler_list %}
{% for sprinkler in sprinkler_list %}
<article class="articlecontent">
<header><h2><a href="sprinklers/{{sprinkler.id}}">{{ sprinkler.name }}</a></h2></header>
<p>Currently the sprinkler status is: {{sprinkler.status}}</p>
</article>
{% if sprinkler.enabled %}
<article class="articlecontent">
<header><h2><a href="sprinklers/{{sprinkler.id}}">{{ sprinkler.name }}</a></h2></header>
<p>Currently the sprinkler status is: {{sprinkler.status}}</p>
</article>
{% endif %}
{% endfor %}
{% else %}
<p>No active sprinklers were found.</p>

View File

@ -17,5 +17,6 @@ urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^weather/', include('weather.urls')),
url(r'^sprinklers/', include('sprinklers.urls')),
url(r'^setup/', include('setup.urls')),
url(r'^$', views.index, name='index')
)

Binary file not shown.

BIN
setup/__init__.pyc Normal file

Binary file not shown.

BIN
setup/models.pyc Normal file

Binary file not shown.

View File

@ -1,5 +1,17 @@
{% include "templates/header.html" %}
<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
<section id="intro">
<header>
@ -10,6 +22,26 @@
</section>
<div id="content">
<form action="">
<h2><a href="#" onclick="toggle_visibility('sprinklers');">Sprinklers</a></h2>
<div id="sprinklers">
{% if sprinklers %}
{% for sprinkler in sprinklers %}
<article class="articlecontent" id="sprinkler_{{sprinkler.id}}">
<header><h3>{{sprinkler.id}}</h3></header>
<p>
<strong>Name:</strong> <input type="text" {{sprinkler.id}}_name value="{{ sprinkler.name }}"><br/>
<strong>Enabled: </strong><input type="checkbox" name="{{sprinkler.id}}_enabled" value="{{sprinkler.enabled}}" {% if sprinkler.enabled %}checked{% endif %}><br/>
<strong>Master valve: </strong><input type="checkbox" name="{{sprinkler.id}}_master" value="{{sprinkler.isMaster}}"> (Will turn on when any other sprinkler is on)
</p>
</article>
{% endfor %}
{% else %}
<p>No active sprinklers were found.</p>
{% endif %}
</div>
</form>
<article class="articlecontent">
<p id="demo">Finding location...</p>
</article>

8
setup/urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.conf.urls import patterns, url
from setup import views
urlpatterns = patterns('',
# ex: /setup/
url(r'^$', views.index, name='index'),
)

BIN
setup/urls.pyc Normal file

Binary file not shown.

View File

@ -1 +1,31 @@
# Create your views here.
import json
import urllib2
from django.core.cache import cache
from django.http import HttpResponse
from weather.models import Location
from django.template import Context, loader
from weather import WeatherUtils
from sprinklers.models import Sprinkler
def index(request):
#cache.clear()
latitude = Location.objects.all()[0].latitude
longitude = Location.objects.all()[0].longitude
sprinklers = Sprinkler.objects.all()
template = loader.get_template('setup/index.html')
context = Context({
'sprinklers': sprinklers,
})
return HttpResponse(template.render(context))
def ajax(request):
latitude = request.GET['lat'] # request.POST.get('lat', False)
longitude = request.GET['lon'] # request.POST.get('lat', False)
temperature = WeatherUtils.currentTempByLatLon(latitude, longitude)
return HttpResponse(temperature)

BIN
setup/views.pyc Normal file

Binary file not shown.

View File

@ -6,6 +6,7 @@ class Sprinkler(models.Model):
name = models.CharField(max_length=60)
enabled = models.BooleanField()
status = models.BooleanField(default=False)
isMaster = models.BooleanField(default=False)
currentLog = models.IntegerField(null=True, blank=True) #If the sprinkler is on, this variable contains the active log entry so it can be ended when it's turned off
class LogEntry(models.Model):

Binary file not shown.