mirror of
https://github.com/nikdoof/vapemap.git
synced 2025-12-14 23:02:21 +00:00
Add a set active function for Stores.
This commit is contained in:
@@ -31,12 +31,18 @@ class StoreAdmin(admin.ModelAdmin):
|
|||||||
inlines = [
|
inlines = [
|
||||||
LinkInlineAdmin,
|
LinkInlineAdmin,
|
||||||
]
|
]
|
||||||
actions = ['add_brand', 'set_chain']
|
actions = ['set_active', 'add_brand', 'set_chain']
|
||||||
|
|
||||||
class AddBrandForm(forms.Form):
|
class AddBrandForm(forms.Form):
|
||||||
_selected_action = forms.CharField(widget=forms.MultipleHiddenInput)
|
_selected_action = forms.CharField(widget=forms.MultipleHiddenInput)
|
||||||
brand = forms.ModelChoiceField(Brand.objects)
|
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):
|
def add_brand(self, request, queryset):
|
||||||
form = None
|
form = None
|
||||||
if 'apply' in request.POST:
|
if 'apply' in request.POST:
|
||||||
|
|||||||
Reference in New Issue
Block a user