Skip to content

Commit

Permalink
fix and test #71 (add view don't work on Django 5.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Apr 12, 2024
1 parent 1c6af55 commit d6415ff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

1.3.1 (2024-04-12)
------------------

* fix for Django 5.0 DashboardStats admin add view

1.3.0 (2023-02-10)
------------------

Expand Down
9 changes: 6 additions & 3 deletions admin_tools_stats/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@ def criteria__criteria_dynamic_mapping_preview(self, obj):
class DashboardStatsForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["default_multiseries_criteria"].queryset = CriteriaToStatsM2M.objects.filter(
stats=self.instance,
)
if self.instance.pk:
self.fields["default_multiseries_criteria"].queryset = (
CriteriaToStatsM2M.objects.filter(
stats=self.instance,
)
)


@admin.register(DashboardStats)
Expand Down
8 changes: 8 additions & 0 deletions admin_tools_stats/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ def test_admin_tools_stats_dashboardstatscriteria(self):
response = self.client.get("/admin/admin_tools_stats/dashboardstatscriteria/")
self.assertEqual(response.status_code, 200)

def test_add_view(self):
url = reverse("admin:admin_tools_stats_dashboardstats_add")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
url = reverse("admin:admin_tools_stats_dashboardstatscriteria_add")
response = self.client.get(url)
self.assertEqual(response.status_code, 200)


class AdminToolsStatsAdminCharts(BaseSuperuserAuthenticatedClient):
def test_admin_dashboard_page(self):
Expand Down

0 comments on commit d6415ff

Please sign in to comment.