Skip to content

Commit

Permalink
Merge pull request #109 from PLUS-POSTECH/features/visibility-action
Browse files Browse the repository at this point in the history
Add visibility control action
  • Loading branch information
betarixm authored Mar 7, 2022
2 parents 8b6d583 + 550c00a commit 13314c3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/problem/admin.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions src/website/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "선택된 항목 을/를 문제 리스트에서 보입니다."

0 comments on commit 13314c3

Please sign in to comment.