cms_plugins: only show published announces in the AnnounceListPlugin

fixes #3407
This commit is contained in:
Benjamin Dauvergne 2013-08-02 13:50:01 +02:00
parent f69692ff2a
commit b84a3de582
1 changed files with 7 additions and 4 deletions

View File

@ -22,16 +22,19 @@ class AnnounceListPlugin(CMSPluginBase):
text_enabled = True
transport_identifier = transports.HomepageTransport.identifier
def get_queryset(self):
qs = models.Announce.objects.all()
qs = qs.filter(category__subscription__transport=self.transport_identifier)
def get_queryset(self, user):
qs = models.Announce.objects.published()
categories = models.Subscription.objects.filter(
transport=self.transport_identifier,
user=user).values_list('category', flat=True)
qs = qs.filter(category__in=categories)
if app_settings.feed_homepage_limit:
qs = qs[:app_settings.feed_homepage_limit]
return qs
def render(self, context, instance, placeholder):
request = context['request']
context['object_list'] = self.get_queryset()
context['object_list'] = self.get_queryset(request.user)
context['id_prefix'] = 'announce-item-'
subscriptions = models.Subscription.objects.filter(
transport=self.transport_identifier,