From 2350a9fb259cb5ac12a46f0c8530e5defbff0d05 Mon Sep 17 00:00:00 2001 From: beta Date: Mon, 7 Mar 2022 15:05:59 +0900 Subject: [PATCH 1/2] actions: Add ProblemInstanceVisibilityMixin --- src/website/actions.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/website/actions.py b/src/website/actions.py index cec3180..cfee709 100644 --- a/src/website/actions.py +++ b/src/website/actions.py @@ -20,3 +20,15 @@ def export_as_csv(self, request, queryset): return response export_as_csv.short_description = "선택된 항목 을/를 CSV 로 내보냅니다." + + +class ProblemInstanceVisibilityMixin: + def hide_problem_instance(self, request, queryset): + queryset.update(hidden=True) + + def show_problem_instance(self, request, queryset): + queryset.update(hidden=False) + + hide_problem_instance.short_description = "선택된 항목 을/를 문제 리스트에서 숨깁니다." + + show_problem_instance.short_description = "선택된 항목 을/를 문제 리스트에서 보입니다." From 550c00a6704d4b71b3e4cdbe790b04e903a874b8 Mon Sep 17 00:00:00 2001 From: beta Date: Mon, 7 Mar 2022 15:06:15 +0900 Subject: [PATCH 2/2] actions: Apply ProblemInstanceVisibilityMixin --- src/problem/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/problem/admin.py b/src/problem/admin.py index 6e2fdb4..2ff1300 100644 --- a/src/problem/admin.py +++ b/src/problem/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from website.actions import ExportCsvMixin +from website.actions import ExportCsvMixin, ProblemInstanceVisibilityMixin from .models import Problem, ProblemAttachment, ProblemInstance, ProblemList, ProblemAuthLog, ProblemQuestion @@ -17,8 +17,9 @@ class ProblemAttachmentAdmin(admin.ModelAdmin): @admin.register(ProblemInstance) -class ProblemInstanceAdmin(admin.ModelAdmin): +class ProblemInstanceAdmin(admin.ModelAdmin, ProblemInstanceVisibilityMixin): list_display = ('pk', 'problem') + actions = ['hide_problem_instance', 'show_problem_instance'] @admin.register(ProblemList)