changeset 3023:4ec124c124c9

action.AttachFile: bugfix showing unzip for packages, install for superuser on readonly pages too (backport to 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 28 Jan 2008 14:29:07 +0100
parents e757ebc436e7
children a438cc63c626
files MoinMoin/action/AttachFile.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Tue Jan 15 14:40:18 2008 +0100
+++ b/MoinMoin/action/AttachFile.py	Mon Jan 28 14:29:07 2008 +0100
@@ -359,14 +359,14 @@
             else:
                 viewlink = '<a href="%(baseurl)s/%(urlpagename)s?action=%(action)s&amp;do=view&amp;target=%(urlfile)s">%(label_view)s</a>' % parmdict
 
-            if (packages.ZipPackage(request, os.path.join(attach_dir, file).encode(config.charset)).isPackage() and
-                 request.user.isSuperUser() and request.user.may.write(pagename)):
-                viewlink += ' | <a href="%(baseurl)s/%(urlpagename)s?action=%(action)s&amp;do=install&amp;target=%(urlfile)s">%(label_install)s</a>' % parmdict
-            elif (zipfile.is_zipfile(os.path.join(attach_dir, file).encode(config.charset)) and
-                mt.minor == 'zip' and request.user.may.read(pagename) and request.user.may.delete(pagename)
-                and request.user.may.write(pagename)):
-                viewlink += ' | <a href="%(baseurl)s/%(urlpagename)s?action=%(action)s&amp;do=unzip&amp;target=%(urlfile)s">%(label_unzip)s</a>' % parmdict
-
+            is_zipfile = zipfile.is_zipfile(os.path.join(attach_dir, file).encode(config.charset))
+            if is_zipfile:
+                is_package = packages.ZipPackage(request, os.path.join(attach_dir, file).encode(config.charset)).isPackage()
+                if is_package and request.user.isSuperUser():
+                    viewlink += ' | <a href="%(baseurl)s/%(urlpagename)s?action=%(action)s&amp;do=install&amp;target=%(urlfile)s">%(label_install)s</a>' % parmdict
+                elif (not is_package and mt.minor == 'zip' and request.user.may.read(pagename) and request.user.may.delete(pagename)
+                      and request.user.may.write(pagename)):
+                    viewlink += ' | <a href="%(baseurl)s/%(urlpagename)s?action=%(action)s&amp;do=unzip&amp;target=%(urlfile)s">%(label_unzip)s</a>' % parmdict
 
             parmdict['viewlink'] = viewlink
             parmdict['del_link'] = del_link