Malicious uploads test with fake but not really image files working! :)
[mediagoblin.git] / mediagoblin / views.py
index 5bc04b66d4fbebb749bf566102b2163ab653fc03..ccd7a2df2aad283492c9200e895bb3d0fabc7e8b 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import datetime
+from mediagoblin import mg_globals
+from mediagoblin.util import render_to_response, Pagination
+from mediagoblin.db.util import DESCENDING
+from mediagoblin.decorators import uses_pagination
 
-from webob import Response, exc
-import wtforms
-from mediagoblin.db import models
-from mediagoblin.db.util import ObjectId, DESCENDING
-import gettext
-
-def root_view(request):
-    media_entries = request.db.MediaEntry.find(
+@uses_pagination
+def root_view(request, page):
+    cursor = request.db.MediaEntry.find(
         {u'state': u'processed'}).sort('created', DESCENDING)
-    
-    template = request.template_env.get_template(
-        'mediagoblin/root.html')
-    return Response(
-        template.render(
-            {'request': request,
-             'media_entries': media_entries}))
+
+    pagination = Pagination(page, cursor)
+    media_entries = pagination()
+
+    return render_to_response(
+        request, 'mediagoblin/root.html',
+        {'media_entries': media_entries,
+         'allow_registration': mg_globals.app_config["allow_registration"],
+         'pagination': pagination})
+
+
+def simple_template_render(request):
+    """
+    A view for absolutely simple template rendering.
+    Just make sure 'template' is in the matchdict!
+    """
+    template_name = request.matchdict['template']
+    return render_to_response(
+        request, template_name, {})