diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8d57cafe091f3542afdc44bf15331141ad217db0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +db.sqlite3 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..9681517bf5a9c1aa1cb8429944d9b659dd1de810 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +Django==1.11.6 +djangorestframework==3.7.1 +pkg-resources==0.0.0 +pytz==2017.2 diff --git a/src/horae/__init__.py b/src/horae/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/horae/api.py b/src/horae/api.py new file mode 100644 index 0000000000000000000000000000000000000000..ba1c226c18998eab467dd60c694856f0adf9c054 --- /dev/null +++ b/src/horae/api.py @@ -0,0 +1,5 @@ +from django.conf.urls import url, include + + +urlpatterns = [ +] diff --git a/src/horae/settings.py b/src/horae/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..314d85d8a9a3a8a72145b33adb2bc6f316b89b0b --- /dev/null +++ b/src/horae/settings.py @@ -0,0 +1,143 @@ +""" +Django settings for horae project. + +Generated by 'django-admin startproject' using Django 1.11.6. + +For more information on this file, see +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.11/ref/settings/ +""" + +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.11/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'jf0w^y&ml(caax8f&a1mub)(js9(l5mhbbhosz3gi+m01ex+lo' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + # Tools + 'rest_framework', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'horae.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', + ], + }, + }, +] + +WSGI_APPLICATION = 'horae.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/1.11/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# 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.11/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.11/howto/static-files/ + +STATIC_URL = '/static/' + +# API +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': ( + 'rest_framework.permissions.IsAuthenticated', + ), + 'DEFAULT_AUTHENTICATION_CLASSES': ( + 'rest_framework.authentication.SessionAuthentication', + ), + # 'PAGE_SIZE': 20, +} + +# Elastic search config +ELASTIC_SEARCH_HOSTS = ['localhost', ] + +# Local settings +try: + from .local_settings import * +except ImportError: + pass diff --git a/src/horae/urls.py b/src/horae/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..845b90f7be3ed3061972209ca902caa53e4c8c8a --- /dev/null +++ b/src/horae/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import url, include +from django.contrib import admin +from horae.api import urlpatterns as api + +urlpatterns = [ + url(r'^api/', include(api, namespace='api')), + url(r'^admin/', admin.site.urls), +] diff --git a/src/horae/wsgi.py b/src/horae/wsgi.py new file mode 100644 index 0000000000000000000000000000000000000000..8a61f1d3bf6c618f962c7d47230222ad331c6130 --- /dev/null +++ b/src/horae/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for horae 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.11/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "horae.settings") + +application = get_wsgi_application() diff --git a/src/manage.py b/src/manage.py new file mode 100755 index 0000000000000000000000000000000000000000..5354ec25c3122b024f1dbc73795f90e69735729e --- /dev/null +++ b/src/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "horae.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)