From 3f1ab88d6b1c42b231b78ecca5d75c55735535d7 Mon Sep 17 00:00:00 2001 From: lian Date: Mon, 8 Jun 2020 09:59:11 +0800 Subject: [PATCH 01/27] send notice email when user quota is almost full (#4577) Co-authored-by: lian --- .../management/commands/check_user_quota.py | 79 +++++++++++++++++++ seahub/templates/user_quota_full.html | 18 +++++ 2 files changed, 97 insertions(+) create mode 100644 seahub/base/management/commands/check_user_quota.py create mode 100644 seahub/templates/user_quota_full.html diff --git a/seahub/base/management/commands/check_user_quota.py b/seahub/base/management/commands/check_user_quota.py new file mode 100644 index 0000000000..1818f7945c --- /dev/null +++ b/seahub/base/management/commands/check_user_quota.py @@ -0,0 +1,79 @@ +# Copyright (c) 2012-2016 Seafile Ltd. + +from django.core.management.base import BaseCommand +from django.utils.translation import ugettext as _ +from django.utils import translation + +from seaserv import ccnet_api, seafile_api + +from seahub.base.accounts import User +from seahub.profile.models import Profile +from seahub.utils import IS_EMAIL_CONFIGURED, send_html_email, \ + get_site_name + + +class Command(BaseCommand): + + help = "Used to send notice email when user's quota is almost full." + + def __init__(self, *args, **kwargs): + + super(Command, self).__init__(*args, **kwargs) + + def add_arguments(self, parser): + + parser.add_argument( + '--email', + help="Only check this user's quota." + ) + + def get_user_language(self, username): + return Profile.objects.get_user_language(username) + + def send_email(self, email): + + # save current language + cur_language = translation.get_language() + + # get and active user language + user_language = self.get_user_language(email) + translation.activate(user_language) + + orgs = ccnet_api.get_orgs_by_user(email) + if orgs: + org_id = orgs[0].org_id + quota_usage = seafile_api.get_org_user_quota_usage(org_id, email) + quota_total = seafile_api.get_org_user_quota(org_id, email) + else: + quota_usage = seafile_api.get_user_self_usage(email) + quota_total = seafile_api.get_user_quota(email) + + if IS_EMAIL_CONFIGURED and quota_total > 0 and quota_usage/quota_total > 0.9: + + data = {'email': email, 'quota_total': quota_total, 'quota_usage': quota_usage} + contact_email = Profile.objects.get_contact_email_by_user(email) + + print('Send email to %s(%s)' % (contact_email, email)) + + send_html_email(_(u'Your quota is almost full on %s') % get_site_name(), + 'user_quota_full.html', data, None, [contact_email]) + + # restore current language + translation.activate(cur_language) + + def handle(self, *args, **options): + + email = options.get('email', None) + if email: + try: + User.objects.get(email=email) + + self.send_email(email) + except User.DoesNotExist: + print('User %s not found' % email) + else: + user_obj_list = ccnet_api.get_emailusers('DB', -1, -1) + for user in user_obj_list: + self.send_email(user.email) + + print("Done") diff --git a/seahub/templates/user_quota_full.html b/seahub/templates/user_quota_full.html new file mode 100644 index 0000000000..46beab0384 --- /dev/null +++ b/seahub/templates/user_quota_full.html @@ -0,0 +1,18 @@ +{% extends 'email_base.html' %} + +{% load i18n seahub_tags %} + +{% block email_con %} + +{% autoescape off %} + +

{% trans "Hi," %}

+ +

+{% blocktrans %}Your quota is almost full on {{ site_name }}.{% endblocktrans %} +

+

{% trans "Used:" %} {{quota_usage|seahub_filesizeformat}} / {{quota_total|seahub_filesizeformat}}

+ +{% endautoescape %} + +{% endblock %} From 360c57c11b14f7c82393fb3aa3a43b9bf25266ec Mon Sep 17 00:00:00 2001 From: llj Date: Mon, 8 Jun 2020 10:14:23 +0800 Subject: [PATCH 02/27] ['about' dialog] modified the year (#4581) --- frontend/src/components/dialog/about-dialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/dialog/about-dialog.js b/frontend/src/components/dialog/about-dialog.js index c0165df475..5b64f44da5 100644 --- a/frontend/src/components/dialog/about-dialog.js +++ b/frontend/src/components/dialog/about-dialog.js @@ -32,7 +32,7 @@ class AboutDialog extends React.Component {

logo

-

{gettext('Server Version: ')}{seafileVersion}
© 2019 {gettext('Seafile')}

+

{gettext('Server Version: ')}{seafileVersion}
© 2020 {gettext('Seafile')}

{this.renderExternalAboutLinks()}

{gettext('About Us')}

From 968b2c90349ffa1c4060ba9ce5de70d0552b311e Mon Sep 17 00:00:00 2001 From: lian Date: Wed, 10 Jun 2020 17:11:01 +0800 Subject: [PATCH 03/27] update is_inst_admin check (#4584) Co-authored-by: lian --- seahub/api2/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/seahub/api2/views.py b/seahub/api2/views.py index 21894d136f..2ac83eb4ca 100644 --- a/seahub/api2/views.py +++ b/seahub/api2/views.py @@ -328,7 +328,12 @@ class AccountInfo(APIView): info['is_staff'] = request.user.is_staff if getattr(settings, 'MULTI_INSTITUTION', False): - info['is_inst_admin'] = request.user.inst_admin + from seahub.institutions.models import InstitutionAdmin + try: + InstitutionAdmin.objects.get(user=email) + info['is_inst_admin'] = True + except InstitutionAdmin.DoesNotExist: + info['is_inst_admin'] = False interval = UserOptions.objects.get_file_updates_email_interval(email) info['email_notification_interval'] = 0 if interval is None else interval From e954ac763e2c8002a3e71419d37309c73d7aef1d Mon Sep 17 00:00:00 2001 From: lian Date: Fri, 12 Jun 2020 18:11:07 +0800 Subject: [PATCH 04/27] use user name when send notice email (#4587) Co-authored-by: lian --- seahub/notifications/management/commands/send_notices.py | 2 ++ seahub/notifications/templates/notifications/notice_email.html | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/seahub/notifications/management/commands/send_notices.py b/seahub/notifications/management/commands/send_notices.py index bfba65fde0..e1dcfe2c7b 100644 --- a/seahub/notifications/management/commands/send_notices.py +++ b/seahub/notifications/management/commands/send_notices.py @@ -298,12 +298,14 @@ class Command(BaseCommand): if not notices: continue + user_name = email2nickname(to_user) contact_email = Profile.objects.get_contact_email_by_user(to_user) to_user = contact_email # use contact email if any c = { 'to_user': to_user, 'notice_count': count, 'notices': notices, + 'user_name': user_name, } try: diff --git a/seahub/notifications/templates/notifications/notice_email.html b/seahub/notifications/templates/notifications/notice_email.html index 2eca1b91ea..50f289d69f 100644 --- a/seahub/notifications/templates/notifications/notice_email.html +++ b/seahub/notifications/templates/notifications/notice_email.html @@ -4,7 +4,7 @@ {% block email_con %} -

{% blocktrans with name=to_user|email2nickname %}Hi, {{ name }}{% endblocktrans %}

+

{% blocktrans with name=user_name %}Hi, {{ name }}{% endblocktrans %}

{% blocktrans count num=notice_count %} You've got 1 new notice on {{ site_name }}: From 1a3aca68e37fa86776969d2ac3bdac706895f28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=81=A5=E8=BE=89?= <40563566+jianhw@users.noreply.github.com> Date: Mon, 15 Jun 2020 12:56:29 +0800 Subject: [PATCH 05/27] improve file history list (#4586) --- seahub/api2/endpoints/file_history.py | 30 +++++++++++++++++++++++---- seahub/utils/__init__.py | 4 ++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/seahub/api2/endpoints/file_history.py b/seahub/api2/endpoints/file_history.py index 5558eca84e..94ac02faa9 100644 --- a/seahub/api2/endpoints/file_history.py +++ b/seahub/api2/endpoints/file_history.py @@ -1,5 +1,6 @@ # Copyright (c) 2012-2016 Seafile Ltd. import logging +from datetime import datetime from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAuthenticated @@ -108,6 +109,14 @@ class FileHistoryView(APIView): error_msg = 'Permission denied.' return api_error(status.HTTP_403_FORBIDDEN, error_msg) + # get repo history limit + try: + keep_days = seafile_api.get_repo_history_limit(repo_id) + except Exception as e: + logger.error(e) + error_msg = 'Internal Server Error' + return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) + # get file history limit = request.GET.get('limit', 50) try: @@ -125,9 +134,14 @@ class FileHistoryView(APIView): result = [] for commit in file_revisions: - info = get_file_history_info(commit, avatar_size) - info['path'] = path - result.append(info) + present_time = datetime.utcnow() + history_time = datetime.utcfromtimestamp(commit.ctime) + if (keep_days == -1) or ((present_time - history_time).days < keep_days): + info = get_file_history_info(commit, avatar_size) + info['path'] = path + result.append(info) + + next_start_commit = next_start_commit if result else False return Response({ "data": result, @@ -182,11 +196,19 @@ class NewFileHistoryView(APIView): error_msg = 'Permission denied.' return api_error(status.HTTP_403_FORBIDDEN, error_msg) + # get repo history limit + try: + history_limit = seafile_api.get_repo_history_limit(repo_id) + except Exception as e: + logger.error(e) + error_msg = 'Internal Server Error' + return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) + start = (page - 1) * per_page count = per_page try: - file_revisions, total_count = get_file_history(repo_id, path, start, count) + file_revisions, total_count = get_file_history(repo_id, path, start, count, history_limit) except Exception as e: logger.error(e) error_msg = 'Internal Server Error' diff --git a/seahub/utils/__init__.py b/seahub/utils/__init__.py index 0ec17b50ec..df3a4700f5 100644 --- a/seahub/utils/__init__.py +++ b/seahub/utils/__init__.py @@ -712,11 +712,11 @@ if EVENTS_CONFIG_FILE: def get_org_user_events(org_id, username, start, count): return _get_events(username, start, count, org_id=org_id) - def get_file_history(repo_id, path, start, count): + def get_file_history(repo_id, path, start, count, history_limit=-1): """Return file histories """ with _get_seafevents_session() as session: - res = seafevents.get_file_history(session, repo_id, path, start, count) + res = seafevents.get_file_history(session, repo_id, path, start, count, history_limit) return res def get_log_events_by_time(log_type, tstart, tend): From 389f8befee35367181236e24ffec1e6c3a65c28d Mon Sep 17 00:00:00 2001 From: llj Date: Mon, 15 Jun 2020 16:27:00 +0800 Subject: [PATCH 06/27] [terms] rewrote 'terms view' with react (#4589) --- frontend/config/webpack.config.dev.js | 5 +++ frontend/config/webpack.config.prod.js | 1 + frontend/src/tc-view.js | 39 +++++++++++++++++++ .../termsandconditions/tc_view_terms.html | 8 ---- .../tc_view_terms_react.html | 17 ++++++++ thirdpart/termsandconditions/views.py | 3 +- 6 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 frontend/src/tc-view.js delete mode 100644 seahub/templates/termsandconditions/tc_view_terms.html create mode 100644 seahub/templates/termsandconditions/tc_view_terms_react.html diff --git a/frontend/config/webpack.config.dev.js b/frontend/config/webpack.config.dev.js index 31f796dd1a..fdc9f4bf80 100644 --- a/frontend/config/webpack.config.dev.js +++ b/frontend/config/webpack.config.dev.js @@ -59,6 +59,11 @@ module.exports = { require.resolve('react-dev-utils/webpackHotDevClient'), paths.appSrc + "/tc-accept.js", ], + TCView: [ + require.resolve('./polyfills'), + require.resolve('react-dev-utils/webpackHotDevClient'), + paths.appSrc + "/tc-view.js", + ], userNotifications: [ require.resolve('./polyfills'), require.resolve('react-dev-utils/webpackHotDevClient'), diff --git a/frontend/config/webpack.config.prod.js b/frontend/config/webpack.config.prod.js index 35ae90a4c1..86261bdffd 100644 --- a/frontend/config/webpack.config.prod.js +++ b/frontend/config/webpack.config.prod.js @@ -60,6 +60,7 @@ module.exports = { entry: { markdownEditor: [require.resolve('./polyfills'), paths.appIndexJs], TCAccept: [require.resolve('./polyfills'), paths.appSrc + "/tc-accept.js"], + TCView: [require.resolve('./polyfills'), paths.appSrc + "/tc-view.js"], userNotifications: [require.resolve('./polyfills'), paths.appSrc + "/user-notifications.js"], wiki: [require.resolve('./polyfills'), paths.appSrc + "/wiki.js"], fileHistory: [require.resolve('./polyfills'), paths.appSrc + "/file-history.js"], diff --git a/frontend/src/tc-view.js b/frontend/src/tc-view.js new file mode 100644 index 0000000000..166682ab07 --- /dev/null +++ b/frontend/src/tc-view.js @@ -0,0 +1,39 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import Logo from './components/logo'; +import Account from './components/common/account'; +import TermsPreviewWidget from './components/terms-preview-widget'; + +import './css/tc-accept.css'; + +const { + termsName, + termsText +} = window.tc; + +class TCView extends React.Component { + + render() { + return ( +

+
+ + +
+
+
+

+
+ +
+
+
+
+ ); + } +} + +ReactDOM.render( + , + document.getElementById('wrapper') +); diff --git a/seahub/templates/termsandconditions/tc_view_terms.html b/seahub/templates/termsandconditions/tc_view_terms.html deleted file mode 100644 index 37717674f5..0000000000 --- a/seahub/templates/termsandconditions/tc_view_terms.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends 'base_wide_page.html' %} - -{% block wide_page_content %} -

