1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 15:19:06 +00:00

merge 10.0

This commit is contained in:
杨顺强
2023-09-25 10:22:16 +08:00
11 changed files with 44 additions and 6 deletions

View File

@@ -261,7 +261,7 @@ class OrgGroupsSearchGroups extends Component {
<div className="cur-view-content">
<div className="mt-4 mb-6">
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Groups')}</h4>
<Form>
<Form tag={'div'}>
<FormGroup row>
<Col sm={5}>
<Input type="text" name="query" value={query} placeholder={gettext('Search groups')} onChange={this.handleInputChange} />

View File

@@ -163,7 +163,7 @@ class OrgUsersSearchUsers extends Component {
<div className="cur-view-content">
<div className="mt-4 mb-6">
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Users')}</h4>
<Form>
<Form tag={'div'}>
<FormGroup row>
<Col sm={5}>
<Input type="text" name="query" value={query} placeholder={gettext('Search users')} onChange={this.handleInputChange} />

View File

@@ -104,7 +104,7 @@ class SearchGroups extends Component {
<div className="mt-4 mb-6">
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Groups')}</h4>
<p className="text-secondary small">{gettext('Tip: you can search by keyword in name.')}</p>
<Form>
<Form tag={'div'}>
<FormGroup row>
<Label for="name" sm={1}>{gettext('Name')}</Label>
<Col sm={5}>

View File

@@ -100,7 +100,7 @@ class SearchOrgs extends Component {
<div className="mt-4 mb-6">
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Organizations')}</h4>
<p className="text-secondary small">{gettext('Tip: you can search by keyword in name.')}</p>
<Form>
<Form tag={'div'}>
<FormGroup row>
<Label for="name" sm={1}>{gettext('Name')}</Label>
<Col sm={5}>

View File

@@ -32,6 +32,7 @@ class SearchRepos extends Component {
seafileAPI.sysAdminSearchRepos(name).then((res) => {
this.setState({
loading: false,
errorMsg: '',
repos: res.data.repo_list
});
}).catch((error) => {
@@ -91,7 +92,7 @@ class SearchRepos extends Component {
<div className="mt-4 mb-6">
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Libraries')}</h4>
<p className="text-secondary small">{gettext('Tip: you can search by keyword in name or ID.')}</p>
<Form>
<Form tag={'div'}>
<FormGroup row>
<Label for="name" sm={1}>{gettext('Name or ID')}</Label>
<Col sm={5}>

View File

@@ -298,7 +298,7 @@ class SearchUsers extends Component {
<div className="cur-view-content">
<div className="mt-4 mb-6">
<h4 className="border-bottom font-weight-normal mb-2 pb-1">{gettext('Search Users')}</h4>
<Form>
<Form tag={'div'}>
<FormGroup row>
<Col sm={5}>
<Input type="text" name="query" value={query} placeholder={gettext('Search users')} onChange={this.handleInputChange} />

View File

@@ -23,6 +23,7 @@ from seahub.api2.throttling import UserRateThrottle
from seahub.api2.permissions import CanGenerateShareLink
from seahub.constants import PERMISSION_READ_WRITE, PERMISSION_READ, PERMISSION_PREVIEW_EDIT, PERMISSION_PREVIEW
from seahub.share.models import FileShare
from seahub.share.decorators import check_share_link_count
from seahub.utils import is_org_context, get_password_strength_level, \
is_valid_password, gen_shared_link
from seahub.utils.timeutils import datetime_to_isoformat_timestr
@@ -41,6 +42,7 @@ class MultiShareLinks(APIView):
permission_classes = (IsAuthenticated, CanGenerateShareLink)
throttle_classes = (UserRateThrottle,)
@check_share_link_count
def post(self, request):
# argument check
repo_id = request.data.get('repo_id', None)
@@ -213,6 +215,7 @@ class MultiShareLinksBatch(APIView):
permission_classes = (IsAuthenticated, CanGenerateShareLink)
throttle_classes = (UserRateThrottle,)
@check_share_link_count
def post(self, request):
""" Create multi share link.
Permission checking:

View File

@@ -31,6 +31,7 @@ from seahub.api2.permissions import CanGenerateShareLink, IsProVersion
from seahub.constants import PERMISSION_READ_WRITE, PERMISSION_READ, \
PERMISSION_PREVIEW_EDIT, PERMISSION_PREVIEW
from seahub.share.models import FileShare, UploadLinkShare, check_share_link_access
from seahub.share.decorators import check_share_link_count
from seahub.utils import gen_shared_link, is_org_context, normalize_file_path, \
normalize_dir_path, is_pro_version, get_file_type_and_ext, \
check_filename_with_rename, gen_file_upload_url, \
@@ -291,6 +292,7 @@ class ShareLinks(APIView):
return Response(result)
@check_share_link_count
def post(self, request):
""" Create share link.

View File

@@ -31,3 +31,5 @@ HASH_URLS = {
'GROUP_DISCUSS': settings.SITE_ROOT + '#group/%(group_id)s/discussions/',
'SYS_REPO_ADMIN': settings.SITE_ROOT + 'sysadmin/#all-libs/',
}
REPO_SHARE_LINK_COUNT_LIMIT = 500000

View File

@@ -4,9 +4,13 @@ from django.conf import settings
from django.shortcuts import render
from django.utils.translation import gettext as _
from rest_framework import status
from seahub.api2.utils import api_error
from seahub.share.models import FileShare, UploadLinkShare
from seahub.utils import render_error
from seahub.utils import normalize_cache_key, is_pro_version, redirect_to_login
from seahub.constants import REPO_SHARE_LINK_COUNT_LIMIT
def share_link_audit(func):
@@ -85,3 +89,26 @@ def share_link_login_required(func):
return func(request, *args, **kwargs)
return _decorated
def check_share_link_count(func):
def _decorated(view, request, *args, **kwargs):
repo_id = request.data.get('repo_id', None)
share_link_num = request.data.get('number', 1)
try:
share_link_num = int(share_link_num)
except ValueError:
error_msg = 'number invalid.'
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
link_count = FileShare.objects.get_share_link_count_by_repo(repo_id)
if link_count + share_link_num > REPO_SHARE_LINK_COUNT_LIMIT:
error_msg = _("The number of share link exceeds the limit.")
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
return func(view, request, *args, **kwargs)
return _decorated

View File

@@ -180,6 +180,9 @@ class FileShareManager(models.Manager):
def get_valid_dir_link_by_token(self, token):
return self._get_valid_file_share_by_token(token)
def get_share_link_count_by_repo(self, repo_id):
return super(FileShareManager, self).filter(repo_id=repo_id).count()
class ExtraSharePermissionManager(models.Manager):
def get_user_permission(self, repo_id, username):