Skip to content

Commit

Permalink
PEP8, update urls for dj2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Nov 9, 2017
1 parent e225090 commit 3fbaef2
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 66 deletions.
21 changes: 21 additions & 0 deletions django_crypto_fields/migrations/0009_auto_20170903_1532.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-09-03 13:32
from __future__ import unicode_literals

import _socket
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('django_crypto_fields', '0008_auto_20170624_1905'),
]

operations = [
migrations.AlterField(
model_name='crypt',
name='hostname_created',
field=models.CharField(blank=True, default=_socket.gethostname, help_text='System field. (modified on create only)', max_length=60),
),
]
97 changes: 65 additions & 32 deletions django_crypto_fields/settings.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
"""
Django settings for x project.
Django settings for django_crypto_fields project.
Generated by 'django-admin startproject' using Django 1.8.
Generated by 'django-admin startproject' using Django 1.11.1.
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
import sys

from pathlib import PurePath

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


# 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 = 'w^k+nty=&d-)qvc^mn_eo&c7-*^v7-e)f_kk&gbrpiv-d)6x(4'
SECRET_KEY = 'kgvh7)ay04_g&dtn5#lxp9=4bofk3ixnd-6$%c(-=tlcujjo6q'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -41,20 +41,18 @@
'django.contrib.staticfiles',
'django_revision.apps.AppConfig',
'edc_device.apps.AppConfig',
'example.apps.DjangoCryptoFieldsAppConfig',
'example.apps.AppConfig',
'django_crypto_fields.apps.AppConfig',
]

MIDDLEWARE_CLASSES = (
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.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
]

ROOT_URLCONF = 'django_crypto_fields.urls'

Expand All @@ -78,29 +76,48 @@


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
# 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'),
# }
# }
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': os.path.join(BASE_DIR, 'etc', 'default.cnf'),
},
'HOST': '',
'PORT': '',
'ATOMIC_REQUESTS': True,
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'OPTIONS': {
# 'read_default_file': os.path.join(BASE_DIR, 'etc', 'default.cnf'),
# },
# 'HOST': '',
# 'PORT': '',
# 'ATOMIC_REQUESTS': True,
# }
# }

# 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 @@ -114,9 +131,25 @@


# 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_URL = '/static/'


GIT_DIR = BASE_DIR
KEY_PATH = os.path.join(BASE_DIR, 'crypto_fields')
AUTO_CREATE_KEYS = DEBUG

if 'test' in sys.argv:

class DisableMigrations:

def __contains__(self, item):
return True

def __getitem__(self, item):
return None

MIGRATION_MODULES = DisableMigrations()
PASSWORD_HASHERS = ('django.contrib.auth.hashers.MD5PasswordHasher', )
DEFAULT_FILE_STORAGE = 'inmemorystorage.InMemoryStorage'
19 changes: 2 additions & 17 deletions django_crypto_fields/urls.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
"""django_crypto_fields 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 url
from django.urls.conf import path

from .admin import crypto_fields_admin


urlpatterns = [
url(r'^admin/', crypto_fields_admin.urls),
path('admin/', crypto_fields_admin.urls),
]
12 changes: 2 additions & 10 deletions django_crypto_fields/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
"""
WSGI config for django_crypto_fields 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", "django_crypto_fields.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"django_crypto_fields.settings")

application = get_wsgi_application()
23 changes: 18 additions & 5 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#!/usr/bin/env python3
#!/usr/bin/env python
import os
import sys

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

from django.core.management import execute_from_command_line

os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"django_crypto_fields.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)
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# see README if problems with pycrypto
Django
django_extensions
pycrypto
mysqlclient
git+https://github.com/erikvw/edc-base@develop#egg=edc_base
git+https://github.com/erikvw/django-revision@develop#egg=django-revision
git+https://github.com/botswana-harvard/edc-device@develop#egg=edc-device
git+https://github.com/botswana-harvard/edc-constants@develop#egg=edc-constants

0 comments on commit 3fbaef2

Please sign in to comment.