diff --git a/app/stores/admin.py b/app/stores/admin.py index 0a5c512..ba87cd8 100644 --- a/app/stores/admin.py +++ b/app/stores/admin.py @@ -31,12 +31,18 @@ class StoreAdmin(admin.ModelAdmin): inlines = [ LinkInlineAdmin, ] - actions = ['add_brand', 'set_chain'] + actions = ['set_active', 'add_brand', 'set_chain'] class AddBrandForm(forms.Form): _selected_action = forms.CharField(widget=forms.MultipleHiddenInput) brand = forms.ModelChoiceField(Brand.objects) + def set_active(self, request, queryset): + with transaction.commit_on_success(): + queryset.update(active=True) + self.message_user(request, "Successfully set %d stores to active." % queryset.count()) + set_active.short_description = 'Set selected stores active.' + def add_brand(self, request, queryset): form = None if 'apply' in request.POST: