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 f818649 commit fb391d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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 fb391d9

Please sign in to comment.