Skip to content

Commit

Permalink
Merge branch 'release/0.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
benzkji committed May 21, 2024
2 parents c3dfc6e + 3e5126a commit 5f37714
Show file tree
Hide file tree
Showing 42 changed files with 3,608 additions and 3,043 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
max_line_length = 88
rulers = 88
indent_style = space
indent_size = 4

[*.{yaml,yml,json,toml}]
indent_size = 2
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: CI

on: [push, pull_request, ]
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.8, 3.9, "3.10", "3.11", ]
python: [3.8, 3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python }}
Expand All @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10"]
python: ["3.11"]
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python }}
Expand All @@ -37,22 +37,22 @@ jobs:
- name: Run tox with coverage
# Run tox using the version of Python in `PATH`
# run: tox -e py${{ matrix.python }}-${{ matrix.django }}
run: tox -e py310-django32-cms311-coverage
run: tox -e py311-django42-cms311-coverage

lint:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.10"]
python: ["3.11"]
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Install flake8
run: pip install flake8 flake8-print
- name: Run flake8
run: pip install pre-commit
- name: Run pre-commit
# Run tox using the version of Python in `PATH`
# run: tox -e py${{ matrix.python }}-${{ matrix.django }}
run: flake8
run: pre-commit run --all-files
36 changes: 18 additions & 18 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: Release on PYPI
on:
push:
branches: [main]
branches: [main]

jobs:
build-and-publish:
runs-on: ubuntu-latest
if: github.repository == 'bnzk/django-ckeditor-link'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
- name: Build
run: |
python setup.py sdist
python setup.py bdist_wheel --universal
- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER_BNZK }}
TWINE_PASSWORD: ${{ secrets.PYPI_PW_BNZK }}
run: twine upload dist/*
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools wheel twine
- name: Build
run: |
python setup.py sdist
python setup.py bdist_wheel --universal
- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER_BNZK }}
TWINE_PASSWORD: ${{ secrets.PYPI_PW_BNZK }}
run: twine upload dist/*
61 changes: 61 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "^package.json|^package-lock.json|^z_legacy\/.*|__zzz\/.*|\/.*migrations.*\/.*"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
# syntax
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-xml
# - id: pretty-format-json
# git & filesystem
- id: check-added-large-files
- id: check-symlinks
- id: detect-private-key
- id: check-merge-conflict
- id: check-case-conflict # file conflicts: a.txt vs. A.txt
# formatters
- id: mixed-line-ending
- id: trailing-whitespace
exclude: "(.*\\.html|.*\\.md)$"
- id: end-of-file-fixer
exclude: "(.*\\.xml|.*\\.svg)$"
# python
- id: check-ast # abstract syntax tree
- id: check-builtin-literals # no {} and [], but dict() and list()
- id: debug-statements
# naaa
# - id: name-tests-test
# args: [--pytest-test-first]
# django-upgrade suggestions
- repo: https://github.com/adamchainz/django-upgrade
rev: "1.14.0"
hooks:
- id: django-upgrade
args: [--target-version, "4.2"]
# tha black
- repo: https://github.com/psf/black-pre-commit-mirror
rev: "23.7.0"
hooks:
- id: black
# flake8 replacement (&more)
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.284"
hooks:
- id: ruff
args: [--fix]
# js/sass/etc formatter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.2
hooks:
- id: prettier
args: [--list-different]
exclude: "(.*\\.html|.*\\.md)$"
# eslinth, shall we? urrfff
# - repo: https://github.com/pre-commit/mirrors-eslint
# rev: v8.47.0
# hooks:
# - id: eslint
88 changes: 0 additions & 88 deletions .zz-travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

- ?

==== 0.5.2 (2024-05-21) ===

- no functional changes
- REMOVE print statement
- introduce pre-commit / ruff / black and other goodies
- remove python 3.7 from test matrix


==== 0.5.1 (2023-06-28) ===

- introduce CKEDITOR_LINK_MODEL_USE_FILER_ADDONS, to enable usage of
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Alternative link dialog for ckeditor 4, using django modeladmin forms.
Alternative link dialog for ckeditor 4, using django modeladmin forms.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,4 @@ This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
Public License instead of this License.
4 changes: 2 additions & 2 deletions ckeditor_link/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '0.5.1'
__author__ = 'benzkji'
__version__ = "0.5.2"
__author__ = "benzkji"
38 changes: 20 additions & 18 deletions ckeditor_link/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from django.conf import settings
from django.urls import path
from django.contrib import admin
from django.db import models
from django.forms import widgets
from django.http import JsonResponse
from django.urls import path


class DjangoLinkAdmin(admin.ModelAdmin):

def get_model_perms(self, request):
"""
http://stackoverflow.com/questions/2431727/django-admin-hide-a-model
Expand All @@ -18,11 +17,7 @@ def get_model_perms(self, request):
@property
def media(self):
original_media = super(DjangoLinkAdmin, self).media
css = {
'all': (
settings.STATIC_URL + 'admin/ckeditor_link/css/link_admin.css',
)
}
css = {"all": (settings.STATIC_URL + "admin/ckeditor_link/css/link_admin.css",)}
new_media = widgets.Media(css=css)
return original_media + new_media

Expand All @@ -32,39 +27,46 @@ def get_urls(self):
"""
my_urls = [
path(
'verify/',
"verify/",
self.admin_site.admin_view(self.verify),
name=self._get_verify_url_name()
name=self._get_verify_url_name(),
),
]
return my_urls + super(DjangoLinkAdmin, self).get_urls()

def _get_verify_url_name(self):
return '{0}_{1}_verify'.format(self.model._meta.app_label,
self.model._meta.model_name)
return "{0}_{1}_verify".format(
self.model._meta.app_label, self.model._meta.model_name
)

def verify(self, request):
"""
verify data with modelform, send through data.
:param request:
:return:
"""
form = self.get_form(request, )(request.POST)
form = self.get_form(
request,
)(request.POST)
if form.is_valid():
verified_data = form.cleaned_data
obj = self.model(**verified_data)
link_value = ''
link_value = ""
# prepopulate href
if (getattr(obj, 'get_link', None)):
if getattr(obj, "get_link", None):
link_value = obj.get_link()
# basic serialize only
for key, value in verified_data.items():
if isinstance(value, models.Model):
verified_data[key] = value.id
return_data = {"valid": 'true', 'data': verified_data, 'link_value': link_value}
return_data = {
"valid": "true",
"data": verified_data,
"link_value": link_value,
}
else:
errors = form.errors
return_data = {"valid": 'false', 'errors': errors}
return_data = {"valid": "false", "errors": errors}
return JsonResponse(return_data)

def save_model(self, request, obj, form, change):
Expand All @@ -75,6 +77,6 @@ def save_model(self, request, obj, form, change):

def get_changeform_initial_data(self, request):
initial = super(DjangoLinkAdmin, self).get_changeform_initial_data(request)
if request.GET.get('page', None):
initial['cms_page'] = request.GET.get('page')
if request.GET.get("page", None):
initial["cms_page"] = request.GET.get("page")
return initial
Loading

0 comments on commit 5f37714

Please sign in to comment.