diff --git a/helpdesk/admin.py b/helpdesk/admin.py index 8b1dedf9..301a9c43 100644 --- a/helpdesk/admin.py +++ b/helpdesk/admin.py @@ -70,7 +70,7 @@ class FollowUpAdmin(admin.ModelAdmin): @admin.register(KBItem) class KBItemAdmin(admin.ModelAdmin): - list_display = ('category', 'title', 'last_updated', 'team', 'order') + list_display = ('category', 'title', 'last_updated', 'team', 'order', 'enabled') inlines = [KBIAttachmentInline] readonly_fields = ('voted_by', 'downvoted_by') diff --git a/helpdesk/migrations/0032_kbitem_enabled.py b/helpdesk/migrations/0032_kbitem_enabled.py new file mode 100644 index 00000000..7868bfe1 --- /dev/null +++ b/helpdesk/migrations/0032_kbitem_enabled.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.10 on 2020-02-25 13:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('helpdesk', '0031_auto_20200225_1440'), + ] + + operations = [ + migrations.AddField( + model_name='kbitem', + name='enabled', + field=models.BooleanField(default=True, verbose_name='Enabled to display to users'), + ), + ] diff --git a/helpdesk/models.py b/helpdesk/models.py index 15465160..7e4b61c5 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -1323,6 +1323,11 @@ class KBItem(models.Model): null=True, ) + enabled = models.BooleanField( + _('Enabled to display to users'), + default=True, + ) + def save(self, *args, **kwargs): if not self.last_updated: self.last_updated = timezone.now() diff --git a/helpdesk/views/kb.py b/helpdesk/views/kb.py index a1bead71..55b3424d 100644 --- a/helpdesk/views/kb.py +++ b/helpdesk/views/kb.py @@ -30,7 +30,7 @@ def category(request, slug, iframe=False): category = get_object_or_404(KBCategory, slug__iexact=slug) if not user.huser_from_request(request).can_access_kbcategory(category): raise Http404 - items = category.kbitem_set.all() + items = category.kbitem_set.filter(enabled=True) selected_item = request.GET.get('kbitem', None) try: selected_item = int(selected_item)