Skip to content

Commit

Permalink
v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Vedrilla committed Nov 3, 2023
1 parent af51111 commit 46715c3
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 90 deletions.
3 changes: 2 additions & 1 deletion .ambient-package-update/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
],
license_year=2022,
development_status="5 - Production/Stable",
has_migrations=False,
readme_content=ReadmeContent(
tagline="Add simple interactions to the otherwise static django admin.",
content="""# django-dynamic-admin-forms
Expand Down Expand Up @@ -153,7 +154,7 @@ def get_dynamic_city_field(self, data):
$ yarn cypress # or npm run cypress
```
""",
installation="""
custom_installation="""
- Install the package via pip:
```pip install django-dynamic-admin-forms```
Expand Down
5 changes: 1 addition & 4 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ omit =
setup.py,
*_test.py,
tests.py,
tests/*.py,
*tests*,
conftest.py
testapp/*

[report]
precision = 2
show_missing = True
exclude_lines =
# Don't complain if tests don't hit defensive assertion code:
raise NotImplementedError
# Ignore type checking conditions
if TYPE_CHECKING:
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
- name: Run pre-commit hooks
run: pre-commit run --all-files --hook-stage push



tests:
name: Python ${{ matrix.python-version }}, django ${{ matrix.django-version }}
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -76,13 +78,5 @@ jobs:

- name: Combine coverage and fail if it's <100%
run: |
# python -m coverage combine
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
- name: Upload HTML report
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: html-report
path: htmlcov
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
# https://pre-commit.com/

repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.10.0
hooks:
- id: black
args: [ --check, --diff, --config, ./pyproject.toml ]
stages: [ push ]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.1.1'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
# Run the Ruff linter.
- id: ruff
args: [ --fix, --unsafe-fixes, --exit-non-zero-on-fix ]
args: [--fix, --exit-non-zero-on-fix]
# Run the Ruff formatter.
- id: ruff-format

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
Expand Down
31 changes: 31 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- method: pip
path: .
extra_requirements:
- dev
24 changes: 0 additions & 24 deletions .readthedocs.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Downloads](https://static.pepy.tech/badge/django-dynamic-admin-forms)](https://pepy.tech/project/django-dynamic-admin-forms)
[![Coverage](https://img.shields.io/badge/Coverage-100%25-success)](https://github.com/ambient-innovation/django-dynamic-admin-forms/actions?workflow=CI)
[![Linting](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Coding Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![Coding Style](https://img.shields.io/badge/code%20style-Ruff-000000.svg)](https://github.com/astral-sh/ruff)
[![Documentation Status](https://readthedocs.org/projects/django-dynamic-admin-forms/badge/?version=latest)](https://django-dynamic-admin-forms.readthedocs.io/en/latest/?badge=latest)

Add simple interactions to the otherwise static django admin.
Expand Down Expand Up @@ -145,7 +145,7 @@ $ yarn cypress # or npm run cypress
## Installation



- Install the package via pip:

```pip install django-dynamic-admin-forms```
Expand Down
50 changes: 25 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,69 +16,69 @@
import django
from django.conf import settings

sys.path.insert(0, os.path.abspath('..')) # so that we can access the "django_dynamic_admin_forms" package
sys.path.insert(0, os.path.abspath("..")) # so that we can access the "django_dynamic_admin_forms" package
settings.configure(
INSTALLED_APPS=[
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_dynamic_admin_forms',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_dynamic_admin_forms",
],
SECRET_KEY='ASDFjklö123456890',
SECRET_KEY="ASDFjklö123456890",
)
django.setup()

from django_dynamic_admin_forms import __version__ # noqa: E402

# -- Project information -----------------------------------------------------

project = 'django-dynamic-admin-forms'
copyright = '2023, Ambient Innovation: GmbH' # noqa: A001
author = 'Ambient Innovation: GmbH <[email protected]>'
project = "django-dynamic-admin-forms"
copyright = "2023, Ambient Innovation: GmbH" # noqa: A001
author = "Ambient Innovation: GmbH <[email protected]>"
version = __version__
release = __version__

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinx.ext.autodoc',
'm2r2',
"sphinx_rtd_theme",
"sphinx.ext.autodoc",
"m2r2",
]

source_suffix = ['.rst', '.md']
source_suffix = [".rst", ".md"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# html_theme = 'alabaster'
html_theme = 'sphinx_rtd_theme'
# html_theme = "alabaster"
html_theme = "sphinx_rtd_theme"
html_theme_options = {
'display_version': False,
'style_external_links': False,
"display_version": False,
"style_external_links": False,
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Set master doc file
master_doc = 'index'
master_doc = "index"
26 changes: 15 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ dev = [
'pytest-mock~=3.10',
'coverage~=7.3',
'pre-commit~=3.5',
'black~=23.10',
'ruff~=0.1',
'sphinx==4.2.0',
'sphinx-rtd-theme==1.0.0',
'm2r2==0.3.1',
'mistune<2.0.0',
'ambient-package-update~=23.10.2',
'ambient-package-update~=23.10.6',
'unittest-parametrize~=1.4',
]

Expand All @@ -62,15 +62,6 @@ name = "django_dynamic_admin_forms"
'Bugtracker' = 'https://github.com/ambient-innovation/django-dynamic-admin-forms/issues'
'Changelog' = 'https://django-dynamic-admin-forms.readthedocs.io/en/latest/features/changelog.html'


[tool.black]
# use force-exclude, so that black also applies exclude when run using pre-commit: https://github.com/psf/black/issues/395
force-exclude = '''.*/migrations/.*'''
line-length = 120
multi_line_output = 3
skip-string-normalization = true
include_trailing_comma = true

[tool.ruff]
select = [
"E", # pycodestyle errors
Expand Down Expand Up @@ -153,6 +144,19 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Assume Python 3.12
target-version = "py312"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.tox]
legacy_tox_ini = """
[tox]
Expand Down
10 changes: 5 additions & 5 deletions tests/test_admin_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def setUpTestData(cls):

def get_request(self, is_superuser: bool):
factory = RequestFactory()
user = User.objects.create_user(username='testuser', password='testpassword', is_superuser=is_superuser)
request = factory.get('/admin/')
user = User.objects.create_user(username="testuser", password="testpassword", is_superuser=is_superuser)
request = factory.get("/admin/")
request.user = user

return request
Expand All @@ -41,7 +41,7 @@ def test_render_field_with_valid_arguments(self):
response = mixin.render_field(request)

self.assertEqual(response.status_code, 200)
data = response.content.decode('utf-8')
data = response.content.decode("utf-8")
# Add further checks on the data in the response
self.assertNotEqual(data, "")

Expand All @@ -63,13 +63,13 @@ def test_render_field_with_custom_method(self):
def test_render_field_with_missing_arguments(self):
# Test with missing arguments
request = self.get_request(is_superuser=True)
request.GET = QueryDict('')
request.GET = QueryDict("")

mixin = DynamicModelAdminMixin()
response = mixin.render_field(request)

self.assertEqual(response.status_code, 400)
data = response.content.decode('utf-8')
data = response.content.decode("utf-8")
self.assertEqual(data, "Invalid arguments")

def test_render_field_with_permission_denied(self):
Expand Down

0 comments on commit 46715c3

Please sign in to comment.