add in_stream Entry property,
[django-migdal.git] / migdal / api.py
index d4f031e..abd3b21 100644 (file)
@@ -8,10 +8,16 @@ from migdal import app_settings
 from django.utils.translation import get_language
 
 
-def entry_list(entry_type=None, category=None, promobox=False):
+def entry_list(entry_type=None, category=None, promobox=False,
+            for_feed=False):
     lang = get_language()
-    object_list = Entry.objects.filter(**{"published_%s" % lang: True}
-        ).order_by('-published_at_%s' % lang)
+    object_list = Entry.objects.filter(**{"published_%s" % lang: True})
+
+    if for_feed:
+        object_list = object_list.order_by('-published_at_%s' % lang)
+    else:
+        object_list = object_list.order_by('-first_published_at')
+
     if entry_type:
         object_list = object_list.filter(type=entry_type.db)
     else:
@@ -23,6 +29,10 @@ def entry_list(entry_type=None, category=None, promobox=False):
     if promobox:
         promo = list(object_list.filter(promo=True)[:promobox])
         #object_list = object_list.exclude(pk__in=[p.pk for p in promo])
+
+    object_list = object_list.filter(in_stream=True)
+
+    if promobox:
         object_list.promobox = promo
 
     return object_list