diff --git a/poetry.lock b/poetry.lock index 180f2af5..409d8db8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -117,7 +117,7 @@ yaml = ["PyYAML (>=3.10)"] [[package]] name = "decorator" -version = "5.0.5" +version = "5.0.7" description = "Decorators for Humans" category = "dev" optional = false @@ -171,6 +171,25 @@ sqlparse = ">=0.2.2" argon2 = ["argon2-cffi (>=16.1.0)"] bcrypt = ["bcrypt"] +[[package]] +name = "django-admin-numeric-filter" +version = "0.1.6" +description = "Numeric filters for Django admin" +category = "dev" +optional = false +python-versions = "*" + +[package.dependencies] +django = "*" + +[[package]] +name = "django-admin-rangefilter" +version = "0.7.0" +description = "django-admin-rangefilter app, add the filter by a custom date range on the admin UI." +category = "dev" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + [[package]] name = "django-debug-toolbar" version = "3.1.1" @@ -593,11 +612,11 @@ python-versions = "*" [[package]] name = "nltk" -version = "3.5" +version = "3.6.1" description = "Natural Language Toolkit" category = "dev" optional = false -python-versions = "*" +python-versions = ">=3.5.*" [package.dependencies] click = "*" @@ -606,9 +625,9 @@ regex = "*" tqdm = "*" [package.extras] -all = ["requests", "numpy", "python-crfsuite", "scikit-learn", "twython", "pyparsing", "scipy", "matplotlib", "gensim"] +all = ["requests", "pyparsing", "numpy", "twython", "gensim (<4.0.0)", "scikit-learn", "scipy", "python-crfsuite", "matplotlib"] corenlp = ["requests"] -machine_learning = ["gensim", "numpy", "python-crfsuite", "scikit-learn", "scipy"] +machine_learning = ["gensim (<4.0.0)", "numpy", "python-crfsuite", "scikit-learn", "scipy"] plot = ["matplotlib"] tgrep = ["pyparsing"] twitter = ["twython"] @@ -811,7 +830,7 @@ testing = ["fields", "hunter", "process-tests (==2.0.2)", "six", "pytest-xdist", [[package]] name = "pytest-django" -version = "4.1.0" +version = "4.2.0" description = "A Django plugin for pytest." category = "dev" optional = false @@ -1005,7 +1024,7 @@ test = ["pytest", "mock"] [[package]] name = "typed-ast" -version = "1.4.2" +version = "1.4.3" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false @@ -1110,7 +1129,7 @@ testing = ["pathlib2", "unittest2", "jaraco.itertools", "func-timeout"] [metadata] lock-version = "1.1" python-versions = ">=3.5" -content-hash = "0b781ee5936a798482a6a1e5dd469f2eff216615224e4e412c23ff0056d73849" +content-hash = "04f722cc8a85a13407310a729c78c4496dc48133c679ae6960e84c171fb6e00a" [metadata.files] appdirs = [ @@ -1201,8 +1220,8 @@ coveralls = [ {file = "coveralls-3.0.1.tar.gz", hash = "sha256:cbb942ae5ef3d2b55388cb5b43e93a269544911535f1e750e1c656aef019ce60"}, ] decorator = [ - {file = "decorator-5.0.5-py3-none-any.whl", hash = "sha256:b7157d62ea3c2c0c57b81a05e4569853e976a3dda5dd7a1cb86be78978c3c5f8"}, - {file = "decorator-5.0.5.tar.gz", hash = "sha256:acda948ffcfe4bd0c4a57834b74ad968b91925b8201b740ca9d46fb8c5c618ce"}, + {file = "decorator-5.0.7-py3-none-any.whl", hash = "sha256:945d84890bb20cc4a2f4a31fc4311c0c473af65ea318617f13a7257c9a58bc98"}, + {file = "decorator-5.0.7.tar.gz", hash = "sha256:6f201a6c4dac3d187352661f508b9364ec8091217442c9478f1f83c003a0f060"}, ] defusedxml = [ {file = "defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61"}, @@ -1224,6 +1243,13 @@ django = [ {file = "Django-2.2.20-py3-none-any.whl", hash = "sha256:2484f115891ab1a0e9ae153602a641fbc15d7894c036d79fb78662c0965d7954"}, {file = "Django-2.2.20.tar.gz", hash = "sha256:2569f9dc5f8e458a5e988b03d6b7a02bda59b006d6782f4ea0fd590ed7336a64"}, ] +django-admin-numeric-filter = [ + {file = "django-admin-numeric-filter-0.1.6.tar.gz", hash = "sha256:0f2e42e5040567ecc6dea2bd5f2439e2c00d3fb72c1180f51b1e1762e60d9abb"}, +] +django-admin-rangefilter = [ + {file = "django-admin-rangefilter-0.7.0.tar.gz", hash = "sha256:da641c8fb919a570f26d3008250f54f86e6446c47eab0d3e8454a1253ffeb6b5"}, + {file = "django_admin_rangefilter-0.7.0-py2.py3-none-any.whl", hash = "sha256:95343502a9d7725f51708cdc54185c156936b28566a3c004d4cb46dd9b6a3317"}, +] django-debug-toolbar = [ {file = "django-debug-toolbar-3.1.1.tar.gz", hash = "sha256:c97921a9cd421d392e7860dc4b464db8e06c8628df4dc58fedab012888c293c6"}, {file = "django_debug_toolbar-3.1.1-py3-none-any.whl", hash = "sha256:a1ce0665f7ef47d27b8df4b5d1058748e1f08500a01421a30d35164f38aaaf4c"}, @@ -1423,7 +1449,8 @@ mypy-extensions = [ {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] nltk = [ - {file = "nltk-3.5.zip", hash = "sha256:845365449cd8c5f9731f7cb9f8bd6fd0767553b9d53af9eb1b3abf7700936b35"}, + {file = "nltk-3.6.1-py3-none-any.whl", hash = "sha256:1235660f52ab10fda34d5277096724747f767b2903e1c0c4e14bde013552c9ba"}, + {file = "nltk-3.6.1.zip", hash = "sha256:cbc2ed576998fcf7cd181eeb3ca029e5f0025b264074b4beb57ce780673f8b86"}, ] odfpy = [ {file = "odfpy-1.4.1-py2.7.egg", hash = "sha256:fc3b8d1bc098eba4a0fda865a76d9d1e577c4ceec771426bcb169a82c5e9dfe0"}, @@ -1498,8 +1525,8 @@ pytest-cov = [ {file = "pytest_cov-2.10.1-py2.py3-none-any.whl", hash = "sha256:45ec2d5182f89a81fc3eb29e3d1ed3113b9e9a873bcddb2a71faaab066110191"}, ] pytest-django = [ - {file = "pytest-django-4.1.0.tar.gz", hash = "sha256:26f02c16d36fd4c8672390deebe3413678d89f30720c16efb8b2a6bf63b9041f"}, - {file = "pytest_django-4.1.0-py3-none-any.whl", hash = "sha256:10e384e6b8912ded92db64c58be8139d9ae23fb8361e5fc139d8e4f8fc601bc2"}, + {file = "pytest-django-4.2.0.tar.gz", hash = "sha256:80f8875226ec4dc0b205f0578072034563879d98d9b1bec143a80b9045716cb0"}, + {file = "pytest_django-4.2.0-py3-none-any.whl", hash = "sha256:a51150d8962200250e850c6adcab670779b9c2aa07271471059d1fb92a843fa9"}, ] python-dateutil = [ {file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"}, @@ -1651,36 +1678,36 @@ traitlets = [ {file = "traitlets-4.3.3.tar.gz", hash = "sha256:d023ee369ddd2763310e4c3eae1ff649689440d4ae59d7485eb4cfbbe3e359f7"}, ] typed-ast = [ - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:7703620125e4fb79b64aa52427ec192822e9f45d37d4b6625ab37ef403e1df70"}, - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c9aadc4924d4b5799112837b226160428524a9a45f830e0d0f184b19e4090487"}, - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:9ec45db0c766f196ae629e509f059ff05fc3148f9ffd28f3cfe75d4afb485412"}, - {file = "typed_ast-1.4.2-cp35-cp35m-win32.whl", hash = "sha256:85f95aa97a35bdb2f2f7d10ec5bbdac0aeb9dafdaf88e17492da0504de2e6400"}, - {file = "typed_ast-1.4.2-cp35-cp35m-win_amd64.whl", hash = "sha256:9044ef2df88d7f33692ae3f18d3be63dec69c4fb1b5a4a9ac950f9b4ba571606"}, - {file = "typed_ast-1.4.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:c1c876fd795b36126f773db9cbb393f19808edd2637e00fd6caba0e25f2c7b64"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:5dcfc2e264bd8a1db8b11a892bd1647154ce03eeba94b461effe68790d8b8e07"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:8db0e856712f79c45956da0c9a40ca4246abc3485ae0d7ecc86a20f5e4c09abc"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:d003156bb6a59cda9050e983441b7fa2487f7800d76bdc065566b7d728b4581a"}, - {file = "typed_ast-1.4.2-cp36-cp36m-win32.whl", hash = "sha256:4c790331247081ea7c632a76d5b2a265e6d325ecd3179d06e9cf8d46d90dd151"}, - {file = "typed_ast-1.4.2-cp36-cp36m-win_amd64.whl", hash = "sha256:d175297e9533d8d37437abc14e8a83cbc68af93cc9c1c59c2c292ec59a0697a3"}, - {file = "typed_ast-1.4.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cf54cfa843f297991b7388c281cb3855d911137223c6b6d2dd82a47ae5125a41"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:b4fcdcfa302538f70929eb7b392f536a237cbe2ed9cba88e3bf5027b39f5f77f"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:987f15737aba2ab5f3928c617ccf1ce412e2e321c77ab16ca5a293e7bbffd581"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:37f48d46d733d57cc70fd5f30572d11ab8ed92da6e6b28e024e4a3edfb456e37"}, - {file = "typed_ast-1.4.2-cp37-cp37m-win32.whl", hash = "sha256:36d829b31ab67d6fcb30e185ec996e1f72b892255a745d3a82138c97d21ed1cd"}, - {file = "typed_ast-1.4.2-cp37-cp37m-win_amd64.whl", hash = "sha256:8368f83e93c7156ccd40e49a783a6a6850ca25b556c0fa0240ed0f659d2fe496"}, - {file = "typed_ast-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:963c80b583b0661918718b095e02303d8078950b26cc00b5e5ea9ababe0de1fc"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e683e409e5c45d5c9082dc1daf13f6374300806240719f95dc783d1fc942af10"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:84aa6223d71012c68d577c83f4e7db50d11d6b1399a9c779046d75e24bed74ea"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:a38878a223bdd37c9709d07cd357bb79f4c760b29210e14ad0fb395294583787"}, - {file = "typed_ast-1.4.2-cp38-cp38-win32.whl", hash = "sha256:a2c927c49f2029291fbabd673d51a2180038f8cd5a5b2f290f78c4516be48be2"}, - {file = "typed_ast-1.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:c0c74e5579af4b977c8b932f40a5464764b2f86681327410aa028a22d2f54937"}, - {file = "typed_ast-1.4.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:07d49388d5bf7e863f7fa2f124b1b1d89d8aa0e2f7812faff0a5658c01c59aa1"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux1_i686.whl", hash = "sha256:240296b27397e4e37874abb1df2a608a92df85cf3e2a04d0d4d61055c8305ba6"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:d746a437cdbca200622385305aedd9aef68e8a645e385cc483bdc5e488f07166"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:14bf1522cdee369e8f5581238edac09150c765ec1cb33615855889cf33dcb92d"}, - {file = "typed_ast-1.4.2-cp39-cp39-win32.whl", hash = "sha256:cc7b98bf58167b7f2db91a4327da24fb93368838eb84a44c472283778fc2446b"}, - {file = "typed_ast-1.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:7147e2a76c75f0f64c4319886e7639e490fee87c9d25cb1d4faef1d8cf83a440"}, - {file = "typed_ast-1.4.2.tar.gz", hash = "sha256:9fc0b3cb5d1720e7141d103cf4819aea239f7d136acf9ee4a69b047b7986175a"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, + {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, + {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, + {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, + {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, + {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, + {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, + {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, + {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, + {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, ] typing-extensions = [ {file = "typing_extensions-3.7.4.3-py2-none-any.whl", hash = "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"}, diff --git a/pyproject.toml b/pyproject.toml index 95d135c1..9fdcaeb0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,6 +72,8 @@ django-mptt = "^0.11.0" django-treebeard = "^4.3.1" django-import-export = "^2.4.0" dj-database-url = "^0.5.0" +django-admin-numeric-filter = "^0.1.6" +django-admin-rangefilter = "^0.7.0" [tool.poetry.urls] "Bug Tracker" = "https://github.com/farridav/django-jazzmin/issues" @@ -138,6 +140,8 @@ deps = django-import-export django2: Django<3 django3: Django<4 + django-admin-numeric-filter + django-admin-rangefilter [testenv:coveralls-django3-py39] passenv = COVERALLS_REPO_TOKEN diff --git a/tests/test_admin_views.py b/tests/test_admin_views.py index de88e3a2..b1b9a8d7 100644 --- a/tests/test_admin_views.py +++ b/tests/test_admin_views.py @@ -1,8 +1,8 @@ import pytest - from jazzmin.compat import reverse -from .test_app.library.factories import BookFactory + from .test_app.library.books.models import Book +from .test_app.library.factories import BookFactory @pytest.mark.django_db @@ -131,10 +131,11 @@ def test_detail(admin_client): "admin/widgets/foreign_key_raw_id.html": 1, "admin/widgets/related_widget_wrapper.html": 4, "admin/widgets/split_datetime.html": 2, - "django/forms/widgets/attrs.html": 46, + "django/forms/widgets/attrs.html": 47, "django/forms/widgets/date.html": 5, "django/forms/widgets/hidden.html": 6, - "django/forms/widgets/input.html": 18, + "django/forms/widgets/input.html": 19, + "django/forms/widgets/number.html": 1, "django/forms/widgets/select.html": 6, "django/forms/widgets/select_option.html": 21, "django/forms/widgets/text.html": 4, @@ -161,6 +162,7 @@ def test_detail(admin_client): "django/forms/widgets/date.html", "django/forms/widgets/hidden.html", "django/forms/widgets/input.html", + "django/forms/widgets/number.html", "django/forms/widgets/select.html", "django/forms/widgets/select_option.html", "django/forms/widgets/text.html", @@ -208,10 +210,16 @@ def test_list(admin_client): "django/forms/widgets/text.html": 5, "django/forms/widgets/select_option.html": 4, "django/forms/widgets/select.html": 2, - "django/forms/widgets/input.html": 21, + "django/forms/widgets/input.html": 28, "django/forms/widgets/hidden.html": 11, - "django/forms/widgets/attrs.html": 27, + "django/forms/widgets/attrs.html": 34, "jazzmin/includes/ui_builder_panel.html": 1, + "admin/filter_numeric_range.html": 1, + "admin/filter_numeric_single.html": 1, + "admin/filter_numeric_slider.html": 1, + "django/forms/widgets/date.html": 2, + "django/forms/widgets/number.html": 5, + "rangefilter/date_filter.html": 1, } # The templates that were used @@ -238,6 +246,12 @@ def test_list(admin_client): "django/forms/widgets/hidden.html", "django/forms/widgets/attrs.html", "jazzmin/includes/ui_builder_panel.html", + "admin/filter_numeric_range.html", + "admin/filter_numeric_single.html", + "admin/filter_numeric_slider.html", + "django/forms/widgets/date.html", + "django/forms/widgets/number.html", + "rangefilter/date_filter.html", } diff --git a/tests/test_app/library/books/admin.py b/tests/test_app/library/books/admin.py index df33b40f..cadd1422 100644 --- a/tests/test_app/library/books/admin.py +++ b/tests/test_app/library/books/admin.py @@ -1,3 +1,9 @@ +from admin_numeric_filter.admin import ( + NumericFilterModelAdmin, + RangeNumericFilter, + SingleNumericFilter, + SliderNumericFilter, +) from django.contrib import admin from django.contrib.admin.models import LogEntry from django.contrib.auth.admin import UserAdmin @@ -5,12 +11,13 @@ from django.utils.html import format_html from django.utils.timesince import timesince from import_export.admin import ImportExportMixin +from rangefilter.filter import DateRangeFilter from jazzmin.utils import attr -from .models import Book, Author, Genre -from .resources import BookResource from ..loans.admin import BookLoanInline +from .models import Author, Book, Genre +from .resources import BookResource admin.site.unregister(User) @@ -20,16 +27,23 @@ class BooksInline(admin.TabularInline): @admin.register(Book) -class BookAdmin(ImportExportMixin, admin.ModelAdmin): +class BookAdmin(ImportExportMixin, NumericFilterModelAdmin): resource_class = BookResource fieldsets = ( ("general", {"fields": ("title", "author", "library")}), - ("other", {"fields": ("genre", "summary", "isbn", "published_on")}), + ("other", {"fields": ("genre", "summary", "isbn", "published_on", "pages")}), ) raw_id_fields = ("author",) - list_display = ("__str__", "title", "author") + list_display = ("__str__", "title", "author", "pages") readonly_fields = ("__str__",) - list_filter = ("author", "genre") + list_filter = ( + "author", + "genre", + ("pages", SingleNumericFilter), + ("pages", RangeNumericFilter), + ("pages", SliderNumericFilter), + ("last_print", DateRangeFilter), + ) list_per_page = 20 list_max_show_all = 100 list_editable = ("title",) diff --git a/tests/test_app/library/books/migrations/0004_book_pages.py b/tests/test_app/library/books/migrations/0004_book_pages.py new file mode 100644 index 00000000..bc8897cc --- /dev/null +++ b/tests/test_app/library/books/migrations/0004_book_pages.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.5 on 2021-01-18 15:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("books", "0003_auto_20201015_1222"), + ] + + operations = [ + migrations.AddField( + model_name="book", + name="pages", + field=models.IntegerField(null=True), + ), + ] diff --git a/tests/test_app/library/books/migrations/0005_book_last_print.py b/tests/test_app/library/books/migrations/0005_book_last_print.py new file mode 100644 index 00000000..08e85223 --- /dev/null +++ b/tests/test_app/library/books/migrations/0005_book_last_print.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.16 on 2021-02-26 21:49 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("books", "0004_book_pages"), + ] + + operations = [ + migrations.AddField( + model_name="book", + name="last_print", + field=models.DateField(default=datetime.date(2000, 1, 1)), + preserve_default=False, + ), + ] diff --git a/tests/test_app/library/books/models.py b/tests/test_app/library/books/models.py index 53566304..effcf539 100644 --- a/tests/test_app/library/books/models.py +++ b/tests/test_app/library/books/models.py @@ -23,6 +23,8 @@ class Book(models.Model): ) genre = models.ManyToManyField(Genre, help_text="Select a genre for this book") published_on = models.DateField() + last_print = models.DateField() + pages = models.IntegerField(null=True) def get_absolute_url(self): return reverse("admin:books_book_change", args=(self.id,)) diff --git a/tests/test_app/library/factories.py b/tests/test_app/library/factories.py index a0221e8a..381dd992 100644 --- a/tests/test_app/library/factories.py +++ b/tests/test_app/library/factories.py @@ -1,10 +1,10 @@ -from datetime import timedelta, date +from datetime import date, timedelta import factory from django.contrib.auth.models import Group, Permission, User from django.utils import timezone from factory.django import DjangoModelFactory -from factory.fuzzy import FuzzyChoice, FuzzyDate +from factory.fuzzy import FuzzyChoice, FuzzyDate, FuzzyInteger from .books.models import Author, Book, Genre from .loans.models import BookLoan, Library @@ -106,6 +106,8 @@ class BookFactory(DjangoModelFactory): summary = factory.Faker("sentence") isbn = "9780123456472" published_on = FuzzyDate(date(1950, 1, 1), date(1999, 1, 1)) + last_print = FuzzyDate(date(2000, 1, 1), date(2020, 1, 1)) + pages = FuzzyInteger(50, 1000) @factory.post_generation def genre(self, create, extracted, **kwargs): diff --git a/tests/test_app/library/settings.py b/tests/test_app/library/settings.py index 986a0890..e4672e7e 100644 --- a/tests/test_app/library/settings.py +++ b/tests/test_app/library/settings.py @@ -1,8 +1,8 @@ import os -from typing import Dict, Any +from typing import Any, Dict -from django.conf.global_settings import LANGUAGES as DJANGO_LANGUAGES import dj_database_url +from django.conf.global_settings import LANGUAGES as DJANGO_LANGUAGES ################### # Django Settings # @@ -18,6 +18,10 @@ INSTALLED_APPS = [ # Keep this above 'django.contrib.admin' "jazzmin", + # 3rd party app support demonstrated in test app (not a jazzmin requirement) + "admin_numeric_filter", + "rangefilter", + # Django apps "django.contrib.admin", "django.contrib.admindocs", "django.contrib.auth",