From 3e68d2d4fdefbe35e625b769e41a690d3775e654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Mr=C3=B3zek?= Date: Wed, 13 Nov 2024 13:31:03 +0100 Subject: [PATCH] Fix broken bulk changes in inline views The bulk change would previously try to use a form of the parent model. --- is_core/generic_views/table_views.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/is_core/generic_views/table_views.py b/is_core/generic_views/table_views.py index 532c66c6..ed2ad27c 100644 --- a/is_core/generic_views/table_views.py +++ b/is_core/generic_views/table_views.py @@ -8,7 +8,7 @@ from is_core.rest.filters import UIFilterMixin, FilterChoiceIterator from is_core.rest.datastructures import ModelFlatRestFields, ModelRestFieldset from is_core.utils import ( - pretty_class_name, get_export_types_with_content_type, LOOKUP_SEP, get_field_label_from_path + pretty_class_name, get_export_types_with_content_type, LOOKUP_SEP, get_field_label_from_path, get_model_name ) from chamber.utils.http import query_string_from_dict @@ -363,12 +363,23 @@ def get_context_data(self, **kwargs): return context_data def get_bulk_change_snippet_name(self): - return '-'.join(('default', self.core.menu_group, 'form')) + try: + snippet_model_name = get_model_name(self.model) + except Exception: + snippet_model_name = self.core.menu_group + + return "-".join(("default", snippet_model_name, "form")) def get_bulk_change_form_url(self): + try: + snippet_model_name = get_model_name(self.model) + except Exception: + snippet_model_name = self.core.menu_group + return ( - reverse(''.join(('IS:', self.core.get_bulk_change_url_name(), '-', self.core.menu_group))) - if self.is_bulk_change_enabled() else None + reverse("".join(("IS:", self.core.get_bulk_change_url_name(), "-", snippet_model_name))) + if self.is_bulk_change_enabled() + else None ) def _get_menu_group_pattern_name(self):