diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a8202a83..4649914c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - uses: pre-commit/action@v2.0.3 tests: @@ -25,11 +25,11 @@ jobs: max-parallel: 5 matrix: python-version: - - "3.6" - - "3.7" - "3.8" - "3.9" - "3.10" + - "3.11" +# - "3.12" # Enable when we get rid of setuptools steps: - uses: actions/checkout@v2 @@ -58,7 +58,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - uses: actions/download-artifact@v3 with: name: coverage-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a975a26..4189e47f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,8 @@ default_language_version: - python: python3.10 + python: python3.11 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.5.0 hooks: - id: check-case-conflict - id: check-merge-conflict @@ -11,13 +11,13 @@ repos: - id: debug-statements - id: detect-private-key - repo: https://github.com/asottile/pyupgrade - rev: v2.31.0 + rev: v3.15.0 hooks: - id: pyupgrade args: - - --py36-plus - - repo: https://github.com/myint/autoflake - rev: v1.4 + - --py38-plus + - repo: https://github.com/pycqa/autoflake + rev: v2.2.1 hooks: - id: autoflake args: @@ -25,20 +25,20 @@ repos: - --remove-all-unused-imports - --ignore-init-module-imports - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 23.9.1 hooks: - id: black - - repo: https://github.com/asottile/blacken-docs - rev: v1.12.1 + - repo: https://github.com/adamchainz/blacken-docs + rev: 1.16.0 hooks: - id: blacken-docs - additional_dependencies: [black==22.3.0] - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 + additional_dependencies: [black==23.9.1] + - repo: https://github.com/pycqa/flake8 + rev: 6.1.0 hooks: - id: flake8 additional_dependencies: @@ -46,7 +46,7 @@ repos: - flake8-comprehensions - flake8-tidy-imports - repo: https://github.com/sirosen/check-jsonschema - rev: 0.11.0 + rev: 0.27.0 hooks: - id: check-github-workflows # - repo: https://github.com/mgedmin/check-manifest diff --git a/djedi/admin/cms.py b/djedi/admin/cms.py index 58f09643..5123999e 100644 --- a/djedi/admin/cms.py +++ b/djedi/admin/cms.py @@ -10,7 +10,6 @@ class Admin(ModelAdmin): - verbose_name = "CMS" verbose_name_plural = verbose_name diff --git a/djedi/apps.py b/djedi/apps.py new file mode 100644 index 00000000..0b807987 --- /dev/null +++ b/djedi/apps.py @@ -0,0 +1,7 @@ +from django.apps import AppConfig + + +class DjediConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "djedi" + verbose_name = "Djedi CMS" diff --git a/djedi/backends/django/db/backend.py b/djedi/backends/django/db/backend.py index 52e3a837..38ab49e9 100644 --- a/djedi/backends/django/db/backend.py +++ b/djedi/backends/django/db/backend.py @@ -12,7 +12,6 @@ class DjangoModelStorageBackend(DatabaseBackend): - scheme = "db" def __init__(self, **config): @@ -32,7 +31,6 @@ def get_many(self, uris): # Assert requested plugin matches if uri.ext in (None, plugin): - # Assert version matches or node is published if (uri.version == version) or (is_published and not uri.version): meta = self._decode_meta(meta, is_published=is_published) diff --git a/djedi/backends/django/db/models.py b/djedi/backends/django/db/models.py index 63cfe7cb..1187d851 100644 --- a/djedi/backends/django/db/models.py +++ b/djedi/backends/django/db/models.py @@ -2,7 +2,6 @@ class Node(models.Model): - key = models.CharField(max_length=255, db_index=True) content = models.TextField(blank=True) plugin = models.CharField(max_length=8) @@ -12,5 +11,4 @@ class Node(models.Model): date_created = models.DateTimeField(auto_now_add=True) class Meta: - app_label = "djedi" db_table = "djedi_node" diff --git a/djedi/migrations/0001_initial.py b/djedi/migrations/0001_initial.py index b48b75bc..25deac8c 100644 --- a/djedi/migrations/0001_initial.py +++ b/djedi/migrations/0001_initial.py @@ -2,7 +2,6 @@ class Migration(migrations.Migration): - dependencies = [] operations = [ diff --git a/djedi/migrations/0002_auto_20190722_1447.py b/djedi/migrations/0002_auto_20190722_1447.py index 85065e03..10666b44 100644 --- a/djedi/migrations/0002_auto_20190722_1447.py +++ b/djedi/migrations/0002_auto_20190722_1447.py @@ -4,7 +4,6 @@ class Migration(migrations.Migration): - dependencies = [ ("djedi", "0001_initial"), ] diff --git a/djedi/migrations/0003_alter_node_id.py b/djedi/migrations/0003_alter_node_id.py new file mode 100644 index 00000000..82f2e945 --- /dev/null +++ b/djedi/migrations/0003_alter_node_id.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.6 on 2023-10-11 10:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("djedi", "0002_auto_20190722_1447"), + ] + + operations = [ + migrations.AlterField( + model_name="node", + name="id", + field=models.BigAutoField( + auto_created=True, primary_key=True, serialize=False, verbose_name="ID" + ), + ), + ] diff --git a/example/example/settings.py b/example/example/settings.py index d5fc5d21..d56e5db7 100644 --- a/example/example/settings.py +++ b/example/example/settings.py @@ -16,72 +16,74 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" + # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'jf_&sn#&5gb7n510ji#9m7^@@-w@g%f(j0y=@=)pmvpc@4ia0)' +SECRET_KEY = "jf_&sn#&5gb7n510ji#9m7^@@-w@g%f(j0y=@=)pmvpc@4ia0)" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ['*'] +ALLOWED_HOSTS = ["*"] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'corsheaders', - 'djedi', - 'example', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "corsheaders", + "djedi", + "example", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'corsheaders.middleware.CorsMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'djedi.middleware.translation.DjediTranslationMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "corsheaders.middleware.CorsMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "djedi.middleware.translation.DjediTranslationMiddleware", ] -ROOT_URLCONF = 'example.urls' +ROOT_URLCONF = "example.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', + "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 = 'example.wsgi.application' +WSGI_APPLICATION = "example.wsgi.application" # Database # https://docs.djangoproject.com/en/dev/ref/settings/#databases 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"), } } @@ -95,9 +97,9 @@ # Internationalization # https://docs.djangoproject.com/en/dev/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -109,31 +111,29 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/dev/howto/static-files/ -STATIC_URL = '/static/' -MEDIA_URL = '/media/' +STATIC_URL = "/static/" +MEDIA_URL = "/media/" -STATIC_ROOT = '/static/' -MEDIA_ROOT = '/media/' +STATIC_ROOT = "/static/" +MEDIA_ROOT = "/media/" # To test if collectstatic with ManifestStaticFilesStorage works, set `DEBUG = # False` and run: # docker-compose exec django python manage.py collectstatic --no-input # DEBUG = False -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage' +STATICFILES_STORAGE = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" # CORS # https://github.com/OttoYiu/django-cors-headers -CORS_ORIGIN_WHITELIST = ( - 'localhost:3000', -) +CORS_ORIGIN_WHITELIST = ("localhost:3000",) CORS_ALLOW_CREDENTIALS = True # Djedi # https://djedi-cms.org/settings.html -DJEDI_XSS_DOMAIN = 'localhost' +DJEDI_XSS_DOMAIN = "localhost" # env DJEDI_THEME=luke docker-compose up -d django -DJEDI_THEME = os.environ.get('DJEDI_THEME') or None +DJEDI_THEME = os.environ.get("DJEDI_THEME") or None diff --git a/setup.py b/setup.py index 390237e2..af10b03e 100644 --- a/setup.py +++ b/setup.py @@ -58,11 +58,11 @@ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules", ], diff --git a/tox.ini b/tox.ini index ea8ffebc..4df2cc32 100644 --- a/tox.ini +++ b/tox.ini @@ -4,16 +4,16 @@ # and then run "tox" from this directory. [tox] -envlist = py36-django{ 22, 30, 31, 32 }, - py37-django{ 22, 30, 31, 32 }, - py38-django{ 22, 30, 31, 32, 40, 41 }, - py39-django{ 22, 30, 31, 32, 40, 41 }, - py310-django{ 22, 30, 31, 32, 40, 41 } +envlist = py38-django{ 32, 40, 41 }, + py39-django{ 32, 40, 41 }, + py310-django{ 32, 40, 41 }, + py311-django{ 32, 40, 41 }, + py312-django{ 32, 40, 41 }, [testenv] passenv = COVERAGE_FILE -whitelist_externals = make +allowlist_externals = make commands = make test install_command = pip install --pre {opts} {packages} deps = six @@ -21,29 +21,28 @@ deps = six markdown<=3.3 django-discover-runner coverage - django22: Django>=2.2,<2.3 - django30: Django>=3.0,<3.1 - django31: Django>=3.1,<3.2 django32: Django>=3.2,<3.3 django40: Django>=4.0,<4.1 django41: Django>=4.1,<4.2 [testenv:lcov] passenv = COVERAGE_FILE -whitelist_externals = make +allowlist_externals = make commands = make coverage-lcov install_command = pip install --pre {opts} {packages} deps = coverage [testenv:coverage] skip_install = true -basepython = python3.10 +basepython = python3.11 passenv = COVERAGE_FILE +allowlist_externals = make commands = make coverage deps = coverage [testenv:lint] skip_install = true -basepython = python3.10 +basepython = python3.11 +allowlist_externals = make commands = make lint deps = flake8