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) 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 = "선택된 항목 을/를 문제 리스트에서 보입니다."