added first public views - no check for access rights at the moment
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
from django.contrib import admin
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from content.models import Link, MediaFile, Question, QuestionVersion, Level, Label
|
||||
from lib.utils import color_label
|
||||
from content.models import Link, MediaFile, Question, QuestionVersion, Level, Label, SharedQuestion
|
||||
from lib.mixins import PermissionsAdminMixin
|
||||
from lib.utils import color_label
|
||||
|
||||
|
||||
@admin.register(SharedQuestion)
|
||||
class SharedQuestionAdmin(admin.ModelAdmin):
|
||||
search_fields = ('user__username',)
|
||||
|
||||
|
||||
@admin.register(Level)
|
||||
@@ -22,15 +27,19 @@ class LabelAdmin(PermissionsAdminMixin, admin.ModelAdmin):
|
||||
|
||||
@admin.register(Question)
|
||||
class QuestionAdmin(PermissionsAdminMixin, admin.ModelAdmin):
|
||||
autocomplete_fields = ('medias', 'links', 'labels',)
|
||||
autocomplete_fields = ('medias', 'links', 'labels', 'shares')
|
||||
list_display = ('name', 'list_labels', 'list_level', 'author')
|
||||
search_fields = ('name', 'question', 'awnser', 'description', 'label__name', 'level__value', 'level__name',)
|
||||
|
||||
def list_labels(self, instance):
|
||||
return mark_safe(', '.join([color_label(l, value=l.name) for l in instance.labels.all()]))
|
||||
if instance.labels:
|
||||
return mark_safe(', '.join([color_label(l, value=l.name) for l in instance.labels.all()]))
|
||||
return ''
|
||||
|
||||
def list_level(self, instance):
|
||||
return mark_safe(color_label(instance.level, value=str(instance.level)))
|
||||
if instance.level:
|
||||
return mark_safe(color_label(instance.level, value=str(instance.level)))
|
||||
return ''
|
||||
|
||||
list_level.short_description = 'Level'
|
||||
list_labels.short_description = 'Labels'
|
||||
|
||||
Reference in New Issue
Block a user