Skip to content

Commit

Permalink
update project
Browse files Browse the repository at this point in the history
  • Loading branch information
jkarneges committed Apr 6, 2019
1 parent d6197b0 commit 048f58b
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 72 deletions.
6 changes: 6 additions & 0 deletions api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

#from django.contrib import admin

# Register your models here.
8 changes: 8 additions & 0 deletions api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.apps import AppConfig


class ApiConfig(AppConfig):
name = 'api'
3 changes: 2 additions & 1 deletion api/middleware.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin

class OptionsMiddleware:
class OptionsMiddleware(MiddlewareMixin):
def process_request(self, request):
if request.method == 'OPTIONS':
return HttpResponse()
File renamed without changes.
5 changes: 5 additions & 0 deletions api/models.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

#from django.db import models

# Create your models here.
18 changes: 4 additions & 14 deletions api/tests.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

Replace this with more appropriate tests for your application.
"""
#from django.test import TestCase

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)
# Create your tests here.
3 changes: 3 additions & 0 deletions api/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from base64 import b64encode, b64decode
import datetime
import copy
Expand Down
20 changes: 16 additions & 4 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@
dotenv.read_dotenv()

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webhookinbox.settings")

from django.core.management import execute_from_command_line

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
31 changes: 23 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
Django==1.8.2
PyJWT==1.4.0
argparse==1.2.1
alabaster==0.7.12
Babel==2.6.0
dj-database-url==0.3.0
dj-static==0.0.6
Django==1.11.20
django-dotenv==1.4.1
django-grip==1.7.0
django-hosts==1.2
gripcontrol==2.4.2
django-grip==2.0.0
django-hosts==3.0
docutils==0.14
gripcontrol==3.3.0
gunicorn==19.3.0
pubcontrol==2.2.7
imagesize==1.1.0
Jinja2==2.10
MarkupSafe==1.1.1
packaging==19.0
pkg-resources==0.0.0
pubcontrol==2.4.2
Pygments==2.3.1
PyJWT==1.4.0
pyparsing==2.3.1
pytz==2018.9
redis==2.10.3
requests==2.10.0
six==1.12.0
snowballstemmer==1.2.1
Sphinx==1.8.5
sphinxcontrib-websupport==1.1.0
static3==0.6.1
typing==3.6.6
Werkzeug==0.15.2
whitenoise==1.0.6
wsgiref==0.1.2
Empty file added server/__init__.py
Empty file.
File renamed without changes.
68 changes: 42 additions & 26 deletions webhookinbox/settings.py → server/settings.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""
Django settings for webhookinbox project.
Django settings for server project.
Generated by 'django-admin startproject' using Django 1.8.2.
Generated by 'django-admin startproject' using Django 1.11.20.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'secret')
Expand All @@ -30,7 +30,7 @@

# Application definition

INSTALLED_APPS = (
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -40,25 +40,23 @@
'django_hosts',
'api',
'website',
)
]

MIDDLEWARE_CLASSES = (
'django_hosts.middleware.HostsRequestMiddleware',
MIDDLEWARE = [
'django_grip.GripMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'api.middleware.OptionsMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
'django_hosts.middleware.HostsResponseMiddleware',
)
]

ROOT_HOSTCONF = 'webhookinbox.hosts'
ROOT_URLCONF = 'webhookinbox.urls'
ROOT_HOSTCONF = 'server.hosts'
ROOT_URLCONF = 'server.urls'

DEFAULT_HOST = 'website'

Expand All @@ -78,17 +76,36 @@
},
]

WSGI_APPLICATION = 'webhookinbox.wsgi.application'
WSGI_APPLICATION = 'server.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {}


# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

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.8/topics/i18n/
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

Expand All @@ -102,7 +119,7 @@


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
Expand Down Expand Up @@ -146,25 +163,24 @@

REDIS_HOST = os.environ.get('REDIS_HOST')
if 'REDIS_PORT' in os.environ:
REDIS_PORT = int(os.environ['REDIS_PORT'])
REDIS_PORT = int(os.environ['REDIS_PORT'])
if 'REDIS_DB' in os.environ:
REDIS_DB = int(os.environ['REDIS_DB'])
REDIS_DB = int(os.environ['REDIS_DB'])

from gripcontrol import parse_grip_uri

GRIP_PROXY_REQUIRED = True
if 'GRIP_URL' in os.environ:
GRIP_PROXIES = [parse_grip_uri(os.environ['GRIP_URL'])]
GRIP_URL = os.environ.get('GRIP_URL')

WHINBOX_API_BASE = os.environ.get('WHINBOX_API_BASE')
WHINBOX_REDIS_PREFIX = os.environ.get('WHINBOX_REDIS_PREFIX')
WHINBOX_GRIP_PREFIX = os.environ.get('WHINBOX_GRIP_PREFIX')
if 'WHINBOX_ITEM_MAX' in os.environ:
WHINBOX_ITEM_MAX = int(os.environ['WHINBOX_ITEM_MAX'])
WHINBOX_ITEM_MAX = int(os.environ['WHINBOX_ITEM_MAX'])
if 'WHINBOX_ITEM_BURST_TIME' in os.environ:
WHINBOX_ITEM_BURST_TIME = int(os.environ['WHINBOX_ITEM_BURST_TIME'])
WHINBOX_ITEM_BURST_TIME = int(os.environ['WHINBOX_ITEM_BURST_TIME'])
if 'WHINBOX_ITEM_BURST_MAX' in os.environ:
WHINBOX_ITEM_BURST_MAX = int(os.environ['WHINBOX_ITEM_BURST_MAX'])
WHINBOX_ITEM_BURST_MAX = int(os.environ['WHINBOX_ITEM_BURST_MAX'])
WHINBOX_ORIG_HEADERS = (os.environ.get('WHINBOX_ORIG_HEADERS', '0') == '1')

GA_ID = os.environ.get('GA_ID')
File renamed without changes.
6 changes: 3 additions & 3 deletions webhookinbox/wsgi.py → server/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
WSGI config for webhookinbox project.
WSGI config for server 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.8/howto/deployment/wsgi/
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os
Expand All @@ -14,7 +14,7 @@

dotenv.read_dotenv(os.path.join(os.path.dirname(os.path.dirname(__file__)), '.env'))

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webhookinbox.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "server.settings")

from django.conf import settings

Expand Down
6 changes: 6 additions & 0 deletions website/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

#from django.contrib import admin

# Register your models here.
8 changes: 8 additions & 0 deletions website/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.apps import AppConfig


class WebsiteConfig(AppConfig):
name = 'website'
Empty file added website/migrations/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

#from django.db import models

# Create your models here.
18 changes: 4 additions & 14 deletions website/tests.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

Replace this with more appropriate tests for your application.
"""
#from django.test import TestCase

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)
# Create your tests here.
7 changes: 5 additions & 2 deletions website/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.shortcuts import render

def _page(request, name, inbox_id=None):
if settings.WHINBOX_API_BASE:
Expand All @@ -19,7 +22,7 @@ def _page(request, name, inbox_id=None):
if ga_id:
context['ga_id'] = ga_id

return render_to_response('website/%s.html' % name, context, context_instance=RequestContext(request))
return render(request, 'website/%s.html' % name, context)

def home(request):
return _page(request, 'home')
Expand Down

0 comments on commit 048f58b

Please sign in to comment.