diff --git a/fragdenstaat_de/fds_blog/admin.py b/fragdenstaat_de/fds_blog/admin.py index 55fa1fe1f..43558fa8d 100644 --- a/fragdenstaat_de/fds_blog/admin.py +++ b/fragdenstaat_de/fds_blog/admin.py @@ -19,7 +19,7 @@ from djangocms_text_ckeditor.widgets import TextEditorWidget from parler.admin import TranslatableAdmin -from froide.helper.admin_utils import make_nullfilter +from froide.helper.admin_utils import make_choose_object_action, make_nullfilter from froide.helper.widgets import TagAutocompleteWidget from .documents import index_article @@ -104,6 +104,11 @@ class AuthorshipInlineAdmin(SortableInlineAdminMixin, admin.TabularInline): raw_id_fields = ("author",) +def add_category_on_articles(admin, request, queryset, action_obj): + for article in queryset: + article.categories.add(action_obj) + + class ArticleAdminForm(forms.ModelForm): class Meta: model = Article @@ -247,9 +252,12 @@ class ArticleAdmin(SortableAdminBase, admin.ModelAdmin): ) save_on_top = True - actions = ["set_language"] + actions = ["set_language", "add_category"] actions_on_top = True - actions_on_bottom = True + + add_category = make_choose_object_action( + Category, add_category_on_articles, _("Set category on articles...") + ) # def __init__(self, model, admin_site): # # self.form.admin_site = admin_site