Commit 7128a979a1b68651beeda67a63ce5363f4cb6935

Authored by Gust
Committed by Sergio Oliveira
1 parent f80bb4a2

Haystack only indexes public threads

Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Signed-off-by: Alexandre Barbosa <alexandreab@live.com>
colab/super_archives/management/commands/import_emails.py
... ... @@ -295,3 +295,7 @@ class Command(BaseCommand, object):
295 295 raise
296 296 finally:
297 297 os.remove(self.lock_file)
  298 +
  299 + for mlist in MailingList.objects.all():
  300 + mlist.update_privacy()
  301 + mlist.save()
298 302 \ No newline at end of file
... ...
colab/super_archives/migrations/0002_mailinglist_is_private.py 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +# -*- coding: utf-8 -*-
  2 +from __future__ import unicode_literals
  3 +
  4 +from django.db import models, migrations
  5 +
  6 +
  7 +class Migration(migrations.Migration):
  8 +
  9 + dependencies = [
  10 + ('super_archives', '0001_initial'),
  11 + ]
  12 +
  13 + operations = [
  14 + migrations.AddField(
  15 + model_name='mailinglist',
  16 + name='is_private',
  17 + field=models.BooleanField(default=False),
  18 + preserve_default=True,
  19 + ),
  20 + ]
... ...
colab/super_archives/search_indexes.py
... ... @@ -85,10 +85,12 @@ class ThreadIndex(BaseIndex, indexes.Indexable):
85 85 return u'thread'
86 86  
87 87 def index_queryset(self, using=None):
88   - return self.get_model().objects.filter(
89   - spam=False
  88 + elements = self.get_model().objects.filter(
  89 + spam=False, mailinglist__is_private=False
90 90 ).exclude(subject_token='')
91 91  
  92 + return elements
  93 +
92 94 def get_boost(self, obj):
93 95 boost = super(ThreadIndex, self).get_boost(obj)
94 96  
... ...