Fixed bugs on miscellaneous admin UI
This commit is contained in:
parent
bfb4666106
commit
415ddc2315
|
@ -86,9 +86,9 @@ class MiscellaneousAdmin(SelectPluginAdminMixin, AccountAdminMixin, ExtendedMode
|
|||
else:
|
||||
return obj.service
|
||||
|
||||
def get_fields(self, request, obj=None):
|
||||
fields = super().get_fields(request, obj)
|
||||
fields = list(fields)
|
||||
def get_fieldsets(self, request, obj=None):
|
||||
fieldsets = super().get_fieldsets(request, obj)
|
||||
fields = list(fieldsets[0][1]['fields'])
|
||||
service = self.get_service(obj)
|
||||
if obj:
|
||||
fields.insert(1, 'account_link')
|
||||
|
@ -96,7 +96,8 @@ class MiscellaneousAdmin(SelectPluginAdminMixin, AccountAdminMixin, ExtendedMode
|
|||
fields.insert(-1, 'amount')
|
||||
if service.has_identifier:
|
||||
fields.insert(2, 'identifier')
|
||||
return fields
|
||||
fieldsets[0][1]['fields'] = fields
|
||||
return fieldsets
|
||||
|
||||
def get_form(self, request, obj=None, **kwargs):
|
||||
if obj:
|
||||
|
|
|
@ -14,9 +14,11 @@ class Plugin(object):
|
|||
|
||||
def __init__(self, instance=None):
|
||||
# Related model instance of this plugin
|
||||
if self.form is None:
|
||||
self.instance = instance
|
||||
from .forms import PluginForm
|
||||
self.form = PluginForm
|
||||
super().__init__()
|
||||
|
||||
@classmethod
|
||||
def get_name(cls):
|
||||
|
@ -93,11 +95,13 @@ class PluginModelAdapter(Plugin):
|
|||
""" Adapter class for using model classes as plugins """
|
||||
model = None
|
||||
name_field = None
|
||||
form = None
|
||||
|
||||
def __init__(self, instance=None):
|
||||
super().__init__(instance)
|
||||
if self.form is None:
|
||||
from .forms import PluginModelAdapterForm
|
||||
self.form = PluginModelAdapterForm
|
||||
super().__init__(instance)
|
||||
|
||||
@classmethod
|
||||
def get_plugins(cls):
|
||||
|
|
Loading…
Reference in New Issue