changeset 18:72099349b4a8

arnica_action: moved view before check of delete rights
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 22 May 2008 18:36:05 +0200
parents cb6ad4cfdc5e
children 2e91ea8506a0
files data/plugin/action/arnica_slides.py
diffstat 1 files changed, 32 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/action/arnica_slides.py	Thu May 22 18:24:46 2008 +0200
+++ b/data/plugin/action/arnica_slides.py	Thu May 22 18:36:05 2008 +0200
@@ -348,6 +348,7 @@
         pagename = self.pagename
         page = Page(request, pagename)
         arena_dir = caching.get_arena_dir(request, page, 'item')
+        msg = None
 
         if not Image:
             msg = _('The action %(action)s needs python imaging library (PIL) installed' % {'action': action_name})
@@ -397,11 +398,41 @@
             request.write(request.theme.send_footer(pagename))
             msg = None
 
+        elif command == 'view':
+            if not target:
+                return
+            if not request.user.may.read(pagename):
+                return _('You are not allowed to view attachments of this page.')
+            fpath = os.path.join(arena_dir, target)
+            if not os.path.exists(fpath):
+                return
+
+            timestamp = timefuncs.formathttpdate(int(os.path.getmtime(fpath)))
+            if request.if_modified_since == timestamp:
+                request.emit_http_headers(["Status: 304 Not modified"])
+            else:
+                mt = wikiutil.MimeType(filename=target)
+                content_type = mt.content_type()
+                mime_type = mt.mime_type()
+
+                content_dispo = 'inline'
+                filename_enc = target.encode(config.charset)
+
+                request.emit_http_headers([
+                    'Content-Type: %s' % content_type,
+                    'Last-Modified: %s' % timestamp,
+                    'Content-Length: %d' % os.path.getsize(fpath),
+                    'Content-Disposition: %s; filename="%s"' % (content_dispo, filename_enc),
+                     ])
+
+                    # send data
+                request.send_file(open(fpath, 'rb'))
+
         elif command == 'PS':
             msg = None
 
         elif command == 'BS':
-            msg = "gone back" 
+            msg = "gone back"
 
         elif request.user.may.delete(pagename):
         # only users which are allowed to delete should use this tool
@@ -446,36 +477,6 @@
                 self.image_rotate(infile, webf, thumbf, 270, img_type)
                 msg = _('%(target)s rotated to right 90 degrees' % {'target':target})
 
-            elif command == 'view':
-                if not target:
-                    return
-                if not request.user.may.read(pagename):
-                    return _('You are not allowed to view attachments of this page.')
-
-
-                fpath = os.path.join(arena_dir, target)
-                if not os.path.exists(fpath):
-                    return
-                timestamp = timefuncs.formathttpdate(int(os.path.getmtime(fpath)))
-                if request.if_modified_since == timestamp:
-                    request.emit_http_headers(["Status: 304 Not modified"])
-                else:
-                    mt = wikiutil.MimeType(filename=target)
-                    content_type = mt.content_type()
-                    mime_type = mt.mime_type()
-
-                    content_dispo = 'inline'
-                    filename_enc = target.encode(config.charset)
-
-                    request.emit_http_headers([
-                        'Content-Type: %s' % content_type,
-                        'Last-Modified: %s' % timestamp,
-                        'Content-Length: %d' % os.path.getsize(fpath),
-                        'Content-Disposition: %s; filename="%s"' % (content_dispo, filename_enc),
-                        ])
-
-                    # send data
-                    request.send_file(open(fpath, 'rb'))
             else:
                 # fallback
                 msg = _('action not implemented: %s') % (command, )