mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 23:29:49 +00:00
@@ -105,6 +105,7 @@ class Item extends Component {
|
||||
case 'group_delete': return gettext('Delete Group');
|
||||
case 'user_add': return gettext('Add User');
|
||||
case 'user_delete': return gettext('Delete User');
|
||||
case 'user_migrate': return gettext('Migrate User');
|
||||
default: return '';
|
||||
}
|
||||
};
|
||||
@@ -184,6 +185,12 @@ class Item extends Component {
|
||||
.replace('{user}', '<span class="font-weight-bold">' + detail.email+ '</span>');
|
||||
return detailText;
|
||||
|
||||
case 'user_migrate':
|
||||
detailText = gettext('User migrate from {user_from} to {user_to}')
|
||||
.replace('{user_from}', '<span class="font-weight-bold">' + detail.from + '</span>')
|
||||
.replace('{user_to}', '<span class="font-weight-bold">' + detail.to+ '</span>');
|
||||
return detailText;
|
||||
|
||||
default: return '';
|
||||
}
|
||||
};
|
||||
|
@@ -28,9 +28,12 @@ USER_ADD = 'user_add'
|
||||
# 'user_delete': {'email': deleted_user}
|
||||
USER_DELETE = 'user_delete'
|
||||
|
||||
# 'user_migrate': {'from': from_user, 'to': to_user}
|
||||
USER_MIGRATE = 'user_migrate'
|
||||
|
||||
ADMIN_LOG_OPERATION_TYPE = (REPO_TRANSFER, REPO_DELETE,
|
||||
GROUP_CREATE, GROUP_TRANSFER, GROUP_DELETE,
|
||||
USER_ADD, USER_DELETE)
|
||||
USER_ADD, USER_DELETE, USER_MIGRATE)
|
||||
|
||||
|
||||
class AdminLogManager(models.Manager):
|
||||
|
@@ -13,6 +13,8 @@ from rest_framework.views import APIView
|
||||
import seaserv
|
||||
from seaserv import seafile_api, ccnet_threaded_rpc, ccnet_api
|
||||
|
||||
from seahub.admin_log.models import USER_MIGRATE
|
||||
from seahub.admin_log.signals import admin_operation
|
||||
from seahub.api2.authentication import TokenAuthentication
|
||||
from seahub.api2.serializers import AccountSerializer
|
||||
from seahub.api2.throttling import UserRateThrottle
|
||||
@@ -21,6 +23,7 @@ from seahub.base.accounts import User
|
||||
from seahub.base.templatetags.seahub_tags import email2nickname
|
||||
from seahub.profile.models import Profile, DetailedProfile
|
||||
from seahub.institutions.models import Institution
|
||||
from seahub.share.models import UploadLinkShare, FileShare
|
||||
from seahub.utils import is_valid_username, is_org_context
|
||||
from seahub.utils.file_size import get_file_size_unit
|
||||
from seahub.group.utils import is_group_member
|
||||
@@ -107,6 +110,21 @@ class Account(APIView):
|
||||
if from_user == g.creator_name:
|
||||
ccnet_threaded_rpc.set_group_creator(g.id, to_user)
|
||||
|
||||
# reshare repo to links
|
||||
try:
|
||||
UploadLinkShare.objects.filter(username=from_user).update(username=to_user)
|
||||
FileShare.objects.filter(username=from_user).update(username=to_user)
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
error_msg = 'Internal Server Error'
|
||||
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
|
||||
|
||||
admin_op_detail = {
|
||||
"from": from_user,
|
||||
"to": to_user
|
||||
}
|
||||
admin_operation.send(sender=None, admin_name=request.user.username,
|
||||
operation=USER_MIGRATE, detail=admin_op_detail)
|
||||
return Response({'success': True})
|
||||
else:
|
||||
return api_error(status.HTTP_400_BAD_REQUEST, 'op can only be migrate.')
|
||||
|
Reference in New Issue
Block a user