...
This commit is contained in:
@@ -1,11 +1,32 @@
|
||||
from django.contrib import admin
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from content.models import Link, MediaFile, Question, QuestionVersion, Level, Label, SharedQuestion
|
||||
from content.models import Link, MediaFile, Question, QuestionVersion, Level, Label, SharedQuestion, SubmittedQuestion
|
||||
from lib.mixins import PermissionsAdminMixin
|
||||
from lib.utils import color_label
|
||||
|
||||
|
||||
class ActiveFilter(admin.SimpleListFilter):
|
||||
title = "Aktiv/Inaktiv"
|
||||
parameter_name = 'released'
|
||||
|
||||
def lookups(self, request, model_admin):
|
||||
return [
|
||||
(1, 'Inaktiv'),
|
||||
(0, 'Aktiv')
|
||||
]
|
||||
|
||||
def queryset(self, request, queryset):
|
||||
v = int(self.value() or -1)
|
||||
if v == 1:
|
||||
return queryset.filter(**{self.parameter_name: True})
|
||||
elif v == 0:
|
||||
return queryset.filter(**{self.parameter_name: False})
|
||||
else:
|
||||
return queryset.filter(**{self.parameter_name: False})
|
||||
# return queryset
|
||||
|
||||
|
||||
@admin.register(SharedQuestion)
|
||||
class SharedQuestionAdmin(admin.ModelAdmin):
|
||||
search_fields = ('user__username',)
|
||||
@@ -25,6 +46,11 @@ class LabelAdmin(PermissionsAdminMixin, admin.ModelAdmin):
|
||||
list_editable = ('color',)
|
||||
|
||||
|
||||
@admin.register(SubmittedQuestion)
|
||||
class SubmittedQuestionAdmin(admin.ModelAdmin):
|
||||
list_filter = [ActiveFilter,]
|
||||
|
||||
|
||||
@admin.register(Question)
|
||||
class QuestionAdmin(PermissionsAdminMixin, admin.ModelAdmin):
|
||||
autocomplete_fields = ('medias', 'links', 'labels', 'shares')
|
||||
|
||||
Reference in New Issue
Block a user