summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei MIHAI <smihai@entrouvert.com>2014-11-25 16:39:02 (GMT)
committerSerghei MIHAI <smihai@entrouvert.com>2014-11-26 10:07:21 (GMT)
commit3aa4df5b8256dd9e6bdf09d5c26351e4e8596b89 (patch)
tree11be6bbb7b2e02b9a1ce38064a4e4e629c219d28
parentf9ea2f1212e0d5eeb05bb3176c17d6bbb8668f08 (diff)
downloadportail-citoyen-announces-3aa4df5b8256dd9e6bdf09d5c26351e4e8596b89.zip
portail-citoyen-announces-3aa4df5b8256dd9e6bdf09d5c26351e4e8596b89.tar.gz
portail-citoyen-announces-3aa4df5b8256dd9e6bdf09d5c26351e4e8596b89.tar.bz2
published only announces are displayed.
-rw-r--r--portail_citoyen_announces/views.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/portail_citoyen_announces/views.py b/portail_citoyen_announces/views.py
index 698ee38..4d081e0 100644
--- a/portail_citoyen_announces/views.py
+++ b/portail_citoyen_announces/views.py
@@ -34,11 +34,9 @@ subscription_view = SubscriptionView.as_view()
class AnnounceHomepageView(ListView):
model = models.Announce
template_name = 'portail_citoyen_announces/announce_homepage.html'
- transport_identifier = transports.HomepageTransport.identifier
def get_queryset(self):
- qs = models.Announce.objects.all()
- qs = qs.filter(category__subscription__transport=self.transport_identifier)
+ qs = models.Announce.objects.all().published()
if app_settings.feed_homepage_limit:
qs = qs[:app_settings.feed_homepage_limit]
return qs
@@ -46,10 +44,10 @@ class AnnounceHomepageView(ListView):
def get_context_data(self, **kwargs):
ctx = super(AnnounceHomepageView, self).get_context_data(**kwargs)
ctx['id_prefix'] = 'announce-item-'
- subscriptions = models.Subscription.objects.filter(
- transport=self.transport_identifier,
+ if self.request.user.is_authenticated():
+ subscriptions = models.Subscription.objects.filter(
user=self.request.user).select_related('category')
- ctx['subscriptions'] = [ sub.category.name for sub in subscriptions ]
+ ctx['subscriptions'] = [ sub.category.name for sub in subscriptions ]
return ctx
homepage_view = AnnounceHomepageView.as_view()
@@ -66,7 +64,7 @@ class AnnounceFeed(Feed):
self.__dict__.update(kwargs)
def items(self):
- return models.Announce.objects.order_by('-publication_time')
+ return models.Announce.objects.published().order_by('-publication_time')
def item_title(self, item):
return item.title