issue 582: use media.slug instead of media.id
authorlora <lorochka85@gmail.com>
Sat, 19 Nov 2011 23:00:25 +0000 (17:00 -0600)
committerlora <lorochka85@gmail.com>
Sat, 19 Nov 2011 23:00:25 +0000 (17:00 -0600)
mediagoblin/decorators.py
mediagoblin/templates/mediagoblin/user_pages/media.html
mediagoblin/templates/mediagoblin/user_pages/media_confirm_delete.html

index 19e22bcabe257125f97a5e4944faa2e71aa81e2e..38f52cedcb8979d791b4c99044c6c46b50e7b7d9 100644 (file)
@@ -58,7 +58,7 @@ def user_may_delete_media(controller):
     """
     def wrapper(request, *args, **kwargs):
         uploader = request.db.MediaEntry.find_one(
-            {'_id': ObjectId(request.matchdict['media'])}).uploader()
+            {'slug': request.matchdict['media'] }).uploader()
         if not (request.user['is_admin'] or
                 request.user['_id'] == uploader['_id']):
             return exc.HTTPForbidden()
@@ -95,7 +95,6 @@ def get_user_media_entry(controller):
 
         if not user:
             return render_404(request)
-
         media = request.db.MediaEntry.find_one(
             {'slug': request.matchdict['media'],
              'state': 'processed',
index 433f74dcac73dcd96dd2ed97bd6c86fe3f2d1a41..5e1b73deabeef615363232cfb22c3f58d9d84eef 100644 (file)
         <p>
           {% set edit_url = request.urlgen('mediagoblin.edit.edit_media',
                                      user= media.uploader().username,
-                                     media= media._id) %}
+                                     media= media.slug) %}
           <a href="{{ edit_url }}"
              ><img src="{{ request.staticdirect('/images/icon_edit.png') }}"
                    class="media_icon" /></a>
         <p>
           {% set delete_url = request.urlgen('mediagoblin.user_pages.media_confirm_delete',
                                      user= media.uploader().username,
-                                     media= media._id) %}
+                                     media= media.slug) %}
           <a href="{{ delete_url }}"
              ><img src="{{ request.staticdirect('/images/icon_delete.png') }}"
                class="media_icon" /></a>
index dd6923a9420e493ae9d4463a4fa2860ab91a5dd3..f62082bde8171e85bf554c71f4bfad236322107f 100644 (file)
@@ -23,7 +23,7 @@
 
   <form action="{{ request.urlgen('mediagoblin.user_pages.media_confirm_delete',
                                  user=media.uploader().username,
-                                 media=media._id) }}"
+                                 media=media.slug) }}"
         method="POST" enctype="multipart/form-data">
     <div class="grid_8 prefix_1 suffix_1 edit_box form_box">
       <h1>