Skip to content

Commit

Permalink
fix issue where Admin actions get leaked to other apps
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Baechler committed Apr 16, 2015
1 parent 35f0489 commit c14bb4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions elephantblog/extensions/blogping.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def pre_save_handler(sender, instance, **kwargs):

@staticmethod
def _entry_admin_update_fn(new_state, new_state_dict, short_description=None):
def _fn(self, request, queryset):
def _fn(modeladmin, request, queryset):
rows_updated = queryset.update(**new_state_dict)

self.message_user(request, ungettext(
modeladmin.message_user(request, ungettext(
'One entry was successfully marked as %(state)s',
'%(count)s entries were successfully marked as %(state)s',
rows_updated) % {'state': new_state, 'count': rows_updated})
Expand Down Expand Up @@ -55,9 +55,8 @@ def handle_model(self):
pre_save.connect(Extension.pre_save_handler, sender=self.model)

def handle_modeladmin(self, modeladmin):
if not hasattr(modeladmin, 'actions'):
setattr(modeladmin, 'actions', [])
modeladmin.actions.append(Extension._entry_admin_update_fn(
actions = modeladmin.actions
actions.append(Extension._entry_admin_update_fn(
_('queued'),
{'pinging': self.model.QUEUED},
short_description=_('Ping Again')
Expand Down
2 changes: 2 additions & 0 deletions elephantblog/modeladmins.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def entries(self, obj):


class EntryAdmin(item_editor.ItemEditor):
actions = []

date_hierarchy = 'published_on'
filter_horizontal = ['categories']
list_display = [
Expand Down

0 comments on commit c14bb4b

Please sign in to comment.