changeset 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 2161d292e1af
children 985659f4ed55
files MoinMoin/action/AttachFile.py docs/CHANGES
diffstat 2 files changed, 19 insertions(+), 13 deletions(-) [+]
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
--- a/docs/CHANGES	Sun Oct 22 03:28:33 2006 +0200
+++ b/docs/CHANGES	Sun Oct 22 17:30:23 2006 +0200
@@ -374,7 +374,9 @@
       version). The file has some standard css inside (evaluated on all MSIE
       versions) and some * html hacks that only IE < 7 will read.
       HINT: if you use custom themes, you want to update them in the same way.
-
+    * AttachFile displays the upload dialogue now at top, this avoids lots of
+      scrolling if you attach some new files to a page that already has lots of
+      files attached.