Commit a93f06d2 authored by Alan Mitchell's avatar Alan Mitchell
Browse files

Skeleton of Ecobee Authorization done.

parent d4e971b2
......@@ -2,6 +2,8 @@
{% block pagetitle %}Ecobee Authorization{% endblock %}
{% block this_nav_link %}{% endblock %}
{% block title %}Ecobee Thermostat Authorization{% endblock %}
{% block content %}
......@@ -19,11 +21,11 @@ the following 4 character PIN in your account:</p>
<h2>Step 2: Click the following Button after Completing Step 1</h2>
<form style="text-align:center">
<form method="post" style="text-align:center">{% csrf_token %}
<input type="hidden" name="auth_code" value="{{ auth_code }}">
<input type="hidden" name="ecobee_PIN" value="{{ ecobee_PIN }}">
<input type="submit" value="Click after Completing Step 1">
<input type="submit" value="Click after Completing Step 1" style="font-size:20px">
</form>
......
{% extends "bmsapp/base.html" %}
{% block pagetitle %}Ecobee Access Tokens{% endblock %}
{% block title %}Ecobee Thermostat Access Tokens{% endblock %}
{% block content %}
<p>Copy and Paste the text below into the Script Parameters input for your
Ecobee Periodic Script:</p>
<textarea style="font-size:15px" rows="3" cols="50">
access_token: {{ access_token }}
refresh_token: {{ refresh_token }}
</textarea>
{% endblock %}
......@@ -21,6 +21,7 @@ urlpatterns = [
url(r'^map_json/$', views.map_json, name='map-json'),
url(r'^training/video/(\w+)/(\d+)/(\d+)/$', views.show_video, name='show-video'),
url(r'^make_store_key/$', views.make_store_key),
url(r'^ecobee_auth/$', views.ecobee_auth),
# catches URLs that don't match the above patterns. Assumes they give a template name to render.
url(r'^(\w+)/$', views.wildcard, name='wildcard'),
......
......@@ -2,7 +2,7 @@
import sys, logging, json, random, time
from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
from django.shortcuts import render_to_response, redirect, render
from django.contrib.auth.decorators import login_required
from django.views.decorators.csrf import csrf_exempt
from django.core.urlresolvers import reverse
......@@ -297,6 +297,21 @@ def map_json(request):
return HttpResponse(json.dumps(ret), content_type="application/json")
def ecobee_auth(request):
"""Used to generated a form so that a System Admin can obtain access keys
for reading data from the Ecobee thermostat server.
"""
ctx = base_context()
if request.method == 'GET':
ctx.update({'ecobee_PIN': 'Xy12', 'auth_code': 'ABcd132435@#45xaui'})
return render(request, 'bmsapp/ecobee_auth.html', ctx)
elif request.method == 'POST':
req = request.POST.dict()
ctx.update({'access_token': 'XYZ123abc', 'refresh_token': '123abcDEF'})
return render_to_response('bmsapp/ecobee_auth_result.html', ctx)
def wildcard(request, template_name):
'''
Used if a URL component doesn't match any of the predefied URL patterns. Renders
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment