From 37aa4ad0ccc93b67a9d85295cf4483de8f48306f Mon Sep 17 00:00:00 2001 From: wuyue Date: Thu, 16 Jun 2022 16:52:19 +0800 Subject: [PATCH 1/5] make previous & next button effective on change_list.html --- adminlteui/templates/admin/pagination.html | 55 ++++++++++++++++------ 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/adminlteui/templates/admin/pagination.html b/adminlteui/templates/admin/pagination.html index fba3f8a..494aa07 100644 --- a/adminlteui/templates/admin/pagination.html +++ b/adminlteui/templates/admin/pagination.html @@ -24,21 +24,48 @@ id="example2_paginate"> - \ No newline at end of file + From d769c0ca4ba70390329b3335fb4708dc5fb0017c Mon Sep 17 00:00:00 2001 From: wuyue Date: Wed, 22 Jun 2022 09:43:52 +0800 Subject: [PATCH 2/5] use select2 make admin filter searchable --- adminlteui/admin.py | 25 +++++++++++++++++++++++++ adminlteui/templates/admin/filter.html | 26 ++++++++++++++++++++------ 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/adminlteui/admin.py b/adminlteui/admin.py index 23190a7..ffb40b3 100644 --- a/adminlteui/admin.py +++ b/adminlteui/admin.py @@ -48,6 +48,31 @@ def get_image_box(): option_name='site_logo') else '' +class ModelAdmin(admin.ModelAdmin): + select2_list_filter = () + + class Media: + css = { + "all": ("admin/components/select2/dist/css/select2.min.css",) + } + js = ( + "admin/components/select2/dist/js/select2.min.js", + ) + + def changelist_view(self, request, extra_context=None): + view = super().changelist_view(request, extra_context) + cl = view.context_data.get('cl') + filter_specs = cl.filter_specs + + for index, filter_spec in enumerate(filter_specs): + if filter_spec.field_path in self.select2_list_filter: + # flag to use select2 + filter_spec.display_select2 = True + cl.filter_specs[index] = filter_spec + view.context_data['cl'] = cl + return view + + class GeneralOptionForm(forms.Form): site_title = forms.CharField(label=_('Site Title'), widget=widgets.AdminTextInputWidget(), diff --git a/adminlteui/templates/admin/filter.html b/adminlteui/templates/admin/filter.html index a8621ba..5402159 100644 --- a/adminlteui/templates/admin/filter.html +++ b/adminlteui/templates/admin/filter.html @@ -1,15 +1,29 @@ {% load i18n %}
- {% for choice in choices %} - {% if choice.name %} - - {% endif %} + {% if choice.name %} + + {% endif %} {% endfor %} + {% if spec.display_select2 %} + + {% endif %}
From 0ec6150e50bfd34767710b8701c765a1fd47a0b6 Mon Sep 17 00:00:00 2001 From: wuyue Date: Thu, 23 Jun 2022 10:39:34 +0800 Subject: [PATCH 3/5] add search_field_placeholder for search_fields --- adminlteui/admin.py | 2 ++ adminlteui/templates/admin/search_form.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/adminlteui/admin.py b/adminlteui/admin.py index ffb40b3..f008c3d 100644 --- a/adminlteui/admin.py +++ b/adminlteui/admin.py @@ -50,6 +50,7 @@ def get_image_box(): class ModelAdmin(admin.ModelAdmin): select2_list_filter = () + search_field_placeholder = '' class Media: css = { @@ -62,6 +63,7 @@ class Media: def changelist_view(self, request, extra_context=None): view = super().changelist_view(request, extra_context) cl = view.context_data.get('cl') + cl.search_field_placeholder = self.search_field_placeholder filter_specs = cl.filter_specs for index, filter_spec in enumerate(filter_specs): diff --git a/adminlteui/templates/admin/search_form.html b/adminlteui/templates/admin/search_form.html index ad66433..c13057a 100644 --- a/adminlteui/templates/admin/search_form.html +++ b/adminlteui/templates/admin/search_form.html @@ -12,7 +12,7 @@ {% if cl.search_fields %}
- +
{% endif %} {% if cl.has_filters or cl.search_fields %} From 67fff187456ecbbe1f7c320b3d1f39ba382f0110 Mon Sep 17 00:00:00 2001 From: wuyue Date: Thu, 23 Jun 2022 11:14:48 +0800 Subject: [PATCH 4/5] update ci/cd --- .github/workflows/main.yml | 6 ++++++ .travis.yml | 20 -------------------- 2 files changed, 6 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..f496b5d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,6 @@ +- name: Publish a Python distribution to PyPI + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.PYPI }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a0fb159..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: python -python: -- '3.6' -script: python setup.py install - -deploy: - provider: pypi - user: wuyue - password: - secure: ZIgyvPMWDL4sSAwT9b47iHF9HZPqloYqAG+q7l624uYtUZ8JVFBspUP3CGv1htrBVCeN6U5WZLodgFaosaT25PscUAgkVgQF7diyComRubx1HUG403yVr0SeRJTWHeDqz6jmQgjR1fSmXvM+Oho6lMILOUkPneHV3ZRmklnsxqT1mlOjf51ohjfmYd9/20KknH1ecqwa7dQ4OnbyLlrThKUzXE+AdwPrHO2hXP3nD+hUnVzZL+aCpMmnVmSrWIZUQ82LiQonxt0OdXUzgoyzSo0yRhmA4uUUUlSy4FZFE7oOEW1JmGwA3Tx32d55RXetzbQ+lWpfKHrkyQoj3lF0EE7+CMY3xpXz8UjFo4wSWH9KLWV4mTUSCHxVhG6jJ24LSesoCjPo8z9GPtbO8GUcOIW3HckKOitnfuV80xqp6BOFe69Zat8y/I4TOpomLjaOUHrYaFbmO2KEXb/rTVpTMDiWrkhT1i0JhEz4mHtzXHBFHGHTWtisW8nDaVUAW459tf/DXVUUD/szX/DYVawzn9IwLjKlOAMFJUJVzOfBRccPOklkfgEVMWcF4RUt2UZmKltxYWrhozUuJWjAXU6LGYROPjEbCdeV4TxowRoZp12vE3Hj2rpM0NYhhZg2qg08s1o4TB1VceFjmMBy54inoaVTyqRgqQPXaW3sT4FqzpQ= - skip_existing: true - skip_cleanup: true - on: - tag: true - all_branches: true - -branches: - except: - - develop - - master From f1c36d8c468d212c5efa61dafd36d69c45e294ec Mon Sep 17 00:00:00 2001 From: wuyue Date: Thu, 23 Jun 2022 11:53:22 +0800 Subject: [PATCH 5/5] update version to 1.7.0 --- .github/workflows/main.yml | 41 ++++++++++++++++++++++++++++++++------ README.md | 2 +- adminlteui/__init__.py | 2 +- docs/about.md | 6 ++++++ docs/guide.md | 33 ++++++++++++++++++++++++++++++ docs/index.md | 2 +- 6 files changed, 77 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f496b5d..484a1c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,35 @@ -- name: Publish a Python distribution to PyPI - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@v1.5.0 - with: - user: __token__ - password: ${{ secrets.PYPI }} \ No newline at end of file +name: main + +on: push + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@master + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + - name: Publish a Python distribution to PyPI + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@v1.5.0 + with: + user: __token__ + password: ${{ secrets.PYPI }} diff --git a/README.md b/README.md index 86725fd..8ca7a74 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ # django-adminlte-ui [![PyPI Version](https://img.shields.io/pypi/v/django-adminlte-ui.svg)](https://pypi.python.org/pypi/django-adminlte-ui) [![Download Status](https://img.shields.io/pypi/dm/django-adminlte-ui.svg)](https://pypi.python.org/pypi/django-adminlte-ui) -[![Build Status](https://api.travis-ci.org/wuyue92tree/django-adminlte-ui.svg)](https://travis-ci.org/wuyue92tree/django-adminlte-ui) +[![Build Status](https://github.com/wuyue92tree/django-adminlte-ui/workflows/main/badge.svg)](https://github.com/wuyue92tree/django-adminlte-ui/workflows/main/badge.svg) [![Documentation Status](https://readthedocs.org/projects/django-adminlte-ui/badge/?version=latest)](https://django-adminlte-ui.readthedocs.io/en/latest/?badge=latest) [![Gitter](https://badges.gitter.im/django-adminlte-ui/community.svg)](https://gitter.im/django-adminlte-ui/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) diff --git a/adminlteui/__init__.py b/adminlteui/__init__.py index bf8776e..1e00a3b 100644 --- a/adminlteui/__init__.py +++ b/adminlteui/__init__.py @@ -1,2 +1,2 @@ -version = '1.6.1' +version = '1.7.0' default_app_config = 'adminlteui.apps.AdminlteUIConfig' diff --git a/docs/about.md b/docs/about.md index d9b37ae..58834d4 100644 --- a/docs/about.md +++ b/docs/about.md @@ -1,5 +1,11 @@ # ChangeLog +## [v1.7.0](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/1.7.0) +- make previous & next button effective on change_list.html +- use select2 make admin filter searchable +- add search_field_placeholder for search_fields +- use `github actions` replace `travis` + ## [v1.6.1](https://github.com/wuyue92tree/django-adminlte-ui/releases/tag/1.6.1) - fix app in ADMINLTE_SETTINGS but current_user has not perm - fix model in ADMINLTE_SETTINGS but current_user has not perm diff --git a/docs/guide.md b/docs/guide.md index 0219765..f3cf120 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -50,6 +50,39 @@ before custom option, you should known what adminlte has used. - avatar_field - show_avatar +## ModelAdmin +- make change_list filter support select2 +- custom placeholder for search_fields + +```python +# adminlte/admin.py +class ModelAdmin(admin.ModelAdmin): + select2_list_filter = () + search_field_placeholder = '' + + class Media: + css = { + "all": ("admin/components/select2/dist/css/select2.min.css",) + } + js = ( + "admin/components/select2/dist/js/select2.min.js", + ) + + def changelist_view(self, request, extra_context=None): + view = super().changelist_view(request, extra_context) + cl = view.context_data.get('cl') + cl.search_field_placeholder = self.search_field_placeholder + filter_specs = cl.filter_specs + + for index, filter_spec in enumerate(filter_specs): + if filter_spec.field_path in self.select2_list_filter: + # flag to use select2 + filter_spec.display_select2 = True + cl.filter_specs[index] = filter_spec + view.context_data['cl'] = cl + return view +``` + ## Widgets ### AdminlteSelect diff --git a/docs/index.md b/docs/index.md index ea091cc..61cd812 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ [![PyPI Version](https://img.shields.io/pypi/v/django-adminlte-ui.svg)](https://pypi.python.org/pypi/django-adminlte-ui) [![Download Status](https://img.shields.io/pypi/dm/django-adminlte-ui.svg)](https://pypi.python.org/pypi/django-adminlte-ui) -[![Build Status](https://api.travis-ci.org/wuyue92tree/django-adminlte-ui.svg)](https://travis-ci.org/wuyue92tree/django-adminlte-ui) +[![Build Status](https://github.com/wuyue92tree/django-adminlte-ui/workflows/main/badge.svg)](https://github.com/wuyue92tree/django-adminlte-ui/workflows/main/badge.svg) [![Gitter](https://badges.gitter.im/django-adminlte-ui/community.svg)](https://gitter.im/django-adminlte-ui/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)