polyadmin 0.1.0b3__tar.gz → 0.1.0b6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/PKG-INFO +3 -1
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/browsertests/test_flows.py +175 -3
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/browsertests/test_i18n.py +4 -1
- polyadmin-0.1.0b6/docs/bulk-edit.md +95 -0
- polyadmin-0.1.0b6/docs/dashboard.md +325 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/lists.md +5 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/model-admin.md +89 -1
- polyadmin-0.1.0b6/docs/sqlalchemy.md +47 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/main.py +89 -4
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/tests/test_app.py +58 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/user_admin.py +22 -3
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/mkdocs.yml +3 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/__init__.py +4 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/action.py +92 -8
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/admin.py +3 -0
- polyadmin-0.1.0b6/polyadmin/core/dashboard.py +231 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/filter.py +30 -25
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/model_admin.py +88 -11
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/template_context.py +68 -3
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/widget.py +230 -8
- polyadmin-0.1.0b6/polyadmin/fastapi/action_forms.py +237 -0
- polyadmin-0.1.0b6/polyadmin/fastapi/dashboard.py +175 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/deletes.py +18 -12
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/handlers.py +117 -68
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/responses.py +18 -1
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/router.py +10 -18
- polyadmin-0.1.0b6/polyadmin/locale/fr/LC_MESSAGES/polyadmin.mo +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/locale/fr/LC_MESSAGES/polyadmin.po +46 -13
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/locale/polyadmin.pot +46 -4
- polyadmin-0.1.0b6/polyadmin/locale/ru/LC_MESSAGES/polyadmin.mo +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/locale/ru/LC_MESSAGES/polyadmin.po +48 -13
- polyadmin-0.1.0b6/polyadmin/sqlalchemy/__init__.py +3 -0
- polyadmin-0.1.0b6/polyadmin/sqlalchemy/columns.py +91 -0
- polyadmin-0.1.0b6/polyadmin/sqlalchemy/filters.py +99 -0
- polyadmin-0.1.0b6/polyadmin/sqlalchemy/model_admin.py +201 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/components/bulk_edit_row.html +15 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/components/dashboard_filters.html +24 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/icons.html +3 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/calendar.html +17 -19
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/combobox.html +1 -1
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/filter-panel.html +7 -1
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/select.html +48 -5
- polyadmin-0.1.0b6/polyadmin/templates/admin/components/widget_body.html +15 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/components/widget_card.html +38 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/dashboard.html +35 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/resource/action_form.html +60 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/widgets/data_table.html +20 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/widgets/data_table_rows.html +16 -0
- polyadmin-0.1.0b6/polyadmin/templates/admin/widgets/metric_group.html +13 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/tabs.html +1 -1
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templating.py +119 -1
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/ui.py +4 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/pyproject.toml +6 -1
- polyadmin-0.1.0b6/tests/core/test_action_form.py +96 -0
- polyadmin-0.1.0b6/tests/core/test_bulk_edit.py +93 -0
- polyadmin-0.1.0b6/tests/core/test_dashboard_filters.py +141 -0
- polyadmin-0.1.0b6/tests/core/test_dashboard_widgets.py +113 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_filter.py +17 -0
- polyadmin-0.1.0b6/tests/fastapi/test_action_downloads.py +76 -0
- polyadmin-0.1.0b6/tests/fastapi/test_action_error.py +91 -0
- polyadmin-0.1.0b6/tests/fastapi/test_action_forms.py +199 -0
- polyadmin-0.1.0b6/tests/fastapi/test_bulk_edit.py +144 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_components.py +6 -2
- polyadmin-0.1.0b6/tests/fastapi/test_dashboard_export.py +59 -0
- polyadmin-0.1.0b6/tests/fastapi/test_dashboard_lazy.py +245 -0
- polyadmin-0.1.0b6/tests/fastapi/test_record_form_error.py +41 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/__init__.py +0 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/models.py +91 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/test_bulk.py +103 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/test_default_filters_http.py +35 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/test_filters.py +74 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/test_hardening.py +53 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/test_list_page.py +90 -0
- polyadmin-0.1.0b6/tests/sqlalchemy/test_writes.py +121 -0
- polyadmin-0.1.0b6/tests/test_data_cell.py +66 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/test_layout.py +8 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/uv.lock +178 -2
- polyadmin-0.1.0b3/docs/dashboard.md +0 -148
- polyadmin-0.1.0b3/polyadmin/core/dashboard.py +0 -41
- polyadmin-0.1.0b3/polyadmin/locale/fr/LC_MESSAGES/polyadmin.mo +0 -0
- polyadmin-0.1.0b3/polyadmin/locale/ru/LC_MESSAGES/polyadmin.mo +0 -0
- polyadmin-0.1.0b3/polyadmin/templates/admin/dashboard.html +0 -35
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/.github/workflows/notify-docs.yml +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/.github/workflows/publish.yml +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/.gitignore +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/LICENSE +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/README.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/babel.cfg +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/browsertests/README.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/browsertests/conftest.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/browsertests/test_deletes.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/browsertests/test_parity.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/architecture.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/audit.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/authentication.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/components.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/concepts/architecture.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/concepts/model-admin.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/deletes.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/exports.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/i18n.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/inlines.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/permissions.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/python/index.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/routing.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/docs/templates.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/README.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/README.md +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/models.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/organization_admin.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/pages.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/pyproject.toml +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/role_admin.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/session.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/templates/pages/broadcast.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/examples/fastapi/uv.lock +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/__init__.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/_async.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/audit.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/auth.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/authorization.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/csrf.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/delete.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/exporter.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/field.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/inline.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/login.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/page.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/pagination.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/query.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/relation.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/core/slug.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/__init__.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/audit.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/auth.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/csrf.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/errors.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/inlines.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/locale.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/login.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/pages.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/relations.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/fastapi/static.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/i18n/__init__.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/i18n/context.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/i18n/negotiation.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/i18n/setup.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/i18n/translator.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/base.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/action_confirm_modal.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/csrf-field.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/error_fragment.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/field.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/form_wrapper.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/inline.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/inline_fragment.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/list_content.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/lookup_results.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/search.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/toasts.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/breadcrumb.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/bulk-actions.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/delete-preview.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/dropdown-menu.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/field.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/locale-switcher.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/multi-select.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/pagination.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/radio-group.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/sidebar.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/slider.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/switch.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/table.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/components/ui/theme-toggle.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/error.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/login.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/resource/delete.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/resource/delete_selected.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/resource/detail.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/resource/form.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/resource/list.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/theme.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/activity.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/chart.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/donut.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/metric.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/progress.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/stat.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/table.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/polyadmin/templates/admin/widgets/timeline.html +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/__init__.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/conftest.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/__init__.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/mo.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_action_decorator.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_action_placement.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_admin.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_async.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_auth.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_authorization.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_csrf.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_dashboard.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_delete.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_delete_selected_i18n.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_exporter.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_field.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_i18n.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_inline.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_login.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_model_admin.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_pagination.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_parity.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_query.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_relation.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_template_context.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/core/test_widget.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/__init__.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_action_placement.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_actions.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_async_model_admin.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_async_relations.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_audit.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_auth.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_code_strings.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_csrf.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_dashboard.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_delete_preview.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_delete_selected.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_delete_selected_preview.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_errors.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_export.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_favicon.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_filters.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_htmx.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_inlines.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_list_querier.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_listopts.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_locale.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_login.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_pages.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_parity_list.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_pseudo_locale.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_relations.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_router.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_scroll_area.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_switcher.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/fastapi/test_theme.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/test_catalogs.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/test_format.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/test_templating.py +0 -0
- {polyadmin-0.1.0b3 → polyadmin-0.1.0b6}/tests/test_ui.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: polyadmin
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0b6
|
|
4
4
|
Summary: PolyAdmin: cross-language server-rendered admin framework (Python core)
|
|
5
5
|
Project-URL: Documentation, https://magicrodri.github.io/polyadmin-docs/
|
|
6
6
|
Project-URL: Source, https://github.com/MagicRodri/polyadmin
|
|
@@ -26,6 +26,8 @@ Requires-Dist: openpyxl>=3.1; extra == 'export-xlsx'
|
|
|
26
26
|
Provides-Extra: fastapi
|
|
27
27
|
Requires-Dist: fastapi>=0.110; extra == 'fastapi'
|
|
28
28
|
Requires-Dist: python-multipart>=0.0.9; extra == 'fastapi'
|
|
29
|
+
Provides-Extra: sqlalchemy
|
|
30
|
+
Requires-Dist: sqlalchemy[asyncio]>=2.0; extra == 'sqlalchemy'
|
|
29
31
|
Description-Content-Type: text/markdown
|
|
30
32
|
|
|
31
33
|
# PolyAdmin
|
|
@@ -349,16 +349,31 @@ def test_filtering_by_a_related_record(admin_page):
|
|
|
349
349
|
trigger = panel.locator('input[role="combobox"]').first
|
|
350
350
|
expect(trigger).to_be_visible()
|
|
351
351
|
trigger.click()
|
|
352
|
+
# Before typing: the unfiltered page includes an organization "Acme"
|
|
353
|
+
# would never match, so the assertions below only pass once /lookup
|
|
354
|
+
# actually narrows to the typed query (the combobox's text input has
|
|
355
|
+
# to carry its value as the request's own "q" for that to happen --
|
|
356
|
+
# a bug here previously left every keystroke re-fetching the same
|
|
357
|
+
# unfiltered list, which "an option is visible" alone would not catch).
|
|
358
|
+
expect(admin_page.locator('[role="listbox"]', has_text="Widgets Inc")).to_be_visible()
|
|
352
359
|
# Typed, not filled: the lookup fires on keyup (hx-trigger), and
|
|
353
360
|
# fill() sets the value without dispatching one.
|
|
354
361
|
trigger.press_sequentially("Acme", delay=30)
|
|
355
|
-
|
|
356
|
-
expect(
|
|
357
|
-
|
|
362
|
+
options = admin_page.locator('[role="listbox"] [data-pk]')
|
|
363
|
+
expect(options.first).to_be_visible()
|
|
364
|
+
expect(admin_page.locator('[role="listbox"]', has_text="Widgets Inc")).to_have_count(0)
|
|
365
|
+
for label in options.all_inner_texts():
|
|
366
|
+
assert "acme" in label.lower(), f"unfiltered result leaked through: {label!r}"
|
|
367
|
+
options.first.click()
|
|
358
368
|
panel.locator('button[type="submit"]').first.click()
|
|
359
369
|
|
|
360
370
|
expect(admin_page).to_have_url(re.compile(r"filter"))
|
|
361
371
|
expect(admin_page.locator("table tbody tr").first).to_be_visible()
|
|
372
|
+
# The combobox's text input rides in the same form Apply submits
|
|
373
|
+
# natively (hx-disinherit isolates its own /lookup wiring, not this).
|
|
374
|
+
# Without the form's own hx-params="not q" excluding it, the search
|
|
375
|
+
# text tags along into this URL as a stray, meaningless ?q=Acme.
|
|
376
|
+
assert "q=" not in admin_page.url, f"combobox search text leaked into the URL: {admin_page.url}"
|
|
362
377
|
|
|
363
378
|
|
|
364
379
|
def test_the_filter_panel_combobox_is_not_clipped(admin_page):
|
|
@@ -417,3 +432,160 @@ def test_detail_page_offers_only_the_allowlisted_actions(admin_page):
|
|
|
417
432
|
expect(admin_page.get_by_role("button", name="Deactivate")).to_be_visible()
|
|
418
433
|
expect(admin_page.get_by_role("button", name="Activate", exact=True)).to_have_count(0)
|
|
419
434
|
expect(admin_page.get_by_role("button", name="Delete selected")).to_have_count(0)
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
def _run_bulk_action(page, email, label):
|
|
438
|
+
rows = rows_matching(page, email)
|
|
439
|
+
expect(rows).to_have_count(1)
|
|
440
|
+
rows.locator('input[type="checkbox"]').check()
|
|
441
|
+
page.locator("#bulk-actions-form button").click()
|
|
442
|
+
page.get_by_role("option", name=label).click()
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def test_bulk_edit_changes_only_the_ticked_field(admin_page):
|
|
446
|
+
email = unique_email()
|
|
447
|
+
create_user(admin_page, email)
|
|
448
|
+
_run_bulk_action(admin_page, email, "Edit selected")
|
|
449
|
+
|
|
450
|
+
form = admin_page.locator("#action-form")
|
|
451
|
+
expect(form).to_be_visible()
|
|
452
|
+
plan_row = form.locator("fieldset").filter(has=admin_page.locator('[name="plan"]'))
|
|
453
|
+
plan_control = plan_row.locator("[x-data*='adminSelect'] button").first
|
|
454
|
+
expect(plan_control).to_be_disabled()
|
|
455
|
+
form.locator('input[name="_change_plan"]').check()
|
|
456
|
+
expect(plan_control).to_be_enabled()
|
|
457
|
+
plan_control.click()
|
|
458
|
+
admin_page.get_by_role("option", name="Enterprise").click()
|
|
459
|
+
admin_page.locator("#action-form-submit").click()
|
|
460
|
+
|
|
461
|
+
expect(admin_page.locator("body > ol[aria-label] > li")).to_have_count(1)
|
|
462
|
+
expect(rows_matching(admin_page, email).first).to_contain_text("Enterprise")
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
def test_action_form_relation_picker_assigns_an_organization(admin_page):
|
|
466
|
+
email = unique_email()
|
|
467
|
+
create_user(admin_page, email)
|
|
468
|
+
_run_bulk_action(admin_page, email, "Assign organization")
|
|
469
|
+
|
|
470
|
+
trigger = admin_page.locator('#action-form input[role="combobox"]').first
|
|
471
|
+
trigger.click()
|
|
472
|
+
trigger.press_sequentially("Acme", delay=30)
|
|
473
|
+
option = admin_page.locator('[role="listbox"] [data-pk]').first
|
|
474
|
+
expect(option).to_be_visible()
|
|
475
|
+
option.click()
|
|
476
|
+
admin_page.locator("#action-form-submit").click()
|
|
477
|
+
|
|
478
|
+
expect(admin_page.locator("body > ol[aria-label] > li").first).to_contain_text("Assigned 1 user(s)")
|
|
479
|
+
expect(rows_matching(admin_page, email).first).to_contain_text("Acme")
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
def test_download_action_saves_a_file(admin_page):
|
|
483
|
+
email = unique_email()
|
|
484
|
+
create_user(admin_page, email)
|
|
485
|
+
rows = rows_matching(admin_page, email)
|
|
486
|
+
rows.locator('input[type="checkbox"]').check()
|
|
487
|
+
admin_page.locator("#bulk-actions-form button").click()
|
|
488
|
+
with admin_page.expect_download() as info:
|
|
489
|
+
admin_page.get_by_role("option", name="Export emails").click()
|
|
490
|
+
download = info.value
|
|
491
|
+
assert download.suggested_filename == "users.csv"
|
|
492
|
+
with open(download.path()) as f:
|
|
493
|
+
assert email in f.read()
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
def test_dashboard_widgets_load_lazily(admin_page):
|
|
497
|
+
admin_page.goto(ADMIN_URL)
|
|
498
|
+
expect(admin_page.locator("#widget-body-overview [data-tile]")).to_have_count(4)
|
|
499
|
+
expect(admin_page.locator("#widget-body-users [data-row]").first).to_be_visible()
|
|
500
|
+
expect(admin_page.locator('#widget-body-billing [data-widget-state="unavailable"]')).to_be_visible()
|
|
501
|
+
|
|
502
|
+
|
|
503
|
+
def test_changing_the_organization_reloads_only_dependent_widgets(admin_page):
|
|
504
|
+
admin_page.goto(ADMIN_URL)
|
|
505
|
+
expect(admin_page.locator("#widget-body-organizations [data-row]").first).to_be_visible()
|
|
506
|
+
admin_page.evaluate("el => el.dataset.probe = 'kept'", admin_page.locator("#widget-body-organizations [data-row]").first.element_handle())
|
|
507
|
+
trigger = admin_page.locator('[data-dashboard-filter="organization"] [x-data*="adminSelect"] button').first
|
|
508
|
+
trigger.click()
|
|
509
|
+
admin_page.get_by_role("option").nth(1).click()
|
|
510
|
+
expect(admin_page).to_have_url(re.compile(r"organization="))
|
|
511
|
+
expect(admin_page.locator("#widget-body-organizations [data-row]").first).to_have_attribute("data-probe", "kept")
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
def test_scrolling_the_users_table_appends_rows(admin_page):
|
|
515
|
+
admin_page.goto(ADMIN_URL)
|
|
516
|
+
rows = admin_page.locator("#widget-body-users [data-row]")
|
|
517
|
+
expect(rows.first).to_be_visible()
|
|
518
|
+
first_count = rows.count()
|
|
519
|
+
admin_page.locator("#widget-body-users [data-next-page]").scroll_into_view_if_needed()
|
|
520
|
+
expect(rows).not_to_have_count(first_count)
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
def test_searching_narrows_the_users_table(admin_page):
|
|
524
|
+
admin_page.goto(ADMIN_URL)
|
|
525
|
+
admin_page.locator("#widget-search-users").fill("user100")
|
|
526
|
+
expect(admin_page.locator("#widget-body-users [data-row]")).to_have_count(1)
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def test_dashboard_export_downloads_a_file(admin_page):
|
|
530
|
+
admin_page.goto(ADMIN_URL)
|
|
531
|
+
with admin_page.expect_download() as info:
|
|
532
|
+
admin_page.locator('[data-dashboard-export="users-csv"]').click()
|
|
533
|
+
assert info.value.suggested_filename == "users.csv"
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
def test_scrolling_inside_the_users_card_appends_rows(admin_page):
|
|
537
|
+
admin_page.goto(ADMIN_URL)
|
|
538
|
+
rows = admin_page.locator("#widget-body-users [data-row]")
|
|
539
|
+
expect(rows.first).to_be_visible()
|
|
540
|
+
first_count = rows.count()
|
|
541
|
+
admin_page.locator("#widget-users").scroll_into_view_if_needed()
|
|
542
|
+
admin_page.wait_for_timeout(500)
|
|
543
|
+
assert rows.count() == first_count, "the next page loaded before the table was scrolled"
|
|
544
|
+
admin_page.evaluate(
|
|
545
|
+
"() => { const body = document.querySelector('#widget-body-users'); body.scrollTop = body.scrollHeight; }"
|
|
546
|
+
)
|
|
547
|
+
expect(rows).not_to_have_count(first_count, timeout=3000)
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
def test_the_overview_sits_above_the_filters_without_a_header(admin_page):
|
|
551
|
+
admin_page.goto(ADMIN_URL)
|
|
552
|
+
overview = admin_page.locator('[data-placement="top"]#widget-overview')
|
|
553
|
+
expect(overview.locator("[data-tile]")).to_have_count(4)
|
|
554
|
+
expect(overview.locator("h2")).to_have_count(0)
|
|
555
|
+
assert overview.bounding_box()["y"] < admin_page.locator("#dashboard-filters").bounding_box()["y"]
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
def test_clicking_a_date_field_opens_the_calendar_and_typing_still_works(admin_page):
|
|
559
|
+
admin_page.goto(ADMIN_URL)
|
|
560
|
+
period = admin_page.locator('[data-dashboard-filter="period"]')
|
|
561
|
+
expect(period.locator('button[aria-label="Open calendar"]')).to_have_count(0)
|
|
562
|
+
field = period.locator('input[type="date"]').first
|
|
563
|
+
field.click()
|
|
564
|
+
grid = period.locator('[role="grid"]').first
|
|
565
|
+
expect(grid).to_be_visible()
|
|
566
|
+
assert grid.bounding_box()["width"] >= 220, grid.bounding_box()
|
|
567
|
+
admin_page.keyboard.press("Escape")
|
|
568
|
+
expect(grid).to_be_hidden()
|
|
569
|
+
field.click(position={"x": 16, "y": 12})
|
|
570
|
+
admin_page.keyboard.type("01152026")
|
|
571
|
+
expect(field).to_have_value("2026-01-15")
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
def test_the_organization_filter_is_searchable(admin_page):
|
|
575
|
+
admin_page.goto(ADMIN_URL)
|
|
576
|
+
trigger = admin_page.locator('[data-dashboard-filter="organization"] [x-data*="adminSelect"] button').first
|
|
577
|
+
trigger.click()
|
|
578
|
+
search = admin_page.locator('[role="listbox"] input[x-ref="search"]:visible')
|
|
579
|
+
expect(search).to_be_focused()
|
|
580
|
+
search.click()
|
|
581
|
+
expect(search).to_be_visible()
|
|
582
|
+
options = admin_page.locator('[role="listbox"] [role="option"]:visible')
|
|
583
|
+
before = options.count()
|
|
584
|
+
admin_page.keyboard.type("glob")
|
|
585
|
+
expect(options.first).to_contain_text("Globex")
|
|
586
|
+
matches = options.all_inner_texts()
|
|
587
|
+
assert 0 < len(matches) < before, (len(matches), before)
|
|
588
|
+
assert all("glob" in text.lower() for text in matches), matches
|
|
589
|
+
admin_page.keyboard.press("Enter")
|
|
590
|
+
expect(admin_page).to_have_url(re.compile(r"organization=\d+"))
|
|
591
|
+
expect(trigger).to_contain_text(matches[0])
|
|
@@ -34,6 +34,9 @@ ALLOWED = re.compile(
|
|
|
34
34
|
rf"|^(?:{ROLES})(?:, (?:{ROLES}))*$"
|
|
35
35
|
r"|^(?:Demo Admin|Demo Viewer|Amélie)$"
|
|
36
36
|
r"|^(?:Active|Inactive|Account created|user #\d+)$"
|
|
37
|
+
# The dashboard's example rows and tiles (main.py / dashboard.go).
|
|
38
|
+
r"|^(?:yes|no|All|active: \d+)$"
|
|
39
|
+
r"|^The billing service is not configured in this demo\.$"
|
|
37
40
|
r"|^(?:English|Français|Русский|Pseudo \(en-XA\))$"
|
|
38
41
|
r"|^[A-Z]{1,2}$"
|
|
39
42
|
r"|^\W*\d[\d\s.,:/-]*\W*$"
|
|
@@ -116,7 +119,7 @@ def test_date_picker_weekdays_are_french_under_fr(browser):
|
|
|
116
119
|
page = context.new_page()
|
|
117
120
|
_sign_in(page, SUPERUSER)
|
|
118
121
|
page.goto(f"{ADMIN_URL}/organizations/1/edit")
|
|
119
|
-
page.
|
|
122
|
+
page.locator('[x-data="adminCalendar()"] input[type="date"]').first.click()
|
|
120
123
|
weekdays = page.locator('[x-data="adminCalendar()"] [role="columnheader"]')
|
|
121
124
|
expect(weekdays.first).to_have_text(re.compile(r"^lun\.?$"))
|
|
122
125
|
expect(weekdays.last).to_have_text(re.compile(r"^dim\.?$"))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Bulk editing
|
|
2
|
+
|
|
3
|
+
A ModelAdmin that lists `bulk_edit_fields` gets an **Edit selected** action
|
|
4
|
+
on its list page. It changes the same fields on every selected record in one
|
|
5
|
+
go:
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
class UserAdmin(ModelAdmin):
|
|
9
|
+
form_fields = ["email", "is_active", "plan", "organization"]
|
|
10
|
+
bulk_edit_fields = ["is_active", "plan", "organization"]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Each name must be one of the form fields and not in `readonly_fields`; a
|
|
14
|
+
wrong name fails when the `Admin` is built. The action is offered only when
|
|
15
|
+
`can_update` is true, and it requires the `{slug}.update` permission on top
|
|
16
|
+
of `.view`. It is a list-only action: it never appears on a detail page, even
|
|
17
|
+
when named in `detail_actions`.
|
|
18
|
+
|
|
19
|
+
## The form
|
|
20
|
+
|
|
21
|
+
Picking **Edit selected** opens a form with one row per field, using the
|
|
22
|
+
field's own widget — the same select, switch or relation picker the edit form
|
|
23
|
+
shows, including `autocomplete_fields`. Each row has a **Change** checkbox,
|
|
24
|
+
and the field stays disabled until it is ticked. Only ticked fields are
|
|
25
|
+
parsed, validated and applied; a row left unticked is ignored even when a
|
|
26
|
+
value is posted for it. Submitting with nothing ticked redisplays the form
|
|
27
|
+
with "Choose at least one field to change."
|
|
28
|
+
|
|
29
|
+
## `update` receives only the ticked fields
|
|
30
|
+
|
|
31
|
+
The default implementation calls your ModelAdmin's own `update(obj, data)`
|
|
32
|
+
once per record, with `data` holding **only the ticked fields** — a PATCH,
|
|
33
|
+
not the full form the edit page posts. An `update` that reads every key and
|
|
34
|
+
writes what it finds would clear the fields nobody touched:
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
def update(self, obj, data):
|
|
38
|
+
obj.plan = data.get("plan") # wipes plan when it was not ticked
|
|
39
|
+
if "plan" in data: # keeps it
|
|
40
|
+
obj.plan = data["plan"]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Write `update` so that a missing key leaves the value as it is. The edit form
|
|
44
|
+
already omits read-only fields, so an `update` that handles that is most of
|
|
45
|
+
the way there.
|
|
46
|
+
|
|
47
|
+
## One call instead of N
|
|
48
|
+
|
|
49
|
+
Override `bulk_update` to apply the change in a single call, for example to a
|
|
50
|
+
backend's bulk endpoint:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
class EmployeeAdmin(ModelAdmin):
|
|
54
|
+
bulk_edit_fields = ["group"]
|
|
55
|
+
|
|
56
|
+
async def bulk_update(self, objects, data, principal):
|
|
57
|
+
await self.client.patch("/employees", json={"ids": [o.id for o in objects], **data})
|
|
58
|
+
return f"Updated {len(objects)} employee(s)."
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The return value is the success message, as for any action.
|
|
62
|
+
|
|
63
|
+
## All or nothing
|
|
64
|
+
|
|
65
|
+
Before anything is applied, every selected record is checked: the
|
|
66
|
+
authorizer must allow `{slug}.update` on that record, and none of the ticked
|
|
67
|
+
fields may be read-only for it (`get_readonly_fields(obj)`). If any record
|
|
68
|
+
fails either check, nothing is changed and the form lists the records that
|
|
69
|
+
blocked it.
|
|
70
|
+
|
|
71
|
+
The default loop stops at the first record whose `update` raises and reports
|
|
72
|
+
how far it got — "Updated 3 of 10, then failed: …" — the same way the bulk
|
|
73
|
+
delete does. Records before the failure keep their change; there is no
|
|
74
|
+
transaction to roll back. Override `bulk_update` when your storage can do
|
|
75
|
+
better.
|
|
76
|
+
|
|
77
|
+
## Audit log
|
|
78
|
+
|
|
79
|
+
Each record gets an ordinary `update` entry, the same as saving it from its
|
|
80
|
+
edit page (see [`audit.md`](audit.md)).
|
|
81
|
+
|
|
82
|
+
## Replacing the built-in
|
|
83
|
+
|
|
84
|
+
`bulk_edit` is a method on `ModelAdmin` decorated with `@action`, like
|
|
85
|
+
`delete_selected`. Override it to change its label or behaviour, and repeat
|
|
86
|
+
the decorator to keep it a form action:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
class UserAdmin(ModelAdmin):
|
|
90
|
+
bulk_edit_fields = ["plan"]
|
|
91
|
+
|
|
92
|
+
@action(label="Change plan", form=lambda ma: ma.get_bulk_edit_form(), permission="update", where="list")
|
|
93
|
+
async def bulk_edit(self, objects, principal, data):
|
|
94
|
+
...
|
|
95
|
+
```
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Dashboard
|
|
2
|
+
|
|
3
|
+
`Dashboard` renders at `GET {base_path}` — it's independent of any one
|
|
4
|
+
`ModelAdmin`, just a titled collection of `Widget`s.
|
|
5
|
+
|
|
6
|
+
```python
|
|
7
|
+
from polyadmin.core.dashboard import Dashboard
|
|
8
|
+
from polyadmin.core.widget import Metric, Donut, Table
|
|
9
|
+
|
|
10
|
+
dashboard = Dashboard(title="Overview", widgets=[
|
|
11
|
+
Metric("Users", get_value=lambda: len(users.list())),
|
|
12
|
+
Donut("Users by status", get_series=lambda: [
|
|
13
|
+
("Active", sum(1 for u in users.list() if u.is_active)),
|
|
14
|
+
("Inactive", sum(1 for u in users.list() if not u.is_active)),
|
|
15
|
+
]),
|
|
16
|
+
])
|
|
17
|
+
admin = Admin(model_admins=[...], dashboard=dashboard)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Every widget computes its own data lazily (`get_value`/`get_series`/
|
|
21
|
+
`get_rows`/`get_entries` callables) — nothing is computed until the
|
|
22
|
+
dashboard route actually renders, so a widget backed by a slow query
|
|
23
|
+
only pays that cost on page load, not at `Dashboard` construction time.
|
|
24
|
+
|
|
25
|
+
## How tall a card gets
|
|
26
|
+
|
|
27
|
+
The dashboard is a grid, and a grid stretches every card in a row to
|
|
28
|
+
match the tallest one. So a card's content area is bounded rather than
|
|
29
|
+
free to grow: past about 320px it scrolls inside its own card, with the
|
|
30
|
+
same themed scrollbar the rest of the admin uses. A `Table` of two
|
|
31
|
+
hundred rows leaves the cards beside it exactly where they were.
|
|
32
|
+
|
|
33
|
+
It scrolls in one direction only. A card is a fixed column of the grid,
|
|
34
|
+
so anything wider than it is a widget that has to wrap, not a sideways
|
|
35
|
+
scrollbar for the reader to drag — `widgets/table.html` wraps its cells
|
|
36
|
+
(and breaks a long unbroken value) rather than holding them on one
|
|
37
|
+
line.
|
|
38
|
+
|
|
39
|
+
This applies to a custom widget's template too — it renders inside that
|
|
40
|
+
box and needs no overflow container of its own. A second scroller
|
|
41
|
+
nested in there shows a second scrollbar, and content that bleeds past
|
|
42
|
+
the box's edge, as a negative margin does, is clipped.
|
|
43
|
+
|
|
44
|
+
## Built-in widget types
|
|
45
|
+
|
|
46
|
+
| Widget | Shows | Constructor |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| Metric | A single headline number | `Metric(title, get_value=...)` |
|
|
49
|
+
| Stat | A headline number *and* its change vs. the previous period | `Stat(title, get_stat=...)` → `(value, delta)` |
|
|
50
|
+
| Progress | A value against a target, as a bar | `Progress(title, get_data=...)` → `(value, target)` |
|
|
51
|
+
| Chart | Labeled values as horizontal CSS bars | `Chart(title, get_series=...)` → `[(label, value), ...]` |
|
|
52
|
+
| Donut | A share-of-total breakdown, as an SVG ring + legend | `Donut(title, get_series=...)` → `[(label, value), ...]` |
|
|
53
|
+
| Table | Small tabular data | `Table(title, columns=[...], get_rows=...)` |
|
|
54
|
+
| Activity | A recent-activity feed (short text entries) | `Activity(title, get_entries=...)` |
|
|
55
|
+
| Timeline | Dated events on a rail — time, title, description | `Timeline(title, get_entries=...)` → `[(time, title, description), ...]` |
|
|
56
|
+
| Tabs | Several widgets in one card, one visible at a time | `Tabs(title, panels=[(label, widget), ...])` |
|
|
57
|
+
| MetricGroup | A row of headline numbers from one data call | `MetricGroup(title, get_tiles=...)` → `[Tile(label, value, icon=, hint=), ...]` |
|
|
58
|
+
| DataTable | Paged, searchable rows fetched by the host | `DataTable(title, columns=[Column(...)], get_rows=...)` → `Rows(items, total=, totals=)` |
|
|
59
|
+
|
|
60
|
+
`Chart` and `Donut` are deliberately dependency-free — no JS charting
|
|
61
|
+
library is bundled (matching the CDN-only frontend approach), so
|
|
62
|
+
`Chart` renders as plain CSS width-percentage bars and `Donut` as a
|
|
63
|
+
hand-built SVG ring (the classic `stroke-dasharray`-on-a-circumference-
|
|
64
|
+
100-circle technique), not a real charting library's canvas/SVG
|
|
65
|
+
output. `Donut` cycles through a 6-color qualitative palette
|
|
66
|
+
(blue/violet/teal/amber/rose/cyan, deliberately distinct from the
|
|
67
|
+
toast component's green/orange/red success/warning/danger colors so a
|
|
68
|
+
slice is never mistaken for a status indicator); past 6 series entries
|
|
69
|
+
it wraps and repeats.
|
|
70
|
+
|
|
71
|
+
`Stat`, `Timeline` and `Tabs` are adapted from Flowbite's
|
|
72
|
+
admin-dashboard layout (its "Sales this week", "Latest Activity" and
|
|
73
|
+
"Statistics this month" cards respectively), restyled to the same
|
|
74
|
+
shadcn/ui tokens as the rest of the framework, so a custom widget
|
|
75
|
+
inherits the active theme (and dark mode) for free.
|
|
76
|
+
|
|
77
|
+
`Stat`'s delta is the *signed* percentage change, so `-4.2` means
|
|
78
|
+
"down 4.2%". The widget draws up in green and down in red, matching
|
|
79
|
+
the success/danger colors of the toast component, with an arrow
|
|
80
|
+
carrying the same meaning for anyone who can't separate the two hues.
|
|
81
|
+
That assumes up is good — for a metric where it isn't, such as an
|
|
82
|
+
error rate, negate the delta and say so in the title.
|
|
83
|
+
|
|
84
|
+
## Tabs: widgets inside widgets
|
|
85
|
+
|
|
86
|
+
`Tabs` is a *container*: it holds no data of its own, and each panel
|
|
87
|
+
is an ordinary widget rendered exactly as it would be at the top
|
|
88
|
+
level.
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
Tabs("User breakdown", panels=[
|
|
92
|
+
("By status", Donut("Users by status", get_series=...)),
|
|
93
|
+
("By organization", Donut("Users by organization", get_series=...)),
|
|
94
|
+
])
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Two things worth knowing:
|
|
98
|
+
|
|
99
|
+
- **Every panel is computed and rendered on page load**, not on first
|
|
100
|
+
click — switching tabs is pure client-side Alpine, with no round
|
|
101
|
+
trip, so a panel backed by a slow query costs the same whether or
|
|
102
|
+
not anyone opens it. Put an expensive breakdown in its own widget
|
|
103
|
+
rather than a tab if you don't want to pay for it every render.
|
|
104
|
+
- **A panel widget's own title isn't shown** — the tab label takes its
|
|
105
|
+
place, and only the container's title appears in the card header.
|
|
106
|
+
|
|
107
|
+
With Alpine still loading (or not running at all), the first panel
|
|
108
|
+
stays visible and the rest stay hidden, so the card degrades to its
|
|
109
|
+
default tab rather than to everything-at-once.
|
|
110
|
+
|
|
111
|
+
Nesting happens inside `tabs.html`, which renders each panel through
|
|
112
|
+
the same `{% include widget.template %}` the dashboard uses for a
|
|
113
|
+
top-level widget — so a container is just a widget whose template
|
|
114
|
+
happens to include others.
|
|
115
|
+
|
|
116
|
+
Every widget accepts `size="lg"` to span the full grid width instead of
|
|
117
|
+
one column, and an optional `permission=`: a widget naming a permission
|
|
118
|
+
is simply omitted (not shown-disabled) if the `Authorizer` denies it
|
|
119
|
+
for the current principal — see [`permissions.md`](permissions.md).
|
|
120
|
+
|
|
121
|
+
## Filters
|
|
122
|
+
|
|
123
|
+
A dashboard can carry a filter bar. Each filter reads its own query
|
|
124
|
+
parameters, so a filtered dashboard is a plain URL you can reload or share.
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
from polyadmin.core.dashboard import Dashboard, DateRangeFilter, SelectFilter
|
|
128
|
+
|
|
129
|
+
dashboard = Dashboard(
|
|
130
|
+
title="Statistics",
|
|
131
|
+
filters=[
|
|
132
|
+
DateRangeFilter("period", label="Period", default_days=30),
|
|
133
|
+
SelectFilter("contract_id", label="Client", empty_label="All clients", get_choices=load_contracts),
|
|
134
|
+
],
|
|
135
|
+
widgets=[...],
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| Filter | Query parameters | Value in `ctx.filters` |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| `DateRangeFilter(name, default_days=30)` | `{name}_from`, `{name}_to` (ISO dates) | `DateRange(start, end)` |
|
|
142
|
+
| `SelectFilter(name, choices=... \| get_choices=...)` | `{name}` | the chosen value, or `None` |
|
|
143
|
+
|
|
144
|
+
`SelectFilter(..., searchable=True)` puts a search box in the open list that
|
|
145
|
+
narrows the choices by label as you type, for a long list such as clients.
|
|
146
|
+
|
|
147
|
+
A filter never fails on what it is given: an unreadable date falls back to
|
|
148
|
+
the default range and a reversed range is swapped. `get_choices` may be sync
|
|
149
|
+
or async and is only called to render the page; a widget's request passes
|
|
150
|
+
the chosen value through without checking it against the choices.
|
|
151
|
+
|
|
152
|
+
## Widgets that depend on the request
|
|
153
|
+
|
|
154
|
+
A widget whose data function takes a context, or is `async`, is loaded
|
|
155
|
+
after the page, from `GET {base_path}/_widgets/{key}`, so a slow service
|
|
156
|
+
never holds up the whole dashboard. The context is a `WidgetContext`:
|
|
157
|
+
|
|
158
|
+
| Field | What |
|
|
159
|
+
|---|---|
|
|
160
|
+
| `filters` | every filter's parsed value, by name |
|
|
161
|
+
| `principal` | the signed-in principal |
|
|
162
|
+
| `search` | the widget's own search box, if it has one |
|
|
163
|
+
| `offset`, `limit` | the page a `DataTable` is asking for |
|
|
164
|
+
|
|
165
|
+
The widgets that take no context — every built-in one listed above except
|
|
166
|
+
`MetricGroup` and `DataTable` — keep rendering with the page, as before.
|
|
167
|
+
|
|
168
|
+
Options every widget takes:
|
|
169
|
+
|
|
170
|
+
- `key` — the widget's URL slug. Defaults to a slug of the title
|
|
171
|
+
(transliterated, so Cyrillic titles work); pass it explicitly to keep URLs
|
|
172
|
+
stable when a title changes. Keys must be unique within a dashboard.
|
|
173
|
+
- `depends_on` — the filters the widget reloads on. The default reloads on
|
|
174
|
+
every filter; `[]` never reloads. Changing a filter re-fetches only the
|
|
175
|
+
widgets that depend on it.
|
|
176
|
+
- `description` — a subtitle, or a callable of the `DashboardContext`, e.g.
|
|
177
|
+
the period being shown.
|
|
178
|
+
- `empty_text` — shown when the widget has nothing to show.
|
|
179
|
+
- `size="full"` spans the whole row.
|
|
180
|
+
- `placement="top"` renders the widget above the filter bar, full width and
|
|
181
|
+
without its card header -- a summary row such as the headline numbers.
|
|
182
|
+
|
|
183
|
+
## MetricGroup
|
|
184
|
+
|
|
185
|
+
Several numbers that one call answers:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
async def overview(ctx):
|
|
189
|
+
data = await analytics.overview()
|
|
190
|
+
return [
|
|
191
|
+
Tile("Contracts", data["contracts"], icon="file-text"),
|
|
192
|
+
Tile("Using the portal", data["active"], icon="activity", hint=f"dormant: {data['dormant']}"),
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
MetricGroup("Overview", key="overview", size="full", depends_on=[], get_tiles=overview)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## DataTable
|
|
199
|
+
|
|
200
|
+
Rows the host fetches a page at a time, e.g. from another service:
|
|
201
|
+
|
|
202
|
+
```python
|
|
203
|
+
async def passages(ctx):
|
|
204
|
+
data = await analytics.passages(period=ctx.filters["period"], limit=ctx.limit, offset=ctx.offset)
|
|
205
|
+
return Rows(data["items"], total=data["total"], totals=data["overall"])
|
|
206
|
+
|
|
207
|
+
DataTable(
|
|
208
|
+
"Passages", key="passages", size="full",
|
|
209
|
+
columns=[
|
|
210
|
+
Column("contract", "Contract", strong=True),
|
|
211
|
+
Column("total", "Total", align="end", format="number"),
|
|
212
|
+
Column("keypass", "By key", align="end", format="share"),
|
|
213
|
+
],
|
|
214
|
+
get_rows=passages, page_size=50, searchable=True, total_label="{total} contracts",
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
- `Rows(items, total=None, totals=None)`: `items` are dicts keyed by column
|
|
219
|
+
key. `totals`, returned with the first page, is a bold summary row pinned
|
|
220
|
+
above it. With `total` the table knows when it has shown everything;
|
|
221
|
+
without it, a page shorter than `page_size` is the last.
|
|
222
|
+
- Scrolling to the last row loads the next page. `page_size=None` loads
|
|
223
|
+
everything at once.
|
|
224
|
+
- `searchable=True` adds a search box to the card; its text arrives as
|
|
225
|
+
`ctx.search`.
|
|
226
|
+
- `total_label` is a footer with `{total}` filled in.
|
|
227
|
+
|
|
228
|
+
| `format` | Value | Renders |
|
|
229
|
+
|---|---|---|
|
|
230
|
+
| `text` | anything | as is |
|
|
231
|
+
| `number` | int or float | in the viewer's locale |
|
|
232
|
+
| `datetime` | datetime or ISO string | in the viewer's locale and time zone |
|
|
233
|
+
| `share` | `{"count": 12, "percentage": 34.5}` | `12 (34.5%)`; just `0` when the count is 0 |
|
|
234
|
+
| `percent` | a number | `87.3%` |
|
|
235
|
+
|
|
236
|
+
`empty="never used"` on a column shows that text as a badge in an empty
|
|
237
|
+
cell instead of a dash. It goes through translation like other labels.
|
|
238
|
+
|
|
239
|
+
`tones=((80, "success"), (50, "warning"), (0, "danger"))` colours a numeric
|
|
240
|
+
cell: it renders as a badge in the colour of the highest minimum the value
|
|
241
|
+
reaches, and stays plain below all of them.
|
|
242
|
+
|
|
243
|
+
### Filter-aware donuts and tabs
|
|
244
|
+
|
|
245
|
+
A `Donut` whose `get_series` takes the context, or is `async`, loads from its
|
|
246
|
+
fragment route like `DataTable`. A `Tabs` loads that way as soon as one of its
|
|
247
|
+
panels does, so a card of breakdowns can follow the filters:
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
Tabs("Breakdowns", key="breakdowns", size="full", panels=[
|
|
251
|
+
("Entry methods", Donut("Entry methods", get_series=passage_methods)),
|
|
252
|
+
("Users by role", Donut("Users by role", get_series=users_by_role)),
|
|
253
|
+
])
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## When a widget fails
|
|
257
|
+
|
|
258
|
+
Raise `WidgetUnavailable("The analytics service is down.")` from a data
|
|
259
|
+
function to show that message in the widget's card. Any other exception
|
|
260
|
+
shows "This section is unavailable." and is logged; either way the other
|
|
261
|
+
widgets load normally. A request that never reaches the admin shows
|
|
262
|
+
"Couldn't load this section." with a Retry button.
|
|
263
|
+
|
|
264
|
+
## Exports
|
|
265
|
+
|
|
266
|
+
A dashboard export is a button on the filter bar that submits the current
|
|
267
|
+
filters to `GET {base_path}/_exports/{name}`:
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
from polyadmin import Download
|
|
271
|
+
from polyadmin.core.dashboard import DashboardExport
|
|
272
|
+
|
|
273
|
+
async def export_statistics(ctx):
|
|
274
|
+
workbook = await build_workbook(period=ctx.filters["period"])
|
|
275
|
+
return Download("statistics.xlsx", XLSX_CONTENT_TYPE, content=workbook)
|
|
276
|
+
|
|
277
|
+
Dashboard(..., exports=[DashboardExport("xlsx", label="Export to Excel", handler=export_statistics)])
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The handler receives a `DashboardContext` (`filters`, `principal`) and must
|
|
281
|
+
return a `Download`. It requires the `dashboard.export` permission unless
|
|
282
|
+
you pass another `permission=`; without it the button is hidden and the
|
|
283
|
+
route answers 403.
|
|
284
|
+
|
|
285
|
+
## Routes
|
|
286
|
+
|
|
287
|
+
| Route | Serves |
|
|
288
|
+
|---|---|
|
|
289
|
+
| `GET {base_path}` | the page: filter bar, exports, a card per widget |
|
|
290
|
+
| `GET {base_path}/_widgets/{key}` | one widget's body; rows only when `offset` > 0 |
|
|
291
|
+
| `GET {base_path}/_exports/{name}` | an export's file |
|
|
292
|
+
|
|
293
|
+
All of them require `dashboard.view`. A widget hidden by its `permission`
|
|
294
|
+
answers 404 on its route, as an unknown key does.
|
|
295
|
+
|
|
296
|
+
## Custom widgets
|
|
297
|
+
|
|
298
|
+
You can add your own widget type without a framework change. Subclass
|
|
299
|
+
`Widget`, set `template` to your own `.html` file (placed under one of
|
|
300
|
+
the `template_dirs` passed to `create_router`), and implement
|
|
301
|
+
`get_data()` — `{% include widget.template %}` resolves it through
|
|
302
|
+
Jinja2's normal loader search path, same as any other override.
|
|
303
|
+
|
|
304
|
+
```python
|
|
305
|
+
class RecentSignupsWidget(Widget):
|
|
306
|
+
template = "widgets/recent-signups.html"
|
|
307
|
+
|
|
308
|
+
def get_data(self):
|
|
309
|
+
return {"rows": recent_signups()}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
```jinja
|
|
313
|
+
{# templates/widgets/recent-signups.html #}
|
|
314
|
+
<!-- your markup, using whatever get_data() returned -->
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
create_router(admin, base_path="/admin", template_dirs=["templates"])
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
The framework's own widget templates (`Metric`, `Stat`, `Progress`,
|
|
322
|
+
`Chart`, `Donut`, `Table`, `Activity`, `Timeline`, `Tabs`) are checked
|
|
323
|
+
first, so a custom `template` value only needs to avoid colliding with
|
|
324
|
+
`admin/widgets/*.html` — see [`templates.md`](templates.md) for the
|
|
325
|
+
full resolution order shared with per-resource overrides.
|
|
@@ -181,6 +181,11 @@ same answer in both places.
|
|
|
181
181
|
A reader who may not view the target resource does not get the filter at
|
|
182
182
|
all — it is dropped from the panel rather than shown empty.
|
|
183
183
|
|
|
184
|
+
When the relation uses `autocomplete_fields`, typing searches the target's
|
|
185
|
+
lookup endpoint and narrows the combobox options. The lookup text is not
|
|
186
|
+
included in the list URL when the filter is applied; only the selected
|
|
187
|
+
`filter[...]` value is submitted.
|
|
188
|
+
|
|
184
189
|
**One limitation worth knowing.** `apply` receives the parent
|
|
185
190
|
ModelAdmin, not the registry, so it cannot call the target's own
|
|
186
191
|
`get_pk`. It uses the same default lookup `ModelAdmin.get_pk` does. If
|