mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 00:00:00 +00:00
Merge branch '8.0' into master
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { gettext } from '../../../utils/constants';
|
import { gettext, isPro } from '../../../utils/constants';
|
||||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@@ -36,10 +36,12 @@ class SysAdminUnlinkDevice extends React.Component {
|
|||||||
<ModalHeader toggle={toggle}>{gettext('Unlink device')}</ModalHeader>
|
<ModalHeader toggle={toggle}>{gettext('Unlink device')}</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<p>{gettext('Are you sure you want to unlink this device?')}</p>
|
<p>{gettext('Are you sure you want to unlink this device?')}</p>
|
||||||
|
{isPro &&
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
<input id="delete-files" className="mr-1" type="checkbox" checked={inputChecked} onChange={this.handleInputChange} />
|
<input id="delete-files" className="mr-1" type="checkbox" checked={inputChecked} onChange={this.handleInputChange} />
|
||||||
<label htmlFor="delete-files" className="m-0">{gettext('Delete files from this device the next time it comes online.')}</label>
|
<label htmlFor="delete-files" className="m-0">{gettext('Delete files from this device the next time it comes online.')}</label>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
<Button color="secondary" onClick={toggle}>{gettext('Cancel')}</Button>
|
<Button color="secondary" onClick={toggle}>{gettext('Cancel')}</Button>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import React, { Component, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import { seafileAPI } from '../../../utils/seafile-api';
|
import { seafileAPI } from '../../../utils/seafile-api';
|
||||||
import { gettext, isPro } from '../../../utils/constants';
|
import { gettext } from '../../../utils/constants';
|
||||||
import toaster from '../../../components/toast';
|
import toaster from '../../../components/toast';
|
||||||
import { Utils } from '../../../utils/utils';
|
import { Utils } from '../../../utils/utils';
|
||||||
import EmptyTip from '../../../components/empty-tip';
|
import EmptyTip from '../../../components/empty-tip';
|
||||||
@@ -133,9 +133,7 @@ class Item extends Component {
|
|||||||
<span title={moment(item.last_accessed).format('llll')}>{moment(item.last_accessed).fromNow()}</span>
|
<span title={moment(item.last_accessed).format('llll')}>{moment(item.last_accessed).fromNow()}</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{isPro &&
|
|
||||||
<a href="#" className={`sf2-icon-delete action-icon ${isOpIconShown ? '' : 'invisible'}`} title={gettext('Unlink')} onClick={this.handleUnlink}></a>
|
<a href="#" className={`sf2-icon-delete action-icon ${isOpIconShown ? '' : 'invisible'}`} title={gettext('Unlink')} onClick={this.handleUnlink}></a>
|
||||||
}
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{isUnlinkDeviceDialogOpen &&
|
{isUnlinkDeviceDialogOpen &&
|
||||||
|
@@ -9,6 +9,7 @@ from rest_framework import status
|
|||||||
|
|
||||||
from pysearpc import SearpcError
|
from pysearpc import SearpcError
|
||||||
|
|
||||||
|
from seahub.utils import is_pro_version
|
||||||
from seahub.utils.devices import do_unlink_device
|
from seahub.utils.devices import do_unlink_device
|
||||||
from seahub.utils.timeutils import datetime_to_isoformat_timestr
|
from seahub.utils.timeutils import datetime_to_isoformat_timestr
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ from seahub.base.templatetags.seahub_tags import email2nickname
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AdminDevices(APIView):
|
class AdminDevices(APIView):
|
||||||
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
authentication_classes = (TokenAuthentication, SessionAuthentication)
|
||||||
throttle_classes = (UserRateThrottle,)
|
throttle_classes = (UserRateThrottle,)
|
||||||
@@ -75,7 +77,7 @@ class AdminDevices(APIView):
|
|||||||
|
|
||||||
def delete(self, request, format=None):
|
def delete(self, request, format=None):
|
||||||
|
|
||||||
if not request.user.admin_permissions.other_permission():
|
if is_pro_version() and not request.user.admin_permissions.other_permission():
|
||||||
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
|
return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.')
|
||||||
|
|
||||||
platform = request.data.get('platform', '')
|
platform = request.data.get('platform', '')
|
||||||
|
@@ -120,8 +120,18 @@ class AdminLogsFileAccessLogs(APIView):
|
|||||||
start = per_page * (current_page - 1)
|
start = per_page * (current_page - 1)
|
||||||
limit = per_page + 1
|
limit = per_page + 1
|
||||||
|
|
||||||
|
if user_selected:
|
||||||
|
org_id = -1
|
||||||
|
orgs = ccnet_api.get_orgs_by_user(user_selected)
|
||||||
|
if orgs:
|
||||||
|
org_id = orgs[0].org_id
|
||||||
|
elif repo_id_selected:
|
||||||
|
org_id = seafile_api.get_org_id_by_repo_id(repo_id_selected)
|
||||||
|
else:
|
||||||
|
org_id = 0
|
||||||
|
|
||||||
# org_id = 0, show all file audit
|
# org_id = 0, show all file audit
|
||||||
events = get_file_audit_events(user_selected, 0, repo_id_selected, start, limit) or []
|
events = get_file_audit_events(user_selected, org_id, repo_id_selected, start, limit) or []
|
||||||
|
|
||||||
if len(events) > per_page:
|
if len(events) > per_page:
|
||||||
events = events[:per_page]
|
events = events[:per_page]
|
||||||
|
@@ -35,12 +35,11 @@ from seahub.profile.settings import CONTACT_CACHE_TIMEOUT, CONTACT_CACHE_PREFIX,
|
|||||||
from seahub.utils import is_valid_username2, is_org_context, \
|
from seahub.utils import is_valid_username2, is_org_context, \
|
||||||
is_pro_version, normalize_cache_key, is_valid_email, \
|
is_pro_version, normalize_cache_key, is_valid_email, \
|
||||||
IS_EMAIL_CONFIGURED, send_html_email, get_site_name, \
|
IS_EMAIL_CONFIGURED, send_html_email, get_site_name, \
|
||||||
gen_shared_link, gen_shared_upload_link, \
|
gen_shared_link, gen_shared_upload_link
|
||||||
get_file_audit_events, get_file_update_events
|
|
||||||
|
|
||||||
from seahub.utils.file_size import get_file_size_unit
|
from seahub.utils.file_size import get_file_size_unit
|
||||||
from seahub.utils.timeutils import timestamp_to_isoformat_timestr, \
|
from seahub.utils.timeutils import timestamp_to_isoformat_timestr, \
|
||||||
datetime_to_isoformat_timestr, utc_to_local
|
datetime_to_isoformat_timestr
|
||||||
from seahub.utils.user_permissions import get_user_role
|
from seahub.utils.user_permissions import get_user_role
|
||||||
from seahub.utils.repo import normalize_repo_status_code
|
from seahub.utils.repo import normalize_repo_status_code
|
||||||
from seahub.constants import DEFAULT_ADMIN
|
from seahub.constants import DEFAULT_ADMIN
|
||||||
@@ -65,23 +64,10 @@ json_content_type = 'application/json; charset=utf-8'
|
|||||||
def get_user_last_access_time(email, last_login_time):
|
def get_user_last_access_time(email, last_login_time):
|
||||||
|
|
||||||
device_last_access = ''
|
device_last_access = ''
|
||||||
audit_last_access = ''
|
|
||||||
update_last_access = ''
|
|
||||||
|
|
||||||
devices = TokenV2.objects.filter(user=email).order_by('-last_accessed')
|
devices = TokenV2.objects.filter(user=email).order_by('-last_accessed')
|
||||||
if devices:
|
if devices:
|
||||||
device_last_access = devices[0].last_accessed
|
device_last_access = devices[0].last_accessed
|
||||||
|
|
||||||
if is_pro_version():
|
|
||||||
audit_events = get_file_audit_events(email, 0, None, 0, 1) or []
|
|
||||||
if audit_events:
|
|
||||||
audit_last_access = audit_events[0].timestamp
|
|
||||||
|
|
||||||
if is_pro_version():
|
|
||||||
update_events = get_file_update_events(email, 0, None, 0, 1) or []
|
|
||||||
if update_events:
|
|
||||||
update_last_access = update_events[0].timestamp
|
|
||||||
|
|
||||||
# before make_naive
|
# before make_naive
|
||||||
# 2021-04-09 05:32:30+00:00
|
# 2021-04-09 05:32:30+00:00
|
||||||
# tzinfo: UTC
|
# tzinfo: UTC
|
||||||
@@ -100,16 +86,6 @@ def get_user_last_access_time(email, last_login_time):
|
|||||||
device_last_access = make_naive(device_last_access)
|
device_last_access = make_naive(device_last_access)
|
||||||
last_access_time_list.append(device_last_access)
|
last_access_time_list.append(device_last_access)
|
||||||
|
|
||||||
if audit_last_access:
|
|
||||||
if is_aware(audit_last_access):
|
|
||||||
audit_last_access = make_naive(audit_last_access)
|
|
||||||
last_access_time_list.append(utc_to_local(audit_last_access))
|
|
||||||
|
|
||||||
if update_last_access:
|
|
||||||
if is_aware(update_last_access):
|
|
||||||
update_last_access = make_naive(update_last_access)
|
|
||||||
last_access_time_list.append(utc_to_local(update_last_access))
|
|
||||||
|
|
||||||
if not last_access_time_list:
|
if not last_access_time_list:
|
||||||
return ''
|
return ''
|
||||||
else:
|
else:
|
||||||
@@ -250,7 +226,7 @@ def update_user_info(request, user, password, is_active, is_staff, role,
|
|||||||
if institution_name == '':
|
if institution_name == '':
|
||||||
InstitutionAdmin.objects.filter(user=email).delete()
|
InstitutionAdmin.objects.filter(user=email).delete()
|
||||||
|
|
||||||
if quota_total_mb:
|
if quota_total_mb is not None:
|
||||||
quota_total = int(quota_total_mb) * get_file_size_unit('MB')
|
quota_total = int(quota_total_mb) * get_file_size_unit('MB')
|
||||||
orgs = ccnet_api.get_orgs_by_user(email)
|
orgs = ccnet_api.get_orgs_by_user(email)
|
||||||
try:
|
try:
|
||||||
|
@@ -43,7 +43,7 @@ from seahub.settings import SHARE_LINK_EXPIRE_DAYS_MAX, \
|
|||||||
SHARE_LINK_EXPIRE_DAYS_MIN, SHARE_LINK_LOGIN_REQUIRED, \
|
SHARE_LINK_EXPIRE_DAYS_MIN, SHARE_LINK_LOGIN_REQUIRED, \
|
||||||
SHARE_LINK_EXPIRE_DAYS_DEFAULT, \
|
SHARE_LINK_EXPIRE_DAYS_DEFAULT, \
|
||||||
ENABLE_SHARE_LINK_AUDIT, ENABLE_VIDEO_THUMBNAIL, \
|
ENABLE_SHARE_LINK_AUDIT, ENABLE_VIDEO_THUMBNAIL, \
|
||||||
THUMBNAIL_ROOT
|
THUMBNAIL_ROOT, ENABLE_UPLOAD_LINK_VIRUS_CHECK
|
||||||
from seahub.wiki.models import Wiki
|
from seahub.wiki.models import Wiki
|
||||||
from seahub.views.file import can_edit_file
|
from seahub.views.file import can_edit_file
|
||||||
from seahub.views import check_folder_permission
|
from seahub.views import check_folder_permission
|
||||||
@@ -808,11 +808,17 @@ class ShareLinkUpload(APIView):
|
|||||||
|
|
||||||
# generate token
|
# generate token
|
||||||
obj_id = json.dumps({'parent_dir': path})
|
obj_id = json.dumps({'parent_dir': path})
|
||||||
|
|
||||||
|
check_virus = False
|
||||||
|
if is_pro_version() and ENABLE_UPLOAD_LINK_VIRUS_CHECK:
|
||||||
|
check_virus = True
|
||||||
|
|
||||||
token = seafile_api.get_fileserver_access_token(repo_id,
|
token = seafile_api.get_fileserver_access_token(repo_id,
|
||||||
obj_id,
|
obj_id,
|
||||||
'upload-link',
|
'upload-link',
|
||||||
share_link.username,
|
share_link.username,
|
||||||
use_onetime=False)
|
use_onetime=False,
|
||||||
|
check_virus=check_virus)
|
||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
|
@@ -25,12 +25,14 @@ from seahub.api2.throttling import AnonRateThrottle, UserRateThrottle
|
|||||||
from seahub.api2.permissions import CanGenerateUploadLink
|
from seahub.api2.permissions import CanGenerateUploadLink
|
||||||
|
|
||||||
from seahub.share.models import UploadLinkShare, check_share_link_common
|
from seahub.share.models import UploadLinkShare, check_share_link_common
|
||||||
from seahub.utils import gen_shared_upload_link, gen_file_upload_url
|
from seahub.utils import gen_shared_upload_link, gen_file_upload_url, \
|
||||||
|
is_pro_version
|
||||||
from seahub.views import check_folder_permission
|
from seahub.views import check_folder_permission
|
||||||
from seahub.utils.timeutils import datetime_to_isoformat_timestr
|
from seahub.utils.timeutils import datetime_to_isoformat_timestr
|
||||||
|
|
||||||
from seahub.settings import UPLOAD_LINK_EXPIRE_DAYS_DEFAULT, \
|
from seahub.settings import UPLOAD_LINK_EXPIRE_DAYS_DEFAULT, \
|
||||||
UPLOAD_LINK_EXPIRE_DAYS_MIN, UPLOAD_LINK_EXPIRE_DAYS_MAX
|
UPLOAD_LINK_EXPIRE_DAYS_MIN, UPLOAD_LINK_EXPIRE_DAYS_MAX, \
|
||||||
|
ENABLE_UPLOAD_LINK_VIRUS_CHECK
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -349,11 +351,17 @@ class UploadLinkUpload(APIView):
|
|||||||
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||||
|
|
||||||
obj_id = json.dumps({'parent_dir': path})
|
obj_id = json.dumps({'parent_dir': path})
|
||||||
|
|
||||||
|
check_virus = False
|
||||||
|
if is_pro_version() and ENABLE_UPLOAD_LINK_VIRUS_CHECK:
|
||||||
|
check_virus = True
|
||||||
|
|
||||||
token = seafile_api.get_fileserver_access_token(repo_id,
|
token = seafile_api.get_fileserver_access_token(repo_id,
|
||||||
obj_id,
|
obj_id,
|
||||||
'upload-link',
|
'upload-link',
|
||||||
uls.username,
|
uls.username,
|
||||||
use_onetime=False)
|
use_onetime=False,
|
||||||
|
check_virus=check_virus)
|
||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
error_msg = 'Internal Server Error'
|
error_msg = 'Internal Server Error'
|
||||||
|
Reference in New Issue
Block a user