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