Fixed bugs on miscellaneous admin UI

This commit is contained in:
Marc Aymerich 2016-05-07 20:09:05 +00:00
parent bfb4666106
commit 415ddc2315
2 changed files with 14 additions and 9 deletions

View file

@ -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:

View file

@ -14,9 +14,11 @@ class Plugin(object):
def __init__(self, instance=None):
# Related model instance of this plugin
self.instance = instance
from .forms import PluginForm
self.form = PluginForm
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):
if self.form is None:
from .forms import PluginModelAdapterForm
self.form = PluginModelAdapterForm
super().__init__(instance)
from .forms import PluginModelAdapterForm
self.form = PluginModelAdapterForm
@classmethod
def get_plugins(cls):