Skip to content

Commit

Permalink
Merge pull request #41 from wiltso/dj3
Browse files Browse the repository at this point in the history
Update to python ^3 and Django ^3 & remove support for older versions
  • Loading branch information
suutari-ai authored Jun 28, 2022
2 parents 5ab4318 + 3172d56 commit b3060c2
Show file tree
Hide file tree
Showing 37 changed files with 1,541 additions and 912 deletions.
15 changes: 9 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ env:
- DATABASE=mysql DATABASE_USER=travis DATABASE_PASSWORD=
- DATABASE=sqlite
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "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", ""),
}
}
7 changes: 2 additions & 5 deletions dfd_tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from django.conf.urls import include, url
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 = [
url(r'^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
1 change: 0 additions & 1 deletion form_designer/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'form_designer.apps.FormDesignerConfig'
Loading

0 comments on commit b3060c2

Please sign in to comment.