{{ terms.name|safe }}

-
- {{ terms.text|safe }} -
-{% endblock %} diff --git a/seahub/templates/termsandconditions/tc_view_terms_react.html b/seahub/templates/termsandconditions/tc_view_terms_react.html new file mode 100644 index 0000000000..fd8ee8bbc0 --- /dev/null +++ b/seahub/templates/termsandconditions/tc_view_terms_react.html @@ -0,0 +1,17 @@ +{% extends "base_for_react.html" %} +{% load seahub_tags i18n %} +{% load render_bundle from webpack_loader %} + +{% block extra_style %} +{% render_bundle 'TCAccept' 'css' %} +{% endblock %} + +{% block extra_script %} + +{% render_bundle 'TCView' 'js' %} +{% endblock %} diff --git a/thirdpart/termsandconditions/views.py b/thirdpart/termsandconditions/views.py index 26ba2ff363..6af292476a 100644 --- a/thirdpart/termsandconditions/views.py +++ b/thirdpart/termsandconditions/views.py @@ -34,7 +34,8 @@ class TermsView(DetailView): url: /terms/view """ - template_name = "termsandconditions/tc_view_terms.html" + #template_name = "termsandconditions/tc_view_terms.html" + template_name = "termsandconditions/tc_view_terms_react.html" context_object_name = 'terms' def get_object(self, queryset=None): From 8fcfe292dcffcfde7c80bee58112f3639d1541c3 Mon Sep 17 00:00:00 2001 From: lian Date: Thu, 18 Jun 2020 14:25:47 +0800 Subject: [PATCH 07/27] add is_dir_downloadable check when download folder (#4590) Co-authored-by: lian --- seahub/api2/endpoints/zip_task.py | 16 ++++++++++++++-- tests/api/endpoints/test_zip_task.py | 11 +++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/seahub/api2/endpoints/zip_task.py b/seahub/api2/endpoints/zip_task.py index 6b1a1a3d5b..b02fe2a22c 100644 --- a/seahub/api2/endpoints/zip_task.py +++ b/seahub/api2/endpoints/zip_task.py @@ -72,7 +72,13 @@ class ZipTaskView(APIView): return api_error(status.HTTP_404_NOT_FOUND, error_msg) # permission check - if not check_folder_permission(request, repo_id, parent_dir): + repo_folder_permission = check_folder_permission(request, repo_id, parent_dir) + if not repo_folder_permission: + error_msg = 'Permission denied.' + return api_error(status.HTTP_403_FORBIDDEN, error_msg) + + if not json.loads(seafile_api.is_dir_downloadable(repo_id, parent_dir, + request.user.username, repo_folder_permission))['is_downloadable']: error_msg = 'Permission denied.' return api_error(status.HTTP_403_FORBIDDEN, error_msg) @@ -192,7 +198,13 @@ class ZipTaskView(APIView): return api_error(status.HTTP_404_NOT_FOUND, error_msg) # permission check - if parse_repo_perm(check_folder_permission(request, repo_id, parent_dir)).can_download is False: + repo_folder_permission = check_folder_permission(request, repo_id, parent_dir) + if parse_repo_perm(repo_folder_permission).can_download is False: + error_msg = 'Permission denied.' + return api_error(status.HTTP_403_FORBIDDEN, error_msg) + + if not json.loads(seafile_api.is_dir_downloadable(repo_id, parent_dir, + request.user.username, repo_folder_permission))['is_downloadable']: error_msg = 'Permission denied.' return api_error(status.HTTP_403_FORBIDDEN, error_msg) diff --git a/tests/api/endpoints/test_zip_task.py b/tests/api/endpoints/test_zip_task.py index b5c43e75f3..bdc05dc531 100644 --- a/tests/api/endpoints/test_zip_task.py +++ b/tests/api/endpoints/test_zip_task.py @@ -27,6 +27,10 @@ class ZipTaskViewTest(BaseTestCase): self.remove_repo() def test_can_get_download_dir_zip_token(self): + + if not LOCAL_PRO_DEV_ENV: + return + self.login_as(self.user) parent_dir = '/' @@ -41,6 +45,9 @@ class ZipTaskViewTest(BaseTestCase): def test_can_get_download_multi_zip_token(self): + if not LOCAL_PRO_DEV_ENV: + return + # create another folder for download multi another_folder_name = 'another_folder_name' seafile_api.post_dir(repo_id=self.repo.id, @@ -61,6 +68,10 @@ class ZipTaskViewTest(BaseTestCase): assert len(json_resp['zip_token']) == 36 def test_can_get_zip_token_with_invalid_repo_permission(self): + + if not LOCAL_PRO_DEV_ENV: + return + self.login_as(self.admin) parent_dir = '/' From ce875720c839ac1365048a97b72cb2d8b6577833 Mon Sep 17 00:00:00 2001 From: sniper-py Date: Thu, 18 Jun 2020 14:37:25 +0800 Subject: [PATCH 08/27] dist 7.1 --- .github/workflows/dist.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index 6a925f8334..88cf70d932 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - "7.1" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3900f4d7490eeb6957edd37d6cf8a991eaba8790 Mon Sep 17 00:00:00 2001 From: llj Date: Sat, 20 Jun 2020 11:07:25 +0800 Subject: [PATCH 09/27] [jquery] upgraded it from v3.3.1 to the latest v3.5.1 (#4593) --- media/js/base.js | 4 ++-- .../invitations/templates/invitations/token_view.html | 2 +- seahub/share/templates/share/share_link_audit.html | 6 +++--- seahub/templates/decrypt_repo_form.html | 2 +- seahub/templates/feedback.html | 10 ---------- seahub/templates/registration/login.html | 4 ++-- .../templates/registration/password_change_form.html | 8 ++++---- seahub/templates/registration/password_set_form.html | 6 +++--- seahub/templates/registration/registration_form.html | 8 ++++---- seahub/templates/share_access_validation.html | 2 +- seahub/templates/snippets/search_js.html | 4 ++-- seahub/templates/sysadmin/sudo_mode.html | 2 +- static/scripts/lib/jquery.min.js | 4 ++-- 13 files changed, 26 insertions(+), 36 deletions(-) delete mode 100644 seahub/templates/feedback.html diff --git a/media/js/base.js b/media/js/base.js index 675dae8e21..225ff44e34 100644 --- a/media/js/base.js +++ b/media/js/base.js @@ -47,7 +47,7 @@ $(document).on('click', function(e) { // search: disable submit when input nothing $('.search-form').on('submit', function() { - if (!$.trim($(this).find('.search-input').val())) { + if (!$(this).find('.search-input').val().trim()) { return false; } }); @@ -402,7 +402,7 @@ function userInputOPtionsForSelect2(user_search_url) { createSearchChoice: function(term) { return { - 'id': $.trim(term) + 'id': term.trim() }; }, diff --git a/seahub/invitations/templates/invitations/token_view.html b/seahub/invitations/templates/invitations/token_view.html index 985a70c8c9..b687cc1d70 100644 --- a/seahub/invitations/templates/invitations/token_view.html +++ b/seahub/invitations/templates/invitations/token_view.html @@ -22,7 +22,7 @@ {% block extra_script %} -{% endblock %} - -{% block extra_script %} -{% endblock %} diff --git a/seahub/templates/registration/login.html b/seahub/templates/registration/login.html index 207ce67af5..2aa2287d78 100644 --- a/seahub/templates/registration/login.html +++ b/seahub/templates/registration/login.html @@ -149,11 +149,11 @@ $('#refresh-captcha').on('click', function() { }); $('#login-form').on('submit', function(){ - if (!$.trim($('input[name="login"]').val())) { + if (!$('input[name="login"]').val().trim()) { $('.error').removeClass('hide').html("{% trans "Email or username cannot be blank" %}"); return false; } - if (!$.trim($('input[name="password"]').val())) { + if (!$('input[name="password"]').val().trim()) { $('.error').removeClass('hide').html("{% trans "Password cannot be blank" %}"); return false; } diff --git a/seahub/templates/registration/password_change_form.html b/seahub/templates/registration/password_change_form.html index db2ffa6255..ee269df159 100644 --- a/seahub/templates/registration/password_change_form.html +++ b/seahub/templates/registration/password_change_form.html @@ -44,7 +44,7 @@ $("#id_new_password1") }) .on('keyup', function() { var pwd = $(this).val(); - if ($.trim(pwd)) { + if (pwd.trim()) { var level = getStrengthLevel(pwd); showStrength(level); } else { @@ -54,9 +54,9 @@ $("#id_new_password1") {% endif %} $('form').on('submit', function(){ - var old_pwd = $.trim($('input[name="old_password"]').val()), - pwd1 = $.trim($('input[name="new_password1"]').val()), - pwd2 = $.trim($('input[name="new_password2"]').val()); + var old_pwd = $('input[name="old_password"]').val().trim(), + pwd1 = $('input[name="new_password1"]').val().trim(), + pwd2 = $('input[name="new_password2"]').val().trim(); if (!old_pwd) { $('.error').html("{% trans "Current password cannot be blank" %}").removeClass('hide'); diff --git a/seahub/templates/registration/password_set_form.html b/seahub/templates/registration/password_set_form.html index 1723f86a25..e3716d3b25 100644 --- a/seahub/templates/registration/password_set_form.html +++ b/seahub/templates/registration/password_set_form.html @@ -47,7 +47,7 @@ $("#id_new_password1") }) .on('keyup', function() { var pwd = $(this).val(); - if ($.trim(pwd)) { + if (pwd.trim()) { var level = getStrengthLevel(pwd); showStrength(level); } else { @@ -57,8 +57,8 @@ $("#id_new_password1") {% endif %} $('form').on('submit', function(){ - var pwd1 = $.trim($('input[name="new_password1"]').val()), - pwd2 = $.trim($('input[name="new_password2"]').val()); + var pwd1 = $('input[name="new_password1"]').val().trim(), + pwd2 = $('input[name="new_password2"]').val().trim(); if (!pwd1) { $('.error').html("{% trans "Password cannot be blank" %}").removeClass('hide'); diff --git a/seahub/templates/registration/registration_form.html b/seahub/templates/registration/registration_form.html index 5e3e86cac2..d179fec0ed 100644 --- a/seahub/templates/registration/registration_form.html +++ b/seahub/templates/registration/registration_form.html @@ -69,7 +69,7 @@ $("#id_password1") }) .on('keyup', function() { var pwd = $(this).val(); - if ($.trim(pwd)) { + if (pwd.trim()) { var level = getStrengthLevel(pwd); showStrength(level); } else { @@ -79,9 +79,9 @@ $("#id_password1") {% endif %} $('#signup-form').on('submit', function(){ - var email = $.trim($('input[name="email"]').val()), - pwd1 = $.trim($('input[name="password1"]').val()), - pwd2 = $.trim($('input[name="password2"]').val()); + var email = $('input[name="email"]').val().trim(), + pwd1 = $('input[name="password1"]').val().trim(), + pwd2 = $('input[name="password2"]').val().trim(); if (!email) { $('.error').html("{% trans "Email cannot be blank" %}").removeClass('hide'); diff --git a/seahub/templates/share_access_validation.html b/seahub/templates/share_access_validation.html index b2f22b7dc7..4bb1afa265 100644 --- a/seahub/templates/share_access_validation.html +++ b/seahub/templates/share_access_validation.html @@ -28,7 +28,7 @@ $('#share-passwd-form').on('submit', function() { var form = $(this), pwd = $('[name="password"]', form).val(), err = $('.error',form); - if (!$.trim(pwd)) { + if (!pwd.trim()) { err.html("{% trans "Please enter the password." %}").removeClass('hide'); return false; } diff --git a/seahub/templates/snippets/search_js.html b/seahub/templates/snippets/search_js.html index c4452133d1..8202176464 100644 --- a/seahub/templates/snippets/search_js.html +++ b/seahub/templates/snippets/search_js.html @@ -1,6 +1,6 @@ // search-form: top-search-form, advanced-search-form, search-form in search result page $('.search-form').on('submit', function() { - if (!$.trim($(this).find('.search-input').val())) { + if (!$(this).find('.search-input').val().trim()) { return false; } }); @@ -23,7 +23,7 @@ $('.search-filetypes .item:last-child').on('click', function() { $('#advanced-search-form').on('submit', function() { if ($('#custom-search-ftypes').attr('checked') && $('.custom-ftype-options .checkbox-checked').length == 0 && - !$.trim($('.custom-ftype-options .fileext-input').val())) { + $('.custom-ftype-options .fileext-input').val().trim()) { $(this).find('.error').removeClass('hide'); return false; } diff --git a/seahub/templates/sysadmin/sudo_mode.html b/seahub/templates/sysadmin/sudo_mode.html index c4023940d8..5f99b8eeb1 100644 --- a/seahub/templates/sysadmin/sudo_mode.html +++ b/seahub/templates/sysadmin/sudo_mode.html @@ -31,7 +31,7 @@