allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [5/7] allura git commit: [#7998] ticket:878 modified js for send attachments
Date Fri, 08 Jan 2016 11:05:45 GMT
[#7998] ticket:878 modified js for send attachments


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/ebd8e6bc
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/ebd8e6bc
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/ebd8e6bc

Branch: refs/heads/ib/7998a
Commit: ebd8e6bc48f00406ab610f617b3311d0301e6af4
Parents: ee2895e
Author: Denis Kotov <deniskkotov@gmail.com>
Authored: Mon Dec 21 21:56:11 2015 +0200
Committer: Denis Kotov <deniskkotov@gmail.com>
Committed: Thu Jan 7 21:17:38 2016 +0200

----------------------------------------------------------------------
 .../forgewiki/templates/wiki/page_edit.html     | 20 +++++++-------------
 ForgeWiki/forgewiki/wiki_main.py                |  5 ++---
 2 files changed, 9 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/ebd8e6bc/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 93b4e59..9f3335a 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -115,20 +115,20 @@
                      '<a href="' + attachment_url + '">' +
                      '<img src="' + attachment_url + '/thumb" alt="Thumbnail"/>' +
                      '</a><br/>' + filename +
-                     '<form method="post" action="' + attachment_url + '">' +
+                     '<form method="post" action="' + attachment_url + '" onsubmit="del_attach(this);
return false;">' +
                        '<input type="hidden" name="delete" value="True"/>' +
                        '<input type="submit" value="Delete File"/>' +
                      '</form>' +
                    '</div>';
       $(new_attach).prependTo($('.attachment_images'));
     } else {
-      var new_attach ='<form method="post" action="' + attachment_url + '">' +
+      var new_attach ='<div><form method="post" action="' + attachment_url + '"
onsubmit="del_attach(this); return false;">' +
                         '<a href="' + attachment_url + '">' + filename + '</a>
(' + filesize + ' bytes)' +
                         '<input type="hidden" name="delete" value="True"/>' +
                         '<span>' +
                           '<input type="submit" value="Delete File"/>' +
                         '</span>' +
-                      '</form>';
+                      '</form></div>';
       $(new_attach).prependTo($('.attachment_files'));
     };
   };
@@ -140,9 +140,6 @@
       data: new FormData($('#attachment_form')[0]),
       processData: false,
       contentType: false,
-      headers: {
-        "X-CSRF-Token": $.cookie('_session_id')
-      },
       success: function(data) {
         var attachment_name = $("#file_info").val();
         var attachment_url = page_url + 'attachment/' + attachment_name;
@@ -151,17 +148,14 @@
     });
   };
 
-  function del_attach(this) {
-    var attr_url = $(this).attr('action');
+  function del_attach(elem) {
+    var attr_url = $(elem).attr('action');
     $.ajax({
       type: "POST",
       url: attr_url,
-      data: $(this).serialize(),
-      headers: {
-        "X-CSRF-Token": $.cookie('_session_id')
-      },
+      data: $(elem).serialize() +"&_session_id=" + $.cookie('_session_id'),
       success:  function() {
-        $(this).parent().remove();
+        $(elem).parent().remove();
       }
     });
   };

http://git-wip-us.apache.org/repos/asf/allura/blob/ebd8e6bc/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 8bfa863..31de5b8 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -593,8 +593,6 @@ class PageController(BaseController, FeedController):
             page = self.page
         else:
             page = self.fake_page()
-        if request.headers.get('X-Requested-With', None) == 'XMLHttpRequest':
-            return
         c.confirmation = W.confirmation
         c.markdown_editor = W.markdown_editor
         c.attachment_add = W.attachment_add
@@ -756,7 +754,8 @@ class PageController(BaseController, FeedController):
             raise exc.HTTPNotFound
         require_access(self.page, 'edit')
         self.page.add_multiple_attachments(file_info)
-        redirect(request.referer)
+        if request.headers.get('X-Requested-With', None) != 'XMLHttpRequest':
+            redirect(request.referer)
 
     @expose('json:')
     @require_post()


Mime
View raw message