From c79f720bb948c53ae30c9553b0cbdb1341c15964 Mon Sep 17 00:00:00 2001 From: llj Date: Sat, 5 Jul 2014 14:18:26 +0800 Subject: [PATCH] clean up code for 'link share'; fixed bug for 'login_require_ajax' --- seahub/auth/decorators.py | 2 +- .../templates/snippets/file_share_popup.html | 8 ---- seahub/templates/snippets/shared_link_js.html | 39 +++---------------- 3 files changed, 6 insertions(+), 43 deletions(-) diff --git a/seahub/auth/decorators.py b/seahub/auth/decorators.py index 0d043471b0..57def06efc 100644 --- a/seahub/auth/decorators.py +++ b/seahub/auth/decorators.py @@ -4,7 +4,7 @@ except ImportError: from django.utils.functional import update_wrapper, wraps # Python 2.4 fallback. from seahub.auth import REDIRECT_FIELD_NAME -from django.http import HttpResponseRedirect, HttpResponse +from django.http import HttpResponseRedirect, HttpResponse, Http404 from django.utils.decorators import available_attrs from django.utils.http import urlquote import simplejson as json diff --git a/seahub/templates/snippets/file_share_popup.html b/seahub/templates/snippets/file_share_popup.html index 7d01c2d26f..bcc7e91864 100644 --- a/seahub/templates/snippets/file_share_popup.html +++ b/seahub/templates/snippets/file_share_popup.html @@ -38,14 +38,6 @@
- -

diff --git a/seahub/templates/snippets/shared_link_js.html b/seahub/templates/snippets/shared_link_js.html index 94d314a66a..b4e3c86a45 100644 --- a/seahub/templates/snippets/shared_link_js.html +++ b/seahub/templates/snippets/shared_link_js.html @@ -231,8 +231,7 @@ $('#gen-link-btn').click(function() { form = $('#link-options'), form_id = form.attr('id'), use_passwd = $('#link-passwd-switch').attr('checked'), - set_expiration = $('#link-expire-switch').attr('checked'), - passwd, passwd_again, expire_days, post_data; + passwd, passwd_again, post_data; if (use_passwd) { passwd = $('input[name="passwd"]', form).val(); @@ -259,20 +258,6 @@ $('#gen-link-btn').click(function() { post_data = {'use_passwd': 0}; } - if (set_expiration) { - expire_days = $('input[name="expire-days"]', form).val(); - if (!$.trim(expire_days)) { - apply_form_error(form_id, "{% trans "Please enter days" %}"); - return false; - } - if (Math.floor(expire_days) == expire_days && $.isNumeric(expire_days)) { - post_data["expire_days"] = expire_days; - } else { - apply_form_error(form_id, "{% trans "Please enter valid days" %}"); - return false; - } - } - $.ajax({ url: gen_link_btn.data('url'), type: 'POST', @@ -285,9 +270,9 @@ $('#gen-link-btn').click(function() { gen_link_btn.addClass('hide'); $('#link-options, #link-options .error').addClass('hide'); - $('#link-passwd, #link-expire').hide(); // slideDown use 'show()' - $('#link-passwd-switch, #link-expire-switch').attr('checked', false).parent().removeClass('checkbox-checked'); - $('[type="password"], [name="expire-days"]', form).val('').attr('disabled', false).removeClass('input-disabled'); + $('#link-passwd').hide(); // slideDown use 'show()' + $('#link-passwd-switch').attr('checked', false).parent().removeClass('checkbox-checked'); + $('[type="password"]', form).val('').attr('disabled', false).removeClass('input-disabled'); $('#shared-link-text, #link-send-form input[name="file_shared_link"]').val(link); $('#main').append('

' + link + '

'); @@ -301,7 +286,7 @@ $('#gen-link-btn').click(function() { feedback(jQuery.parseJSON(xhr.responseText).error, 'error'); } else { feedback("{% trans "Failed. Please check the network." %}", 'error'); - } + } } }); return false; @@ -513,17 +498,3 @@ $('#link-passwd-switch').click(function () { pwd_input.attr('disabled', true).addClass('input-disabled'); } }); - -$('#link-expire-switch').click(function () { - var form = $('#link-options'), - days_input = $('input[name="expire-days"]', form); - var link_expire = $('#link-expire'); - - if ($(this).attr('checked')) { - link_expire.slideDown(100); - days_input.attr('disabled', false).removeClass('input-disabled'); - } else { - link_expire.slideUp(100); - days_input.attr('disabled', true).addClass('input-disabled'); - } -});