diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-admin-totals.spec | 235 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 237 insertions, 0 deletions
@@ -0,0 +1 @@ +/admin-totals-1.0.1.tar.gz diff --git a/python-admin-totals.spec b/python-admin-totals.spec new file mode 100644 index 0000000..5905025 --- /dev/null +++ b/python-admin-totals.spec @@ -0,0 +1,235 @@ +%global _empty_manifest_terminate_build 0 +Name: python-admin-totals +Version: 1.0.1 +Release: 1 +Summary: Django Admin Totals, add totals to your columns in Django admin. +License: GNU General Public License v2 (GPLv2) +URL: https://github.com/douwevandermeij/admin-totals +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5d/aa/79adcb8ea873b690ba9f286d0c6439f832df381f00cab3c9a02ed141f4d8/admin-totals-1.0.1.tar.gz +BuildArch: noarch + +Requires: python3-Django + +%description +# Django Admin Totals + +Module to show totals in Django Admin List. + +[](https://codecov.io/gh/douwevandermeij/admin-totals) +[](https://travis-ci.org/douwevandermeij/admin-totals) + +## Installation + + virtualenv . + source bin/activate + pip install admin-totals + +Or + + pip install git+https://github.com/douwevandermeij/admin-totals.git + +## Usage + +In settings.py +```python +INSTALLED_APPS = [ + 'admin_totals', +] +``` +In admin.py: +```python +from admin_totals.admin import ModelAdminTotals +from django.contrib import admin +from django.db.models import Sum, Avg +from django.db.models.functions import Coalesce + +@admin.register(MyModel) +class MyModelAdmin(ModelAdminTotals): + list_display = ['col_a', 'col_b', 'col_c'] + list_totals = [('col_b', lambda field: Coalesce(Sum(field), 0)), ('col_c', Avg)] +``` +Make sure to at least have the columns of `list_totals` in `list_display`. + +## Tests + + python runtests.py + +## Contributing + +Please make sure to run the following commands before pushing and making a PR: + + pip install -r requirements/test-ci.txt + isort --recursive admin_totals tests + flake8 + +`isort` will sort the imports and `flake8` will lint the code. Please fix any errors before committing. Also, make sure to write passing tests. + + + + +%package -n python3-admin-totals +Summary: Django Admin Totals, add totals to your columns in Django admin. +Provides: python-admin-totals +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-admin-totals +# Django Admin Totals + +Module to show totals in Django Admin List. + +[](https://codecov.io/gh/douwevandermeij/admin-totals) +[](https://travis-ci.org/douwevandermeij/admin-totals) + +## Installation + + virtualenv . + source bin/activate + pip install admin-totals + +Or + + pip install git+https://github.com/douwevandermeij/admin-totals.git + +## Usage + +In settings.py +```python +INSTALLED_APPS = [ + 'admin_totals', +] +``` +In admin.py: +```python +from admin_totals.admin import ModelAdminTotals +from django.contrib import admin +from django.db.models import Sum, Avg +from django.db.models.functions import Coalesce + +@admin.register(MyModel) +class MyModelAdmin(ModelAdminTotals): + list_display = ['col_a', 'col_b', 'col_c'] + list_totals = [('col_b', lambda field: Coalesce(Sum(field), 0)), ('col_c', Avg)] +``` +Make sure to at least have the columns of `list_totals` in `list_display`. + +## Tests + + python runtests.py + +## Contributing + +Please make sure to run the following commands before pushing and making a PR: + + pip install -r requirements/test-ci.txt + isort --recursive admin_totals tests + flake8 + +`isort` will sort the imports and `flake8` will lint the code. Please fix any errors before committing. Also, make sure to write passing tests. + + + + +%package help +Summary: Development documents and examples for admin-totals +Provides: python3-admin-totals-doc +%description help +# Django Admin Totals + +Module to show totals in Django Admin List. + +[](https://codecov.io/gh/douwevandermeij/admin-totals) +[](https://travis-ci.org/douwevandermeij/admin-totals) + +## Installation + + virtualenv . + source bin/activate + pip install admin-totals + +Or + + pip install git+https://github.com/douwevandermeij/admin-totals.git + +## Usage + +In settings.py +```python +INSTALLED_APPS = [ + 'admin_totals', +] +``` +In admin.py: +```python +from admin_totals.admin import ModelAdminTotals +from django.contrib import admin +from django.db.models import Sum, Avg +from django.db.models.functions import Coalesce + +@admin.register(MyModel) +class MyModelAdmin(ModelAdminTotals): + list_display = ['col_a', 'col_b', 'col_c'] + list_totals = [('col_b', lambda field: Coalesce(Sum(field), 0)), ('col_c', Avg)] +``` +Make sure to at least have the columns of `list_totals` in `list_display`. + +## Tests + + python runtests.py + +## Contributing + +Please make sure to run the following commands before pushing and making a PR: + + pip install -r requirements/test-ci.txt + isort --recursive admin_totals tests + flake8 + +`isort` will sort the imports and `flake8` will lint the code. Please fix any errors before committing. Also, make sure to write passing tests. + + + + +%prep +%autosetup -n admin-totals-1.0.1 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-admin-totals -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.1-1 +- Package Spec generated @@ -0,0 +1 @@ +90bdb8438897b6cdfbfd4179a3e9df4f admin-totals-1.0.1.tar.gz |