diff --git a/content/admin.py b/content/admin.py index d42e702..1d459b6 100644 --- a/content/admin.py +++ b/content/admin.py @@ -28,8 +28,9 @@ class LabelAdmin(PermissionsAdminMixin, admin.ModelAdmin): @admin.register(Question) class QuestionAdmin(PermissionsAdminMixin, admin.ModelAdmin): autocomplete_fields = ('medias', 'links', 'labels', 'shares') - list_display = ('name', 'list_labels', 'list_level', 'author') + list_display = ('name', 'list_labels', 'list_level', 'author', 'is_published') search_fields = ('name', 'question', 'awnser', 'description', 'label__name', 'level__value', 'level__name',) + list_editable = ('is_published',) def list_labels(self, instance): if instance.labels: diff --git a/content/models.py b/content/models.py index a04b8e7..1edad1d 100644 --- a/content/models.py +++ b/content/models.py @@ -11,7 +11,7 @@ from django.utils.safestring import mark_safe from filer.fields.file import FilerFileField from lib.core.db.models.base import SharedPermissionBase -from lib.core.db.models.mixins import DateAware, AuthorAware, DescriptionAware, NameAware +from lib.core.db.models.mixins import DateAware, AuthorAware, DescriptionAware, NameAware, PublishedAware class MediaFile(NameAware, DateAware, AuthorAware, DescriptionAware): @@ -62,7 +62,7 @@ class SharedQuestion(SharedPermissionBase): abstract = False -class Question(DateAware, AuthorAware, DescriptionAware): +class Question(DateAware, AuthorAware, PublishedAware, DescriptionAware): name = models.CharField(max_length=500, unique=True, db_index=True) question = models.TextField(db_index=True) buzzword = models.CharField(max_length=25, null=True, blank=True) @@ -90,8 +90,10 @@ class Question(DateAware, AuthorAware, DescriptionAware): @staticmethod - def get_by_tearchterm(term): - return Question.objects.filter(Question.searchdomain(term)).annotate(cnt=models.Count('id')) + def get_by_tearchterm(term, queryset=None): + if not queryset: + queryset = Question.objects + return queryset.filter(Question.searchdomain(term)).annotate(cnt=models.Count('id')) def to_view(self, for_players: bool = False): diff --git a/content/templates/questions.html b/content/templates/questions.html index d7ab33e..752325a 100644 --- a/content/templates/questions.html +++ b/content/templates/questions.html @@ -2,10 +2,10 @@ {% block content %}