From 2d59fc468eae9b6d6d669b3ac4aa495024fdadad Mon Sep 17 00:00:00 2001 From: j Date: Sun, 25 Sep 2022 19:09:52 +0100 Subject: [PATCH] unlisted public items --- app/text/migrations/0009_text_listed.py | 18 ++++++++++++++++++ app/text/models.py | 1 + app/text/views.py | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 app/text/migrations/0009_text_listed.py diff --git a/app/text/migrations/0009_text_listed.py b/app/text/migrations/0009_text_listed.py new file mode 100644 index 0000000..de59f3d --- /dev/null +++ b/app/text/migrations/0009_text_listed.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.15 on 2022-09-25 18:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('text', '0008_auto_20211028_1007'), + ] + + operations = [ + migrations.AddField( + model_name='text', + name='listed', + field=models.BooleanField(default=True, verbose_name='Include in list if public'), + ), + ] diff --git a/app/text/models.py b/app/text/models.py index 69ac772..5359e97 100644 --- a/app/text/models.py +++ b/app/text/models.py @@ -43,6 +43,7 @@ class Text(models.Model): language = models.CharField(choices=LANGUAGE_CHOICES, max_length=8, default='en') slug = models.SlugField() public = models.BooleanField(default=False) + listed = models.BooleanField("List this item on overview page", default=True) position = models.IntegerField(default=0) title = models.TextField() diff --git a/app/text/views.py b/app/text/views.py index 1a7b3b6..9d6331d 100644 --- a/app/text/views.py +++ b/app/text/views.py @@ -17,7 +17,7 @@ def index(request): from ..text.models import Text context = {} context['films'] = Film.objects.filter(public=True).count() - context['texts'] = Text.objects.filter(public=True).count() + context['texts'] = Text.objects.filter(public=True, listed=True).count() context['stream_prefix'] = get_stream_prefix(request) featured = Film.objects.filter(featured=True) featured_count = featured.count() @@ -49,7 +49,7 @@ def about(request): def texts(request): context = {} - all_texts = models.Text.objects.filter(public=True).order_by('position', 'created') + all_texts = models.Text.objects.filter(public=True, listed=True).order_by('position', 'created') context['texts'] = all_texts.filter() return render(request, 'texts.html', context)