added first public views - no check for access rights at the moment

This commit is contained in:
Holger Sielaff
2024-07-12 17:22:17 +02:00
parent 7d53df6ea5
commit 3640ab759d
22 changed files with 386 additions and 69 deletions

View File

@@ -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'