More basic layout stuff
This commit is contained in:
parent
a05d6d8b5c
commit
d96559c2cc
Binary file not shown.
|
@ -137,6 +137,7 @@ INSTALLED_APPS = (
|
||||||
# 'django.contrib.admindocs',
|
# 'django.contrib.admindocs',
|
||||||
'weather',
|
'weather',
|
||||||
'sprinklers',
|
'sprinklers',
|
||||||
|
'setup',
|
||||||
)
|
)
|
||||||
|
|
||||||
# A sample logging configuration. The only tangible logging
|
# A sample logging configuration. The only tangible logging
|
||||||
|
|
Binary file not shown.
|
@ -10,10 +10,12 @@
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{% if sprinkler_list %}
|
{% if sprinkler_list %}
|
||||||
{% for sprinkler in sprinkler_list %}
|
{% for sprinkler in sprinkler_list %}
|
||||||
<article class="articlecontent">
|
{% if sprinkler.enabled %}
|
||||||
<header><h2><a href="sprinklers/{{sprinkler.id}}">{{ sprinkler.name }}</a></h2></header>
|
<article class="articlecontent">
|
||||||
<p>Currently the sprinkler status is: {{sprinkler.status}}</p>
|
<header><h2><a href="sprinklers/{{sprinkler.id}}">{{ sprinkler.name }}</a></h2></header>
|
||||||
</article>
|
<p>Currently the sprinkler status is: {{sprinkler.status}}</p>
|
||||||
|
</article>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No active sprinklers were found.</p>
|
<p>No active sprinklers were found.</p>
|
||||||
|
|
|
@ -17,5 +17,6 @@ urlpatterns = patterns('',
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^weather/', include('weather.urls')),
|
url(r'^weather/', include('weather.urls')),
|
||||||
url(r'^sprinklers/', include('sprinklers.urls')),
|
url(r'^sprinklers/', include('sprinklers.urls')),
|
||||||
|
url(r'^setup/', include('setup.urls')),
|
||||||
url(r'^$', views.index, name='index')
|
url(r'^$', views.index, name='index')
|
||||||
)
|
)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,5 +1,17 @@
|
||||||
{% include "templates/header.html" %}
|
{% 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">
|
<section id="intro">
|
||||||
<header>
|
<header>
|
||||||
|
@ -10,6 +22,26 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div id="content">
|
<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">
|
<article class="articlecontent">
|
||||||
<p id="demo">Finding location...</p>
|
<p id="demo">Finding location...</p>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
@ -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'),
|
||||||
|
)
|
Binary file not shown.
|
@ -1 +1,31 @@
|
||||||
# Create your views here.
|
# 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)
|
||||||
|
|
Binary file not shown.
|
@ -6,6 +6,7 @@ class Sprinkler(models.Model):
|
||||||
name = models.CharField(max_length=60)
|
name = models.CharField(max_length=60)
|
||||||
enabled = models.BooleanField()
|
enabled = models.BooleanField()
|
||||||
status = models.BooleanField(default=False)
|
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
|
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):
|
class LogEntry(models.Model):
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue