diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..10f0c87 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn iriot.wsgi diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c9660b --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Heroku Django Starter Template + +An utterly fantastic project starter template for Django 1.9. + +## Features + +- Production-ready configuration for Static Files, Database Settings, Gunicorn, etc. +- Enhancements to Django's static file serving functionality via WhiteNoise + +## How to Use + +To use this project, follow these steps: + +1. Create your working environment. +2. Install Django (`$ pip install django`) +3. Create a new project using this template + +## Creating Your Project + +Using this template to create a new Django app is easy:: + + $ django-admin.py startproject --template=https://github.com/heroku/heroku-django-template/archive/master.zip --name=Procfile helloworld + +You can replace ``helloworld`` with your desired project name. + +## Deployment to Heroku + + $ git init + $ git add -A + $ git commit -m "Initial commit" + + $ heroku create + $ git push heroku master + + $ heroku run python manage.py migrate + +See also, a [ready-made application](https://github.com/heroku/python-getting-started), ready to deploy. + +## Further Reading + +- [Gunicorn](https://warehouse.python.org/project/gunicorn/) +- [WhiteNoise](https://warehouse.python.org/project/whitenoise/) +- [dj-database-url](https://warehouse.python.org/project/dj-database-url/) diff --git a/accounts/__init__.py b/accounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/accounts/admin.py b/accounts/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/accounts/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/accounts/forms.py b/accounts/forms.py new file mode 100644 index 0000000..d2eb93c --- /dev/null +++ b/accounts/forms.py @@ -0,0 +1,12 @@ +from django import forms +from django.contrib.auth.models import User + +class UserForm(forms.ModelForm): + password = forms.CharField(widget=forms.PasswordInput(attrs={'class':'form-control'})) + first_name = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) + last_name = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) + username = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'})) + email = forms.EmailField(widget=forms.TextInput(attrs={'class':'form-control'})) + class Meta: + model = User + fields = ('username', 'first_name', 'last_name', 'email', 'password') diff --git a/accounts/models.py b/accounts/models.py new file mode 100644 index 0000000..53a1022 --- /dev/null +++ b/accounts/models.py @@ -0,0 +1,5 @@ +from django.db import models + +# Create your models here. + +from django.contrib.auth.models import User diff --git a/accounts/templates/accounts/login.html b/accounts/templates/accounts/login.html new file mode 100644 index 0000000..05e3cd0 --- /dev/null +++ b/accounts/templates/accounts/login.html @@ -0,0 +1,16 @@ +{% extends "master/base.html" %} +{% block body_block %} +

Login

+ +
+ {% csrf_token %} + + +
+ + +
+ + +
+{% endblock %} diff --git a/accounts/templates/accounts/register.html b/accounts/templates/accounts/register.html new file mode 100644 index 0000000..ddf3e08 --- /dev/null +++ b/accounts/templates/accounts/register.html @@ -0,0 +1,28 @@ +{% extends "master/base.html" %} +{% block body_block %} +

Register

+ + {% if registered %} +

You are Registered. Continue to Home Page.

+ {% else %} + +
+ + {% csrf_token %} + + + {% for field in user_form.visible_fields %} +
+ {{ field.errors }} + + {{ field }} +
+ {% endfor %} + + + +
+ {% endif %} +{% endblock %} diff --git a/accounts/tests.py b/accounts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/accounts/urls.py b/accounts/urls.py new file mode 100644 index 0000000..56ce987 --- /dev/null +++ b/accounts/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls import url + +from . import views + +urlpatterns = [ + url(r'^register/$', views.register, name='register'), + url(r'^login/$', views.user_login, name='login'), + url(r'^logout/$', views.user_logout, name='logout'), +] diff --git a/accounts/views.py b/accounts/views.py new file mode 100644 index 0000000..aff37aa --- /dev/null +++ b/accounts/views.py @@ -0,0 +1,99 @@ +from django.shortcuts import render +from django.http import HttpResponse, HttpResponseRedirect +from django.contrib.auth import authenticate, login, logout +from .forms import UserForm +from django.contrib.auth.decorators import login_required +from django.contrib import messages +from django.core.urlresolvers import reverse +from django.contrib.auth.models import User + +def register(request): + + # A boolean value for telling the template whether the registration was successful. + # Set to False initially. Code changes value to True when registration succeeds. + registered = False + + # If it's a HTTP POST, we're interested in processing form data. + if request.method == 'POST': + # Attempt to grab information from the raw form information. + # Note that we make use of both UserForm and UserProfileForm. + user_form = UserForm(data=request.POST) + + # If the two forms are valid... + if user_form.is_valid(): + # Save the user's form data to the database. + user = user_form.save() + + # Now we hash the password with the set_password method. + # Once hashed, we can update the user object. + user.set_password(user.password) + + user.save() + + registered = True + + # Invalid form or forms - mistakes or something else? + # Print problems to the terminal. + # They'll also be shown to the user. + else: + print(user_form.errors) + + # Not a HTTP POST, so we render our form using two ModelForm instances. + # These forms will be blank, ready for user input. + else: + user_form = UserForm() + + # Render the template depending on the context. + return render(request, 'accounts/register.html', {'user_form': user_form, 'registered': registered} ) + +def user_login(request): + + # If the request is a HTTP POST, try to pull out the relevant information. + if request.method == 'POST': + # Gather the username and password provided by the user. + # This information is obtained from the login form. + # We use request.POST.get('') as opposed to request.POST[''], + # because the request.POST.get('') returns None, if the value does not exist, + # while the request.POST[''] will raise key error exception + username = request.POST.get('username') + password = request.POST.get('password') + + # Use Django's machinery to attempt to see if the username/password + # combination is valid - a User object is returned if it is. + user = authenticate(username=username, password=password) + + # If we have a User object, the details are correct. + # If None (Python's way of representing the absence of a value), no user + # with matching credentials was found. + if user: + # Is the account active? It could have been disabled. + if user.is_active: + # If the account is valid and active, we can log the user in. + # We'll send the user back to the homepage. + login(request, user) + return HttpResponseRedirect('/') + else: + # An inactive account was used - no logging in! + messages.warning(request, 'Your account is disabled. Please contact support.') + return HttpResponseRedirect('/') + else: + # Bad login details were provided. So we can't log the user in. + # TODO: USE FLASH MESSAGES ----------------- + messages.warning(request, 'Invalid Login.') + return HttpResponseRedirect(reverse('accounts:login')) + + # The request is not a HTTP POST, so display the login form. + # This scenario would most likely be a HTTP GET. + else: + # No context variables to pass to the template system, hence the + # blank dictionary object... + return render(request, 'accounts/login.html', {}) + + +# Use the login_required() decorator to ensure only those logged in can access the view. +@login_required +def user_logout(request): + # Since we know the user is logged in, we can now just log them out. + logout(request) + messages.success(request, 'You are now logged out.') + return HttpResponseRedirect('/') diff --git a/bin/activate b/bin/activate new file mode 100644 index 0000000..7e12a3e --- /dev/null +++ b/bin/activate @@ -0,0 +1,78 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + unset -f pydoc >/dev/null 2>&1 + + # reset old environment variables + # ! [ -z ${VAR+_} ] returns true if VAR is declared at all + if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then + PATH="$_OLD_VIRTUAL_PATH" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then + PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then + hash -r 2>/dev/null + fi + + if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then + PS1="$_OLD_VIRTUAL_PS1" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + if [ ! "${1-}" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelevant variables +deactivate nondestructive + +VIRTUAL_ENV="/Users/jameswindsor/Documents/Capstone/iRiot-WebApp" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/bin:$PATH" +export PATH + +# unset PYTHONHOME if set +if ! [ -z "${PYTHONHOME+_}" ] ; then + _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" + unset PYTHONHOME +fi + +if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then + _OLD_VIRTUAL_PS1="$PS1" + if [ "x" != x ] ; then + PS1="$PS1" + else + PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1" + fi + export PS1 +fi + +# Make sure to unalias pydoc if it's already there +alias pydoc 2>/dev/null >/dev/null && unalias pydoc + +pydoc () { + python -m pydoc "$@" +} + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then + hash -r 2>/dev/null +fi diff --git a/bin/activate.csh b/bin/activate.csh new file mode 100644 index 0000000..91b2c7b --- /dev/null +++ b/bin/activate.csh @@ -0,0 +1,36 @@ +# This file must be used with "source bin/activate.csh" *from csh*. +# You cannot run it directly. +# Created by Davide Di Blasi . + +alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc' + +# Unset irrelevant variables. +deactivate nondestructive + +setenv VIRTUAL_ENV "/Users/jameswindsor/Documents/Capstone/iRiot-WebApp" + +set _OLD_VIRTUAL_PATH="$PATH" +setenv PATH "$VIRTUAL_ENV/bin:$PATH" + + + +if ("" != "") then + set env_name = "" +else + set env_name = `basename "$VIRTUAL_ENV"` +endif + +# Could be in a non-interactive environment, +# in which case, $prompt is undefined and we wouldn't +# care about the prompt anyway. +if ( $?prompt ) then + set _OLD_VIRTUAL_PROMPT="$prompt" + set prompt = "[$env_name] $prompt" +endif + +unset env_name + +alias pydoc python -m pydoc + +rehash + diff --git a/bin/activate.fish b/bin/activate.fish new file mode 100644 index 0000000..edfedb5 --- /dev/null +++ b/bin/activate.fish @@ -0,0 +1,76 @@ +# This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*. +# Do not run it directly. + +function deactivate -d 'Exit virtualenv mode and return to the normal environment.' + # reset old environment variables + if test -n "$_OLD_VIRTUAL_PATH" + set -gx PATH $_OLD_VIRTUAL_PATH + set -e _OLD_VIRTUAL_PATH + end + + if test -n "$_OLD_VIRTUAL_PYTHONHOME" + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME + set -e _OLD_VIRTUAL_PYTHONHOME + end + + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" + # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`. + set -l fish_function_path + + # Erase virtualenv's `fish_prompt` and restore the original. + functions -e fish_prompt + functions -c _old_fish_prompt fish_prompt + functions -e _old_fish_prompt + set -e _OLD_FISH_PROMPT_OVERRIDE + end + + set -e VIRTUAL_ENV + + if test "$argv[1]" != 'nondestructive' + # Self-destruct! + functions -e pydoc + functions -e deactivate + end +end + +# Unset irrelevant variables. +deactivate nondestructive + +set -gx VIRTUAL_ENV "/Users/jameswindsor/Documents/Capstone/iRiot-WebApp" + +set -gx _OLD_VIRTUAL_PATH $PATH +set -gx PATH "$VIRTUAL_ENV/bin" $PATH + +# Unset `$PYTHONHOME` if set. +if set -q PYTHONHOME + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME + set -e PYTHONHOME +end + +function pydoc + python -m pydoc $argv +end + +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" + # Copy the current `fish_prompt` function as `_old_fish_prompt`. + functions -c fish_prompt _old_fish_prompt + + function fish_prompt + # Save the current $status, for fish_prompts that display it. + set -l old_status $status + + # Prompt override provided? + # If not, just prepend the environment name. + if test -n "" + printf '%s%s' "" (set_color normal) + else + printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV") + end + + # Restore the original $status + echo "exit $old_status" | source + _old_fish_prompt + end + + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" +end diff --git a/bin/activate_this.py b/bin/activate_this.py new file mode 100644 index 0000000..f18193b --- /dev/null +++ b/bin/activate_this.py @@ -0,0 +1,34 @@ +"""By using execfile(this_file, dict(__file__=this_file)) you will +activate this virtualenv environment. + +This can be used when you must use an existing Python interpreter, not +the virtualenv bin/python +""" + +try: + __file__ +except NameError: + raise AssertionError( + "You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))") +import sys +import os + +old_os_path = os.environ.get('PATH', '') +os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path +base = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +if sys.platform == 'win32': + site_packages = os.path.join(base, 'Lib', 'site-packages') +else: + site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages') +prev_sys_path = list(sys.path) +import site +site.addsitedir(site_packages) +sys.real_prefix = sys.prefix +sys.prefix = base +# Move the added items to the front of the path: +new_sys_path = [] +for item in list(sys.path): + if item not in prev_sys_path: + new_sys_path.append(item) + sys.path.remove(item) +sys.path[:0] = new_sys_path diff --git a/bin/easy_install b/bin/easy_install new file mode 100755 index 0000000..2843c58 --- /dev/null +++ b/bin/easy_install @@ -0,0 +1,11 @@ +#!/Users/jameswindsor/Documents/Capstone/iRiot-WebApp/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from setuptools.command.easy_install import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/easy_install-2.7 b/bin/easy_install-2.7 new file mode 100755 index 0000000..2843c58 --- /dev/null +++ b/bin/easy_install-2.7 @@ -0,0 +1,11 @@ +#!/Users/jameswindsor/Documents/Capstone/iRiot-WebApp/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from setuptools.command.easy_install import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/pip b/bin/pip new file mode 100755 index 0000000..c7699c2 --- /dev/null +++ b/bin/pip @@ -0,0 +1,11 @@ +#!/Users/jameswindsor/Documents/Capstone/iRiot-WebApp/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from pip import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/pip2 b/bin/pip2 new file mode 100755 index 0000000..c7699c2 --- /dev/null +++ b/bin/pip2 @@ -0,0 +1,11 @@ +#!/Users/jameswindsor/Documents/Capstone/iRiot-WebApp/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from pip import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/pip2.7 b/bin/pip2.7 new file mode 100755 index 0000000..c7699c2 --- /dev/null +++ b/bin/pip2.7 @@ -0,0 +1,11 @@ +#!/Users/jameswindsor/Documents/Capstone/iRiot-WebApp/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from pip import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/python b/bin/python new file mode 100755 index 0000000..947e565 Binary files /dev/null and b/bin/python differ diff --git a/bin/python-config b/bin/python-config new file mode 100755 index 0000000..43486df --- /dev/null +++ b/bin/python-config @@ -0,0 +1,78 @@ +#!/Users/jameswindsor/Documents/Capstone/iRiot-WebApp/bin/python + +import sys +import getopt +import sysconfig + +valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags', + 'ldflags', 'help'] + +if sys.version_info >= (3, 2): + valid_opts.insert(-1, 'extension-suffix') + valid_opts.append('abiflags') +if sys.version_info >= (3, 3): + valid_opts.append('configdir') + + +def exit_with_usage(code=1): + sys.stderr.write("Usage: {0} [{1}]\n".format( + sys.argv[0], '|'.join('--'+opt for opt in valid_opts))) + sys.exit(code) + +try: + opts, args = getopt.getopt(sys.argv[1:], '', valid_opts) +except getopt.error: + exit_with_usage() + +if not opts: + exit_with_usage() + +pyver = sysconfig.get_config_var('VERSION') +getvar = sysconfig.get_config_var + +opt_flags = [flag for (flag, val) in opts] + +if '--help' in opt_flags: + exit_with_usage(code=0) + +for opt in opt_flags: + if opt == '--prefix': + print(sysconfig.get_config_var('prefix')) + + elif opt == '--exec-prefix': + print(sysconfig.get_config_var('exec_prefix')) + + elif opt in ('--includes', '--cflags'): + flags = ['-I' + sysconfig.get_path('include'), + '-I' + sysconfig.get_path('platinclude')] + if opt == '--cflags': + flags.extend(getvar('CFLAGS').split()) + print(' '.join(flags)) + + elif opt in ('--libs', '--ldflags'): + abiflags = getattr(sys, 'abiflags', '') + libs = ['-lpython' + pyver + abiflags] + libs += getvar('LIBS').split() + libs += getvar('SYSLIBS').split() + # add the prefix/lib/pythonX.Y/config dir, but only if there is no + # shared library in prefix/lib/. + if opt == '--ldflags': + if not getvar('Py_ENABLE_SHARED'): + libs.insert(0, '-L' + getvar('LIBPL')) + if not getvar('PYTHONFRAMEWORK'): + libs.extend(getvar('LINKFORSHARED').split()) + print(' '.join(libs)) + + elif opt == '--extension-suffix': + ext_suffix = sysconfig.get_config_var('EXT_SUFFIX') + if ext_suffix is None: + ext_suffix = sysconfig.get_config_var('SO') + print(ext_suffix) + + elif opt == '--abiflags': + if not getattr(sys, 'abiflags', None): + exit_with_usage() + print(sys.abiflags) + + elif opt == '--configdir': + print(sysconfig.get_config_var('LIBPL')) diff --git a/bin/python2 b/bin/python2 new file mode 120000 index 0000000..d8654aa --- /dev/null +++ b/bin/python2 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/bin/python2.7 b/bin/python2.7 new file mode 120000 index 0000000..d8654aa --- /dev/null +++ b/bin/python2.7 @@ -0,0 +1 @@ +python \ No newline at end of file diff --git a/bin/wheel b/bin/wheel new file mode 100755 index 0000000..511c9b8 --- /dev/null +++ b/bin/wheel @@ -0,0 +1,11 @@ +#!/Users/jameswindsor/Documents/Capstone/iRiot-WebApp/bin/python + +# -*- coding: utf-8 -*- +import re +import sys + +from wheel.tool import main + +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..d013580 Binary files /dev/null and b/db.sqlite3 differ diff --git a/include/python2.7 b/include/python2.7 new file mode 120000 index 0000000..3fe034f --- /dev/null +++ b/include/python2.7 @@ -0,0 +1 @@ +/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 \ No newline at end of file diff --git a/iriot/__init__.py b/iriot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/iriot/settings.py b/iriot/settings.py new file mode 100644 index 0000000..e7d6bbb --- /dev/null +++ b/iriot/settings.py @@ -0,0 +1,137 @@ +""" +Django settings for iriot project on Heroku. Fore more info, see: +https://github.com/heroku/heroku-django-template + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/1.9/ref/settings/ +""" + +import os +import dj_database_url + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "9lr-ah*val3=)gm3xt%g$szzchczr6w0%z8uvfsp(%#8lt5jnm" + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + # Disable Django's own staticfiles handling in favour of WhiteNoise, for + # greater consistency between gunicorn and `./manage.py runserver`. See: + # http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development + 'whitenoise.runserver_nostatic', + 'django.contrib.staticfiles', + 'accounts', + 'master' +] + +MIDDLEWARE_CLASSES = [ + 'django.middleware.security.SecurityMiddleware', + 'whitenoise.middleware.WhiteNoiseMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'iriot.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + 'debug': DEBUG, + }, + }, +] + +WSGI_APPLICATION = 'iriot.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.9/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + +# Internationalization +# https://docs.djangoproject.com/en/1.9/topics/i18n/ + +LANGUAGE_CODE = 'en-us' +TIME_ZONE = 'UTC' +USE_I18N = True +USE_L10N = True +USE_TZ = True + +# Update database configuration with $DATABASE_URL. +db_from_env = dj_database_url.config(conn_max_age=500) +DATABASES['default'].update(db_from_env) + +# Honor the 'X-Forwarded-Proto' header for request.is_secure() +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + +# Allow all host headers +ALLOWED_HOSTS = ['*'] + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.9/howto/static-files/ + +STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') +STATIC_URL = '/static/' + +# Extra places for collectstatic to find static files. +STATICFILES_DIRS = [ + os.path.join(PROJECT_ROOT, 'static'), +] + +# Simplified static file serving. +# https://warehouse.python.org/project/whitenoise/ +STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' diff --git a/iriot/static/humans.txt b/iriot/static/humans.txt new file mode 100644 index 0000000..e69de29 diff --git a/iriot/urls.py b/iriot/urls.py new file mode 100644 index 0000000..b0f068f --- /dev/null +++ b/iriot/urls.py @@ -0,0 +1,23 @@ +"""iriot URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.9/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import include, url +from django.contrib import admin + +urlpatterns = [ + url(r'^admin/', admin.site.urls), + url(r'^accounts/', include('accounts.urls', namespace="accounts")), + url(r'^$', include('master.urls', namespace="master")), +] diff --git a/iriot/wsgi.py b/iriot/wsgi.py new file mode 100644 index 0000000..4f199d8 --- /dev/null +++ b/iriot/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for iriot project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "iriot.settings") + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..92c897c --- /dev/null +++ b/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "iriot.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/master/__init__.py b/master/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/master/admin.py b/master/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/master/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/master/migrations/__init__.py b/master/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/master/models.py b/master/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/master/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/master/templates/master/base.html b/master/templates/master/base.html new file mode 100644 index 0000000..5c0c3e9 --- /dev/null +++ b/master/templates/master/base.html @@ -0,0 +1,98 @@ + + + + + + + + + + SecureShare | {% block title %}This page{% endblock %} + + + + + + + {% block head_block %}{% endblock %} + + + + + + +
+
+ +
+
+ {% if messages %} +
+ {% for message in messages %} +
+ + {{ message }} +
+ {% endfor %} +
+ {% endif %} + {% block body_block %}{% endblock %} +
+
+
+
+ + + + + + + + + diff --git a/master/templates/master/index.html b/master/templates/master/index.html new file mode 100644 index 0000000..ebadbf7 --- /dev/null +++ b/master/templates/master/index.html @@ -0,0 +1,21 @@ +{% extends "master/base.html" %} +{% block body_block %} +{% if user.is_authenticated %} + + +

Hello {{ user.first_name }}. Welcome to iRiot!

+ + +{% else %} +
+

Welcome to iRiot!

+

The internet of things. simplified.

+

Register Now

+
+

In traditional IoT systems, every device communicates via a WiFi connection, placing a significant load on your local network and creating an unnecessarily large cyber attack surface. Our solution is different.

+

Old Dogs, New Tricks.

+

Why should creating a “smart home” involve buying brand-new, “smart” devices? Many TVs, light switches, fans, AC units, and more already contain IR sensors. By placing one of our hubs on the ceiling of every room in your home, you will be able to control all of these devices from one, simple web app.

+

Security is Key.

+

Amazon provides our project with a robust, secure Internet of Things backbone. Loaded with air-tight features, you should never have to worry about unwanted intruders in your network.

+{% endif %} +{% endblock %} diff --git a/master/tests.py b/master/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/master/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/master/urls.py b/master/urls.py new file mode 100644 index 0000000..c650e6d --- /dev/null +++ b/master/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import url + +from . import views + +urlpatterns = [ + url(r'^$', views.index, name='index'), + +] diff --git a/master/views.py b/master/views.py new file mode 100644 index 0000000..acc535a --- /dev/null +++ b/master/views.py @@ -0,0 +1,6 @@ +from django.shortcuts import render + +# Create your views here. + +def index(request): + return render(request, 'master/index.html', {}) diff --git a/pip-selfcheck.json b/pip-selfcheck.json new file mode 100644 index 0000000..0e8dda6 --- /dev/null +++ b/pip-selfcheck.json @@ -0,0 +1 @@ +{"last_check":"2016-09-21T13:08:57Z","pypi_version":"8.1.2"} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4421a41 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +dj-database-url==0.4.1 +Django==1.9.8 +gunicorn==19.6.0 +psycopg2==2.6.2 +whitenoise==3.2 diff --git a/runtime.txt b/runtime.txt new file mode 100644 index 0000000..fdf7966 --- /dev/null +++ b/runtime.txt @@ -0,0 +1 @@ +python-2.7.12