Add media tagged "featured" to the front page
[mediagoblin-libreplanet.git] / mediagoblin_libreplanet / views.py
index 832ba14..829840c 100644 (file)
@@ -21,8 +21,13 @@ from mediagoblin.tools.pagination import Pagination
 from mediagoblin.tools.response import render_to_response
 from mediagoblin.decorators import uses_pagination
 
-def type_listing(media_type, title, request, page):
-    cursor = MediaEntry.query.\
+def type_listing(media_type, title, request, page, tag=None):
+    if (tag == None):
+        cursor = MediaEntry.query
+    else:
+        cursor = media_entries_for_tag_slug(request.db, tag)
+
+    cursor = cursor.\
              filter((MediaEntry.media_type == media_type)
                     & (MediaEntry.state == u'processed')).\
              order_by(MediaEntry.created.desc())
@@ -45,3 +50,12 @@ def image_listing(request, page):
 @uses_pagination
 def video_listing(request, page):
     return type_listing(u'mediagoblin.media_types.video', 'Videos', request, page)
+
+@uses_pagination
+def featured_image_listing(request, page):
+    return type_listing(u'mediagoblin.media_types.image', 'Featured Photos', request, page, "featured")
+
+@uses_pagination
+def featured_video_listing(request, page):
+    return type_listing(u'mediagoblin.media_types.video', 'Featured Videos', request, page, "featured")
+