summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCefin <kevon@tuta.io>2021-10-27 15:19:37 +0200
committerCefin <kevon@tuta.io>2021-10-27 15:19:37 +0200
commit3085bb7cabc6909d71de2130a571346f2b6568e0 (patch)
tree9f089ca4c1efcca73f04c5bd659d1fab9ff08757
parent079f4765a762ff6656fcd8d7019d25eea38f5149 (diff)
downloadIshtar-fusion-lot-redmine#4698.tar.bz2
Ishtar-fusion-lot-redmine#4698.zip
adding exception in cas a type don't have parentsfusion-lot-redmine#4698
-rw-r--r--ishtar_common/admin.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py
index a803c64cc..58096b0cd 100644
--- a/ishtar_common/admin.py
+++ b/ishtar_common/admin.py
@@ -372,21 +372,19 @@ class ChangeParentForm(forms.Form):
change_parent = forms.ChoiceField(label=_("Change parent"), choices=[])
def __init__(self, choices, post=None, files=None):
- if post:
- super(ChangeParentForm, self).__init__(post, files)
- else:
- super(ChangeParentForm, self).__init__()
+ super(ChangeParentForm, self).__init__(post, files)
self.fields["change_parent"].choices = choices
class ChangeParentAdmin:
def get_actions(self, request):
action_dct = super(ChangeParentAdmin, self).get_actions(request)
- action_dct["change_parent_selected"] = (
- self.change_parent_admin,
- "change_parent_selected",
- _("Change parent of selected item(s)"),
- )
+ if hasattr(self.model, "parent"):
+ action_dct["change_parent_selected"] = (
+ self.change_parent_admin,
+ "change_parent_selected",
+ _("Change parent of selected item(s)"),
+ )
return action_dct
def change_parent_admin(self, modeladmin, request, queryset):