diff MoinMoin/action/AttachFile.py @ 1635:a41c60e53ddd

display upload attachment form at top, avoids lots of scrolling
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 22 Oct 2006 17:30:23 +0200
parents 435e0748d573
children 5b15b6e010cf
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Sun Oct 22 03:28:33 2006 +0200
+++ b/MoinMoin/action/AttachFile.py	Sun Oct 22 17:30:23 2006 +0200
@@ -448,22 +448,17 @@
         request.write('<p>%s</p>' % _('You are not allowed to view this page.'))
         return
 
-    request.write('<h2>' + _("Attached Files") + '</h2>')
-    request.write(_get_filelist(request, pagename))
+    writeable = request.user.may.write(pagename)
 
-    if not request.user.may.write(pagename):
-        request.write('<p>%s</p>' % _('You are not allowed to attach a file to this page.'))
-        return
-
-    if request.form.get('drawing', [None])[0]:
-        send_hotdraw(pagename, request)
-        return
-
-    request.write('<h2>' + _("New Attachment") + '</h2><p>' +
+    # First send out the upload new attachment form on top of everything else.
+    # This avoids usability issues if you have to scroll down a lot to upload
+    # a new file when the page already has lots of attachments:
+    if writeable:
+        request.write('<h2>' + _("New Attachment") + '</h2><p>' +
 _("""An upload will never overwrite an existing file. If there is a name
 conflict, you have to rename the file that you want to upload.
 Otherwise, if "Rename to" is left blank, the original filename will be used.""") + '</p>')
-    request.write("""
+        request.write("""
 <form action="%(baseurl)s/%(pagename)s" method="POST" enctype="multipart/form-data">
 <dl>
 <dt>%(upload_label_file)s</dt>
@@ -491,6 +486,15 @@
 #<dd><input type="text" name="mime" size="50"></dd>
 #    'upload_label_mime': _('MIME Type (optional)'),
 
+    request.write('<h2>' + _("Attached Files") + '</h2>')
+    request.write(_get_filelist(request, pagename))
+
+    if not writeable:
+        request.write('<p>%s</p>' % _('You are not allowed to attach a file to this page.'))
+
+    if writeable and request.form.get('drawing', [None])[0]:
+        send_hotdraw(pagename, request)
+
 
 #############################################################################
 ### Web interface for file upload, viewing and deletion