Skip to content

Commit

Permalink
Fix code style with isort and flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
William Lindholm committed Jun 17, 2022
1 parent 13ba1d6 commit 71b49c6
Show file tree
Hide file tree
Showing 34 changed files with 1,493 additions and 810 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ python:
- "3.10"
install:
- pip install -U pip
- pip install 'tox>=3.4.0' tox-travis codecov
script: tox -vv -r
- pip install 'tox>=3.4.0' tox-travis codecov isort flake8
script:
- tox -vv -r
- isort .
- flake8 .
after_success: codecov -e TRAVIS_PYTHON_VERSION -e DATABASE
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Acknowledgements
This project is a fork of https://github.com/samluescher/django-form-designer .
Thanks, @samluescher!

This fork is compatible with Django 1.7+ and Python 2.7+.
This fork is compatible with Django 3+ and Python 3.7+.

General
=======
Expand Down
147 changes: 58 additions & 89 deletions dfd_tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import django
import os
from tempfile import gettempdir

Expand All @@ -8,118 +7,88 @@
cms = None

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = '&nsa)3w(oz6^a1e-dj+iw9=jqps6az(&l2khgqtr)%%sj8ky@('
SECRET_KEY = "&nsa)3w(oz6^a1e-dj+iw9=jqps6az(&l2khgqtr)%%sj8ky@("
DEBUG = True
ALLOWED_HOSTS = []

LANGUAGE_CODE = 'en'
LANGUAGES = [('en', 'en')]
TIME_ZONE = 'UTC'
LANGUAGE_CODE = "en"
LANGUAGES = [("en", "en")]
TIME_ZONE = "UTC"
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATIC_URL = "/static/"
MEDIA_ROOT = gettempdir()
WSGI_APPLICATION = 'dfd_tests.wsgi.application'
ROOT_URLCONF = 'dfd_tests.urls'
WSGI_APPLICATION = "dfd_tests.wsgi.application"
ROOT_URLCONF = "dfd_tests.urls"
SITE_ID = 1

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'dfd_tests',
'form_designer',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"dfd_tests",
"form_designer",
]

if cms:
INSTALLED_APPS.extend([
'menus',
'cms',
'treebeard',
'form_designer.contrib.cms_plugins.form_designer_form',
])
INSTALLED_APPS.extend(
[
"menus",
"cms",
"treebeard",
"form_designer.contrib.cms_plugins.form_designer_form",
]
)

CMS_TEMPLATES = [
('page.html', 'page'),
("page.html", "page"),
]

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",
]

if django.VERSION[0] >= 2:
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',
]
elif django.VERSION[:2] < (1, 8):
MIDDLEWARE_CLASSES = (
'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',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.tz',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
)
else:
MIDDLEWARE_CLASSES = (
'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',
)

if django.VERSION[:2] >= (1, 8):
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',
],
},
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",
],
},
]
},
]

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}

if os.environ.get('DATABASE') == 'mysql':
if os.environ.get("DATABASE") == "mysql":
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dfd_tests',
'USER': os.environ['DATABASE_USER'],
'PASSWORD': os.environ.get('DATABASE_PASSWORD', ''),
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": "dfd_tests",
"USER": os.environ["DATABASE_USER"],
"PASSWORD": os.environ.get("DATABASE_PASSWORD", ""),
}
}
8 changes: 2 additions & 6 deletions dfd_tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from django.conf.urls import include
from django.urls import path
from django.contrib import admin
import django

admin_urls = (admin.site.urls if (django.VERSION[0] >= 2) else include(admin.site.urls))
from django.urls import path

urlpatterns = [
path('admin/', admin_urls),
path("admin/", admin.site.urls),
]
1 change: 0 additions & 1 deletion dfd_tests/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dfd_tests.settings")
Expand Down
Loading

0 comments on commit 71b49c6

Please sign in to comment.