diff options
author | Cefin <kevon@tuta.io> | 2021-10-27 15:19:37 +0200 |
---|---|---|
committer | Cefin <kevon@tuta.io> | 2021-10-27 15:19:37 +0200 |
commit | 3085bb7cabc6909d71de2130a571346f2b6568e0 (patch) | |
tree | 9f089ca4c1efcca73f04c5bd659d1fab9ff08757 | |
parent | 079f4765a762ff6656fcd8d7019d25eea38f5149 (diff) | |
download | Ishtar-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.py | 16 |
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): |