diff --git a/frontend/src/components/dialog/file-access-log.js b/frontend/src/components/dialog/file-access-log.js index 1428fa4653..406892f9b0 100644 --- a/frontend/src/components/dialog/file-access-log.js +++ b/frontend/src/components/dialog/file-access-log.js @@ -41,8 +41,7 @@ class FileAccessLog extends React.Component { listFileAccessLog = (page) => { const { repoID, filePath } = this.props; const { perPage, items } = this.state; - const avatarSize = 24 * 2; - fileAccessLogAPI.listFileAccessLog(repoID, filePath, page, perPage, avatarSize).then((res) => { + fileAccessLogAPI.listFileAccessLog(repoID, filePath, page, perPage).then((res) => { const { data: newItems } = res.data; this.setState({ isLoading: false, diff --git a/frontend/src/components/user-settings/user-avatar-form.js b/frontend/src/components/user-settings/user-avatar-form.js index 01de9e4e10..277bac72bd 100644 --- a/frontend/src/components/user-settings/user-avatar-form.js +++ b/frontend/src/components/user-settings/user-avatar-form.js @@ -52,7 +52,7 @@ class UserAvatarForm extends React.Component { return false; } - seafileAPI.updateUserAvatar(file, 160).then((res) => { + seafileAPI.updateUserAvatar(file).then((res) => { this.setState({ avatarSrc: res.data.avatar_url }); diff --git a/frontend/src/pages/dashboard/files-activities.js b/frontend/src/pages/dashboard/files-activities.js index 0cbc5d764e..d0ff265ccb 100644 --- a/frontend/src/pages/dashboard/files-activities.js +++ b/frontend/src/pages/dashboard/files-activities.js @@ -33,7 +33,6 @@ class FilesActivities extends Component { availableUsers: [], targetUsers: [] }; - this.avatarSize = 72; this.curPathList = []; this.oldPathList = []; this.availableUserEmails = new Set(); @@ -41,7 +40,7 @@ class FilesActivities extends Component { componentDidMount() { let { currentPage, availableUsers } = this.state; - seafileAPI.listActivities(currentPage, this.avatarSize).then(res => { + seafileAPI.listActivities(currentPage).then(res => { // {"events":[...]} let events = this.mergePublishEvents(res.data.events); events = this.mergeFileCreateEvents(events); @@ -140,7 +139,7 @@ class FilesActivities extends Component { getMore() { const { currentPage, availableUsers, targetUsers } = this.state; - seafileAPI.listActivities(currentPage, this.avatarSize).then(res => { + seafileAPI.listActivities(currentPage).then(res => { // {"events":[...]} let events = this.mergePublishEvents(res.data.events); events = this.mergeFileCreateEvents(events); diff --git a/frontend/src/pages/sys-admin/users/user-info.js b/frontend/src/pages/sys-admin/users/user-info.js index 7b9c4d3088..d9b682daa8 100644 --- a/frontend/src/pages/sys-admin/users/user-info.js +++ b/frontend/src/pages/sys-admin/users/user-info.js @@ -256,7 +256,7 @@ class User extends Component { componentDidMount() { // avatar size: 160 const email = decodeURIComponent(this.props.email); - systemAdminAPI.sysAdminGetUser(email, 160).then((res) => { + systemAdminAPI.sysAdminGetUser(email).then((res) => { this.setState({ loading: false, userInfo: res.data diff --git a/frontend/src/utils/file-access-log-api.js b/frontend/src/utils/file-access-log-api.js index 5085c3031a..0f4f29a7fb 100644 --- a/frontend/src/utils/file-access-log-api.js +++ b/frontend/src/utils/file-access-log-api.js @@ -32,13 +32,12 @@ class FileAccessLogAPI { return this; } - listFileAccessLog(repoID, filePath, page, perPage, avatarSize) { + listFileAccessLog(repoID, filePath, page, perPage) { const url = this.server + '/api/v2.1/repos/' + repoID + '/file/access-log/'; const params = { path: filePath, page: page || 1, - per_page: perPage || 100, - avatar_size: avatarSize || 64 + per_page: perPage || 100 }; return this.req.get(url, { params: params }); } diff --git a/frontend/src/utils/system-admin-api.js b/frontend/src/utils/system-admin-api.js index 9aa87eee58..f5150904e3 100644 --- a/frontend/src/utils/system-admin-api.js +++ b/frontend/src/utils/system-admin-api.js @@ -874,13 +874,9 @@ class SystemAdminAPI { return this.req.delete(url); } - sysAdminGetUser(email, avatarSize) { + sysAdminGetUser(email) { const url = this.server + '/api/v2.1/admin/users/' + encodeURIComponent(email) + '/'; - let params = {}; - if (avatarSize) { - params.avatar_size = avatarSize; - } - return this.req.get(url, { params: params }); + return this.req.get(url); } sysAdminResetUserPassword(email) { diff --git a/seahub/api2/endpoints/activities.py b/seahub/api2/endpoints/activities.py index 0fce5ee6a2..36d9dbd98f 100644 --- a/seahub/api2/endpoints/activities.py +++ b/seahub/api2/endpoints/activities.py @@ -66,12 +66,7 @@ class ActivitiesView(APIView): d['author_name'] = email2nickname(e.op_user) d['author_contact_email'] = email2contact_email(e.op_user) - try: - avatar_size = int(request.GET.get('avatar_size', 72)) - except ValueError as e: - avatar_size = 72 - - url, is_default, date_uploaded = api_avatar_url(e.op_user, avatar_size) + url, is_default, date_uploaded = api_avatar_url(e.op_user) d['avatar_url'] = url d['time'] = utc_datetime_to_isoformat_timestr(e.timestamp) diff --git a/seahub/api2/endpoints/admin/address_book/groups.py b/seahub/api2/endpoints/admin/address_book/groups.py index 765f997223..9b2b70454a 100644 --- a/seahub/api2/endpoints/admin/address_book/groups.py +++ b/seahub/api2/endpoints/admin/address_book/groups.py @@ -129,10 +129,10 @@ class AdminAddressBookGroup(APIView): throttle_classes = (UserRateThrottle,) permission_classes = (IsAdminUser, IsProVersion) - def _get_address_book_group_memeber_info(self, request, group_member_obj, avatar_size): + def _get_address_book_group_memeber_info(self, request, group_member_obj): email = group_member_obj.user_name - avatar_url, is_default, date_uploaded = api_avatar_url(email, avatar_size) + avatar_url, is_default, date_uploaded = api_avatar_url(email) group_id = group_member_obj.group_id group = ccnet_api.get_group(group_member_obj.group_id) @@ -166,12 +166,6 @@ class AdminAddressBookGroup(APIView): error_msg = 'Group %d not found.' % group_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) - try: - avatar_size = int(request.GET.get('avatar_size', - AVATAR_DEFAULT_SIZE)) - except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE - try: return_ancestors = to_python_boolean(request.GET.get( 'return_ancestors', 'f')) @@ -194,7 +188,7 @@ class AdminAddressBookGroup(APIView): return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) for m in members: - member_info = self._get_address_book_group_memeber_info(request, m, avatar_size) + member_info = self._get_address_book_group_memeber_info(request, m) if member_info['role'] == 'Owner': continue ret_members.append(member_info) diff --git a/seahub/api2/endpoints/admin/group_members.py b/seahub/api2/endpoints/admin/group_members.py index 8887a9aa57..6753f30991 100644 --- a/seahub/api2/endpoints/admin/group_members.py +++ b/seahub/api2/endpoints/admin/group_members.py @@ -44,11 +44,6 @@ class AdminGroupMembers(APIView): error_msg = 'Group %d not found.' % group_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) - try: - avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE)) - except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE - try: page = int(request.GET.get('page', '1')) per_page = int(request.GET.get('per_page', '100')) @@ -74,7 +69,7 @@ class AdminGroupMembers(APIView): group_members_info = [] for m in members: - member_info = get_group_member_info(request, group_id, m.user_name, avatar_size) + member_info = get_group_member_info(request, group_id, m.user_name) group_members_info.append(member_info) group_members = { diff --git a/seahub/api2/endpoints/admin/user_activities.py b/seahub/api2/endpoints/admin/user_activities.py index edf3e605bd..0f7fbb4c81 100644 --- a/seahub/api2/endpoints/admin/user_activities.py +++ b/seahub/api2/endpoints/admin/user_activities.py @@ -83,12 +83,7 @@ class UserActivitiesView(APIView): d['author_name'] = email2nickname(e.op_user) d['author_contact_email'] = email2contact_email(e.op_user) - try: - avatar_size = int(request.GET.get('avatar_size', 72)) - except ValueError as e: - avatar_size = 72 - - url, is_default, date_uploaded = api_avatar_url(e.op_user, avatar_size) + url, is_default, date_uploaded = api_avatar_url(e.op_user) d['avatar_url'] = url d['time'] = utc_datetime_to_isoformat_timestr(e.timestamp) diff --git a/seahub/api2/endpoints/admin/users.py b/seahub/api2/endpoints/admin/users.py index fdd242a33f..b2c80f3831 100644 --- a/seahub/api2/endpoints/admin/users.py +++ b/seahub/api2/endpoints/admin/users.py @@ -1244,14 +1244,6 @@ class AdminUser(APIView): request.user.admin_permissions.can_update_user()): return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') - avatar_size = request.data.get('avatar_size', 64) - try: - avatar_size = int(avatar_size) - except Exception as e: - logger.error(e) - error_msg = 'avatar_size invalid.' - return api_error(status.HTTP_400_BAD_REQUEST, error_msg) - try: User.objects.get(email=email) except User.DoesNotExist: @@ -1259,7 +1251,7 @@ class AdminUser(APIView): return api_error(status.HTTP_404_NOT_FOUND, error_msg) user_info = get_user_info(email) - user_info['avatar_url'], _, _ = api_avatar_url(email, avatar_size) + user_info['avatar_url'], _, _ = api_avatar_url(email) if is_pro_version(): user_info['upload_rate_limit'] = byte_to_kb(seafile_api.get_user_upload_rate_limit(email)) user_info['download_rate_limit'] = byte_to_kb(seafile_api.get_user_download_rate_limit(email)) diff --git a/seahub/api2/endpoints/dir_shared_items.py b/seahub/api2/endpoints/dir_shared_items.py index e69e951a47..f6f0330c83 100644 --- a/seahub/api2/endpoints/dir_shared_items.py +++ b/seahub/api2/endpoints/dir_shared_items.py @@ -80,7 +80,7 @@ class DirSharedItemsEndpoint(APIView): admin_users = ExtraSharePermission.objects.get_admin_users_by_repo(repo_id) ret = [] for item in share_items: - avatar_url, is_default, date_uploaded = api_avatar_url(item.user, 72) + avatar_url, is_default, date_uploaded = api_avatar_url(item.user) ret.append({ "share_type": "user", "user_info": { @@ -414,7 +414,7 @@ class DirSharedItemsEndpoint(APIView): share_dir_to_user(repo, path, repo_owner, username, to_user, permission, None) - avatar_url, is_default, date_uploaded = api_avatar_url(to_user, 72) + avatar_url, is_default, date_uploaded = api_avatar_url(to_user) result['success'].append({ "share_type": "user", "user_info": { diff --git a/seahub/api2/endpoints/draft_reviewer.py b/seahub/api2/endpoints/draft_reviewer.py index 44ca50e005..b581aeac93 100644 --- a/seahub/api2/endpoints/draft_reviewer.py +++ b/seahub/api2/endpoints/draft_reviewer.py @@ -44,7 +44,7 @@ class DraftReviewerView(APIView): # get reviewer list reviewers = [] for x in d.draftreviewer_set.all(): - reviewer = user_to_dict(x.reviewer, request=request, avatar_size=avatar_size) + reviewer = user_to_dict(x.reviewer, request=request) reviewers.append(reviewer) return Response({'reviewers': reviewers}) diff --git a/seahub/api2/endpoints/file_access_log.py b/seahub/api2/endpoints/file_access_log.py index 49317c8108..2d798f66a7 100644 --- a/seahub/api2/endpoints/file_access_log.py +++ b/seahub/api2/endpoints/file_access_log.py @@ -60,11 +60,6 @@ class FileAccessLogView(APIView): return api_error(status.HTTP_403_FORBIDDEN, error_msg) # get access log - try: - avatar_size = int(request.GET.get('avatar_size', 32)) - except ValueError: - avatar_size = 32 - try: current_page = int(request.GET.get('page', '1')) per_page = int(request.GET.get('per_page', '25')) @@ -87,8 +82,7 @@ class FileAccessLogView(APIView): info = {} username = event.user - url, is_default, date_uploaded = api_avatar_url(username, - avatar_size) + url, is_default, date_uploaded = api_avatar_url(username) info['avatar_url'] = url info['email'] = username info['name'] = email2nickname(username) diff --git a/seahub/api2/endpoints/file_comment.py b/seahub/api2/endpoints/file_comment.py index 3aada19b42..ab0cb6aaba 100644 --- a/seahub/api2/endpoints/file_comment.py +++ b/seahub/api2/endpoints/file_comment.py @@ -47,8 +47,7 @@ class FileCommentView(APIView): avatar_size = AVATAR_DEFAULT_SIZE comment = file_comment.to_dict() - comment.update(user_to_dict(file_comment.author, request=request, - avatar_size=avatar_size)) + comment.update(user_to_dict(file_comment.author, request=request)) return Response(comment) @@ -137,6 +136,6 @@ class FileCommentView(APIView): avatar_size = AVATAR_DEFAULT_SIZE comment = file_comment.to_dict() - comment.update(user_to_dict(file_comment.author, request=request, avatar_size=avatar_size)) + comment.update(user_to_dict(file_comment.author, request=request)) return Response(comment) diff --git a/seahub/api2/endpoints/file_comments.py b/seahub/api2/endpoints/file_comments.py index 8763e02fb4..e2d8416f39 100644 --- a/seahub/api2/endpoints/file_comments.py +++ b/seahub/api2/endpoints/file_comments.py @@ -49,12 +49,9 @@ class FileCommentsView(APIView): return api_error(status.HTTP_403_FORBIDDEN, 'Permission denied.') try: - avatar_size = int(request.GET.get('avatar_size', - AVATAR_DEFAULT_SIZE)) page = int(request.GET.get('page', '1')) per_page = int(request.GET.get('per_page', '25')) except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE page = 1 per_page = 25 @@ -72,7 +69,7 @@ class FileCommentsView(APIView): for file_comment in file_comments: comment = file_comment.to_dict() - comment.update(user_to_dict(file_comment.author, request=request, avatar_size=avatar_size)) + comment.update(user_to_dict(file_comment.author, request=request)) comments.append(comment) result = {'comments': comments, 'total_count': total_count} @@ -141,5 +138,5 @@ class FileCommentsView(APIView): author=username) comment = file_comment.to_dict() - comment.update(user_to_dict(username, request=request, avatar_size=avatar_size)) + comment.update(user_to_dict(username, request=request)) return Response(comment, status=201) diff --git a/seahub/api2/endpoints/file_history.py b/seahub/api2/endpoints/file_history.py index 22a3a11ccc..2369a896e6 100644 --- a/seahub/api2/endpoints/file_history.py +++ b/seahub/api2/endpoints/file_history.py @@ -23,12 +23,12 @@ from seahub.base.templatetags.seahub_tags import email2nickname, \ logger = logging.getLogger(__name__) -def get_new_file_history_info(ent, avatar_size): +def get_new_file_history_info(ent): info = {} creator_name = ent.op_user - url, is_default, date_uploaded = api_avatar_url(creator_name, avatar_size) + url, is_default, date_uploaded = api_avatar_url(creator_name) info['creator_avatar_url'] = url info['creator_email'] = creator_name @@ -44,14 +44,14 @@ def get_new_file_history_info(ent, avatar_size): return info -def get_file_history_info(commit, avatar_size): +def get_file_history_info(commit): info = {} creator_name = getattr(commit, 'creator_name', '') if creator_name is None: creator_name = '' - url, is_default, date_uploaded = api_avatar_url(creator_name, avatar_size) + url, is_default, date_uploaded = api_avatar_url(creator_name) info['creator_avatar_url'] = url info['creator_email'] = creator_name @@ -92,11 +92,6 @@ class FileHistoryView(APIView): if not commit_id: commit_id = repo.head_cmmt_id - try: - avatar_size = int(request.GET.get('avatar_size', 32)) - except ValueError: - avatar_size = 32 - # Don't use seafile_api.get_file_id_by_path() # if path parameter is `rev_renamed_old_path`. # seafile_api.get_file_id_by_path() will return None. @@ -141,7 +136,7 @@ class FileHistoryView(APIView): if (keep_days != -1) and ((present_time - history_time).days > keep_days): next_start_commit = False break - info = get_file_history_info(commit, avatar_size) + info = get_file_history_info(commit) info['path'] = path result.append(info) @@ -176,11 +171,9 @@ class NewFileHistoryView(APIView): commit_id = repo.head_cmmt_id try: - avatar_size = int(request.GET.get('avatar_size', 32)) page = int(request.GET.get('page', '1')) per_page = int(request.GET.get('per_page', '25')) except ValueError: - avatar_size = 32 page = 1 per_page = 25 @@ -216,7 +209,7 @@ class NewFileHistoryView(APIView): error_msg = 'Internal Server Error' return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) - data = [get_new_file_history_info(ent, avatar_size) for ent in file_revisions] + data = [get_new_file_history_info(ent) for ent in file_revisions] result = { "data": data, "page": page, diff --git a/seahub/api2/endpoints/group_members.py b/seahub/api2/endpoints/group_members.py index 904cb1b4e9..bb7b7a4ded 100644 --- a/seahub/api2/endpoints/group_members.py +++ b/seahub/api2/endpoints/group_members.py @@ -45,12 +45,6 @@ class GroupMembers(APIView): """ Get all group members. """ - - try: - avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE)) - except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE - try: page = int(request.GET.get('page', '1')) per_page = int(request.GET.get('per_page', '100')) @@ -81,7 +75,7 @@ class GroupMembers(APIView): if is_admin == 'true' and not m.is_staff: continue - member_info = get_group_member_info(request, group_id, m.user_name, avatar_size) + member_info = get_group_member_info(request, group_id, m.user_name) group_members.append(member_info) return Response(group_members) @@ -191,12 +185,7 @@ class GroupMember(APIView): error_msg = 'Internal Server Error' return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) - try: - avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE)) - except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE - - member_info = get_group_member_info(request, group_id, email, avatar_size) + member_info = get_group_member_info(request, group_id, email) return Response(member_info) diff --git a/seahub/api2/endpoints/repo_share_links.py b/seahub/api2/endpoints/repo_share_links.py index d0296190d1..3de2dd2cb1 100644 --- a/seahub/api2/endpoints/repo_share_links.py +++ b/seahub/api2/endpoints/repo_share_links.py @@ -29,7 +29,7 @@ from seahub.share.models import FileShare logger = logging.getLogger(__name__) -def get_share_link_info(fileshare, avatar_size=AVATAR_DEFAULT_SIZE): +def get_share_link_info(fileshare): data = {} token = fileshare.token @@ -55,7 +55,7 @@ def get_share_link_info(fileshare, avatar_size=AVATAR_DEFAULT_SIZE): data['creator_name'] = email2nickname(creator_email) data['creator_contact_email'] = email2contact_email(creator_email) - url, _, _ = api_avatar_url(creator_email, avatar_size) + url, _, _ = api_avatar_url(creator_email) data['creator_avatar'] = url data['path'] = path @@ -105,16 +105,11 @@ class RepoShareLinks(APIView): offset = per_page * (current_page - 1) - try: - avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE)) - except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE - result = [] fileshares = FileShare.objects.filter(repo_id=repo_id)[offset:offset + per_page] for fileshare in fileshares: - link_info = get_share_link_info(fileshare, avatar_size) + link_info = get_share_link_info(fileshare) link_info['repo_id'] = repo_id link_info['repo_name'] = repo.name result.append(link_info) diff --git a/seahub/api2/endpoints/repo_upload_links.py b/seahub/api2/endpoints/repo_upload_links.py index 5c42228b2f..385066bac6 100644 --- a/seahub/api2/endpoints/repo_upload_links.py +++ b/seahub/api2/endpoints/repo_upload_links.py @@ -26,7 +26,7 @@ from seahub.utils.timeutils import datetime_to_isoformat_timestr logger = logging.getLogger(__name__) -def get_upload_link_info(upload_link, avatar_size=AVATAR_DEFAULT_SIZE): +def get_upload_link_info(upload_link): data = {} token = upload_link.token @@ -52,7 +52,7 @@ def get_upload_link_info(upload_link, avatar_size=AVATAR_DEFAULT_SIZE): data['creator_name'] = email2nickname(creator_email) data['creator_contact_email'] = email2contact_email(creator_email) - url, _, _ = api_avatar_url(creator_email, avatar_size) + url, _, _ = api_avatar_url(creator_email) data['creator_avatar'] = url data['path'] = path @@ -100,16 +100,11 @@ class RepoUploadLinks(APIView): offset = per_page * (current_page - 1) - try: - avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE)) - except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE - upload_links = UploadLinkShare.objects.filter(repo_id=repo_id)[offset:offset + per_page] result = [] for upload_link in upload_links: - link_info = get_upload_link_info(upload_link, avatar_size) + link_info = get_upload_link_info(upload_link) link_info['repo_id'] = repo_id link_info['repo_name'] = repo.name result.append(link_info) diff --git a/seahub/api2/endpoints/repos.py b/seahub/api2/endpoints/repos.py index 8869feca3a..022e336b70 100644 --- a/seahub/api2/endpoints/repos.py +++ b/seahub/api2/endpoints/repos.py @@ -123,7 +123,7 @@ class ReposView(APIView): if is_wiki_repo(r): continue - url, _, _ = api_avatar_url(email, int(24)) + url, _, _ = api_avatar_url(email) repo_info = { "type": "mine", @@ -197,7 +197,7 @@ class ReposView(APIView): owner_name = group_name if is_group_owned_repo else nickname_dict.get(owner_email, '') owner_contact_email = '' if is_group_owned_repo else contact_email_dict.get(owner_email, '') - url, _, _ = api_avatar_url(owner_email, int(24)) + url, _, _ = api_avatar_url(owner_email) repo_info = { "type": "shared", @@ -309,7 +309,7 @@ class ReposView(APIView): continue repo_owner = repo_id_owner_dict[r.repo_id] - url, _, _ = api_avatar_url(repo_owner, int(24)) + url, _, _ = api_avatar_url(repo_owner) repo_info = { "type": "public", "repo_id": r.repo_id, @@ -376,7 +376,7 @@ class RepoView(APIView): lib_need_decrypt = True repo_owner = get_repo_owner(request, repo_id) - url, _, _ = api_avatar_url(repo_owner, int(24)) + url, _, _ = api_avatar_url(repo_owner) try: has_been_shared_out = repo_has_been_shared_out(request, repo_id) diff --git a/seahub/api2/endpoints/search_user.py b/seahub/api2/endpoints/search_user.py index f16cfa5a15..b501a8715c 100644 --- a/seahub/api2/endpoints/search_user.py +++ b/seahub/api2/endpoints/search_user.py @@ -153,26 +153,21 @@ class SearchUser(APIView): if CUSTOM_SEARCH_USER: email_result = custom_search_user(request, email_result) - # format user result - try: - size = int(request.GET.get('avatar_size', 32)) - except ValueError: - size = 32 formated_result = format_searched_user_result( - request, email_result[:10], size) + request, email_result[:10]) return Response({"users": formated_result}) -def format_searched_user_result(request, users, size): +def format_searched_user_result(request, users): results = [] if ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER: profile_queryset = Profile.objects.filter(user__in=users) profile_dict = {p.user: p.login_id for p in profile_queryset if p.login_id} for email in users: - url, is_default, date_uploaded = api_avatar_url(email, size) + url, is_default, date_uploaded = api_avatar_url(email) user_info = { "email": email, "avatar_url": url, diff --git a/seahub/api2/endpoints/share_link_auth.py b/seahub/api2/endpoints/share_link_auth.py index c829e392a0..c9c663decf 100644 --- a/seahub/api2/endpoints/share_link_auth.py +++ b/seahub/api2/endpoints/share_link_auth.py @@ -25,7 +25,7 @@ logger = logging.getLogger(__name__) def get_user_auth_info(username, token): - avatar_url, _, _ = api_avatar_url(username, 72) + avatar_url, _, _ = api_avatar_url(username) name = email2nickname(username) contact_email = email2contact_email(username) return { diff --git a/seahub/api2/endpoints/user_avatar.py b/seahub/api2/endpoints/user_avatar.py index 799d5e6e43..b4c4ac5260 100644 --- a/seahub/api2/endpoints/user_avatar.py +++ b/seahub/api2/endpoints/user_avatar.py @@ -31,19 +31,11 @@ class UserAvatarView(APIView): def post(self, request): image_file = request.FILES.get('avatar', None) - avatar_size = request.data.get('avatar_size', 64) if not image_file: error_msg = 'avatar invalid.' return api_error(status.HTTP_400_BAD_REQUEST, error_msg) - try: - avatar_size = int(avatar_size) - except Exception as e: - logger.error(e) - error_msg = 'avatar_size invalid.' - return api_error(status.HTTP_400_BAD_REQUEST, error_msg) - (root, ext) = os.path.splitext(image_file.name.lower()) if AVATAR_ALLOWED_FILE_EXTS and ext not in AVATAR_ALLOWED_FILE_EXTS: error_msg = _("%(ext)s is an invalid file extension. Authorized extensions are : %(valid_exts_list)s") % {'ext' : ext, 'valid_exts_list' : ", ".join(AVATAR_ALLOWED_FILE_EXTS)} @@ -67,7 +59,8 @@ class UserAvatarView(APIView): avatar.avatar.save(image_file.name, image_file) avatar.save() avatar_updated.send(sender=Avatar, user=request.user, avatar=avatar) - avatar_url, is_default, date_uploaded = api_avatar_url(username, int(avatar_size)) + avatar_url, is_default, date_uploaded = api_avatar_url(username) + except Exception as e: logger.error(e) error_msg = 'Internal Server Error' diff --git a/seahub/api2/utils.py b/seahub/api2/utils.py index f57bb1e9b8..13619e23d1 100644 --- a/seahub/api2/utils.py +++ b/seahub/api2/utils.py @@ -265,8 +265,8 @@ def to_python_boolean(string): return False raise ValueError("Invalid boolean value: '%s'" % string) -def get_user_common_info(email, avatar_size=AVATAR_DEFAULT_SIZE): - avatar_url, is_default, date_uploaded = api_avatar_url(email, avatar_size) +def get_user_common_info(email): + avatar_url, is_default, date_uploaded = api_avatar_url(email) return { "email": email, "name": email2nickname(email), @@ -274,8 +274,8 @@ def get_user_common_info(email, avatar_size=AVATAR_DEFAULT_SIZE): "avatar_url": avatar_url } -def user_to_dict(email, request=None, avatar_size=AVATAR_DEFAULT_SIZE): - d = get_user_common_info(email, avatar_size) +def user_to_dict(email, request=None): + d = get_user_common_info(email) return { 'user_name': d['name'], 'user_email': d['email'], diff --git a/seahub/api2/views.py b/seahub/api2/views.py index 16447d9fc1..8fb54b6aff 100644 --- a/seahub/api2/views.py +++ b/seahub/api2/views.py @@ -331,7 +331,7 @@ class AccountInfo(APIView): else: # no space quota set in config info['space_usage'] = '0%' - url, _, _ = api_avatar_url(email, int(72)) + url, _, _ = api_avatar_url(email) info['avatar_url'] = url info['email'] = email @@ -3415,7 +3415,7 @@ class FileDetailView(APIView): entry["last_modifier_name"] = email2nickname(latest_contributor) entry["last_modifier_contact_email"] = email2contact_email(latest_contributor) if latest_contributor: - url, _, _ = api_avatar_url(latest_contributor, int(24)) + url, _, _ = api_avatar_url(latest_contributor) entry["last_modifier_avatar"] = url try: diff --git a/seahub/avatar/management/commands/migrate_avatars_fs2db.py b/seahub/avatar/management/commands/migrate_avatars_fs2db.py index 46555fb8a1..0176685aa6 100644 --- a/seahub/avatar/management/commands/migrate_avatars_fs2db.py +++ b/seahub/avatar/management/commands/migrate_avatars_fs2db.py @@ -7,7 +7,6 @@ from django.core.management.base import BaseCommand from django.db import connection, transaction from seahub.avatar.models import Avatar -from seahub.avatar.settings import AUTO_GENERATE_AVATAR_SIZES from seahub.utils.timeutils import value_to_db_datetime diff --git a/seahub/avatar/management/commands/rebuild_avatars.py b/seahub/avatar/management/commands/rebuild_avatars.py index 320c241922..f3e9425bfc 100644 --- a/seahub/avatar/management/commands/rebuild_avatars.py +++ b/seahub/avatar/management/commands/rebuild_avatars.py @@ -2,14 +2,13 @@ from django.core.management.base import BaseCommand from seahub.avatar.models import Avatar -from seahub.avatar.settings import AUTO_GENERATE_AVATAR_SIZES +from seahub.avatar.settings import AVATAR_DEFAULT_SIZE class Command(BaseCommand): help = "Regenerates avatar thumbnails for the sizes specified in " + \ - "settings.AUTO_GENERATE_AVATAR_SIZES." + "settings.AVATAR_DEFAULT_SIZE." def handle(self, **options): for avatar in Avatar.objects.all(): - for size in AUTO_GENERATE_AVATAR_SIZES: - print("Rebuilding Avatar id=%s at size %s." % (avatar.id, size)) - avatar.create_thumbnail(size) + print("Rebuilding Avatar id=%s at size %s." % (avatar.id, AVATAR_DEFAULT_SIZE)) + avatar.create_thumbnail(AVATAR_DEFAULT_SIZE) diff --git a/seahub/avatar/models.py b/seahub/avatar/models.py index f08a4c71f9..58ec310322 100644 --- a/seahub/avatar/models.py +++ b/seahub/avatar/models.py @@ -29,7 +29,7 @@ from seahub.avatar.util import invalidate_cache, get_avatar_file_storage from seahub.avatar.settings import (AVATAR_STORAGE_DIR, AVATAR_RESIZE_METHOD, AVATAR_MAX_AVATARS_PER_USER, AVATAR_THUMB_FORMAT, AVATAR_HASH_USERDIRNAMES, AVATAR_HASH_FILENAMES, - AVATAR_THUMB_QUALITY, AUTO_GENERATE_AVATAR_SIZES, + AVATAR_THUMB_QUALITY, AVATAR_DEFAULT_SIZE, GROUP_AVATAR_STORAGE_DIR) # Get an instance of a logger @@ -176,8 +176,7 @@ class GroupAvatar(models.Model, AvatarBase): def create_default_thumbnails(instance=None, created=False, **kwargs): if created: - for size in AUTO_GENERATE_AVATAR_SIZES: - instance.create_thumbnail(size) + instance.create_thumbnail(AVATAR_DEFAULT_SIZE) signals.post_save.connect(create_default_thumbnails, sender=Avatar, dispatch_uid="create_default_thumbnails") diff --git a/seahub/avatar/settings.py b/seahub/avatar/settings.py index 189dd5f2df..0375bee2ac 100644 --- a/seahub/avatar/settings.py +++ b/seahub/avatar/settings.py @@ -8,11 +8,10 @@ except ImportError: import Image ### User avatar settings ### -AVATAR_DEFAULT_SIZE = getattr(settings, 'AVATAR_DEFAULT_SIZE', 80) +AVATAR_DEFAULT_SIZE = getattr(settings, 'AVATAR_DEFAULT_SIZE', 256) AVATAR_STORAGE_DIR = getattr(settings, 'AVATAR_STORAGE_DIR', 'avatars') AVATAR_DEFAULT_URL = getattr(settings, 'AVATAR_DEFAULT_URL', 'avatar/img/default.png') AVATAR_DEFAULT_NON_REGISTERED_URL = getattr(settings, 'AVATAR_DEFAULT_NON_REGISTERED_URL', '/avatars/default-non-register.jpg') -AUTO_GENERATE_AVATAR_SIZES = getattr(settings, 'AUTO_GENERATE_AVATAR_SIZES', (AVATAR_DEFAULT_SIZE,)) ### Group avatars ### GROUP_AVATAR_DEFAULT_SIZE = getattr(settings, 'GROUP_AVATAR_DEFAULT_SIZE', 48) diff --git a/seahub/avatar/util.py b/seahub/avatar/util.py index 2c55f8c929..7ad1cbdcd3 100644 --- a/seahub/avatar/util.py +++ b/seahub/avatar/util.py @@ -6,9 +6,8 @@ from urllib.parse import quote from seahub.base.accounts import User from seahub.avatar.settings import AVATAR_DEFAULT_URL, AVATAR_CACHE_TIMEOUT,\ - AUTO_GENERATE_AVATAR_SIZES, AVATAR_DEFAULT_SIZE, \ - AVATAR_DEFAULT_NON_REGISTERED_URL, AUTO_GENERATE_GROUP_AVATAR_SIZES, \ - AVATAR_FILE_STORAGE + AVATAR_DEFAULT_SIZE, AVATAR_DEFAULT_NON_REGISTERED_URL, \ + AUTO_GENERATE_GROUP_AVATAR_SIZES, AVATAR_FILE_STORAGE cached_funcs = set() @@ -35,7 +34,7 @@ def cache_result(func): cache.set(key, value, AVATAR_CACHE_TIMEOUT) return value - def cached_func(user, size): + def cached_func(user, size=AVATAR_DEFAULT_SIZE): prefix = func.__name__ cached_funcs.add(prefix) key = get_cache_key(user, size, prefix=prefix) @@ -46,7 +45,7 @@ def invalidate_cache(user, size=None): """ Function to be called when saving or changing an user's avatars. """ - sizes = set(AUTO_GENERATE_AVATAR_SIZES) + sizes = {AVATAR_DEFAULT_SIZE} if size is not None: sizes.add(size) for prefix in cached_funcs: diff --git a/seahub/base/context_processors.py b/seahub/base/context_processors.py index 1793e20860..87be112bc0 100644 --- a/seahub/base/context_processors.py +++ b/seahub/base/context_processors.py @@ -113,7 +113,7 @@ def base(request): if os.path.exists(custom_login_bg_file): login_bg_path = CUSTOM_LOGIN_BG_PATH - avatar_url, is_default, date_uploaded = api_avatar_url(username, 72) + avatar_url, is_default, date_uploaded = api_avatar_url(username) result = { 'seafile_version': SEAFILE_VERSION, diff --git a/seahub/drafts/views.py b/seahub/drafts/views.py index 85b06fe1f5..000fbe70c7 100644 --- a/seahub/drafts/views.py +++ b/seahub/drafts/views.py @@ -43,7 +43,7 @@ def draft(request, pk): draft_file_name = os.path.basename(d.draft_file_path) - author_info = user_to_dict(d.username, avatar_size=32) + author_info = user_to_dict(d.username) return render(request, "draft.html", { "draft_id": d.id, diff --git a/seahub/group/utils.py b/seahub/group/utils.py index c03273831e..d80881098f 100644 --- a/seahub/group/utils.py +++ b/seahub/group/utils.py @@ -88,14 +88,14 @@ def is_group_admin_or_owner(group_id, email): else: return False -def get_group_member_info(request, group_id, email, avatar_size=AVATAR_DEFAULT_SIZE): +def get_group_member_info(request, group_id, email): p = Profile.objects.get_profile_by_user(email) if p: login_id = p.login_id if p.login_id else '' else: login_id = '' - avatar_url, is_default, date_uploaded = api_avatar_url(email, avatar_size) + avatar_url, is_default, date_uploaded = api_avatar_url(email) role = 'Member' group = ccnet_api.get_group(int(group_id)) diff --git a/seahub/institutions/api_views.py b/seahub/institutions/api_views.py index f6d0aa7183..5fd192eec5 100644 --- a/seahub/institutions/api_views.py +++ b/seahub/institutions/api_views.py @@ -104,7 +104,7 @@ class InstAdminUsers(APIView): user_info['name'] = email2nickname(email) user_info['contact_email'] = email2contact_email(email) user_info['is_institution_admin'] = email in admin_emails - user_info['avatar_url'], _, _ = api_avatar_url(email, 72) + user_info['avatar_url'], _, _ = api_avatar_url(email) try: user_obj = User.objects.get(email=email) @@ -242,7 +242,7 @@ class InstAdminUser(APIView): user_info['name'] = email2nickname(email) user_info['contact_email'] = email2contact_email(email) user_info['is_active'] = user_obj.is_active - user_info['avatar_url'], _, _ = api_avatar_url(email, 72) + user_info['avatar_url'], _, _ = api_avatar_url(email) try: user_info['quota_total'] = seafile_api.get_user_quota(email) user_info['quota_usage'] = seafile_api.get_user_self_usage(email) @@ -314,7 +314,7 @@ class InstAdminSearchUser(APIView): user_info['name'] = email2nickname(email) user_info['contact_email'] = email2contact_email(email) user_info['is_institution_admin'] = email in admin_emails - user_info['avatar_url'], _, _ = api_avatar_url(email, 72) + user_info['avatar_url'], _, _ = api_avatar_url(email) try: user_obj = User.objects.get(email=email) diff --git a/seahub/notifications/management/commands/send_file_updates.py b/seahub/notifications/management/commands/send_file_updates.py index 27a0622b45..f821cf4d90 100644 --- a/seahub/notifications/management/commands/send_file_updates.py +++ b/seahub/notifications/management/commands/send_file_updates.py @@ -71,14 +71,14 @@ class Command(BaseCommand): logger.debug('Finish sending file updates emails.\n') self.stdout.write('[%s] Finish sending file updates emails.\n\n' % str(datetime.now())) - def get_avatar(self, username, default_size=32): - img_tag = avatar(username, default_size) + def get_avatar(self, username): + img_tag = avatar(username, 128) pattern = r'src="(.*)"' repl = r'src="%s\1"' % get_site_scheme_and_netloc() return re.sub(pattern, repl, img_tag) - def get_avatar_src(self, username, default_size=32): - avatar_img = self.get_avatar(username, default_size) + def get_avatar_src(self, username): + avatar_img = self.get_avatar(username) m = re.search(' {% if user %} - {% avatar user.username 64 %} + {% avatar user.username 128 %}

{{ nickname }}

{% else %} - {% avatar "" 64 %} + {% avatar "" 128 %} {% endif %} {% endblock %} diff --git a/seahub/seadoc/apis.py b/seahub/seadoc/apis.py index 2cf06eef87..b11abdcc75 100644 --- a/seahub/seadoc/apis.py +++ b/seahub/seadoc/apis.py @@ -620,10 +620,10 @@ class SeadocHistory(APIView): permission_classes = (IsAuthenticated,) throttle_classes = (UserRateThrottle, ) - def _get_new_file_history_info(self, ent, avatar_size, name_dict): + def _get_new_file_history_info(self, ent, name_dict): info = {} creator_name = ent.get('op_user') - url, is_default, date_uploaded = api_avatar_url(creator_name, avatar_size) + url, is_default, date_uploaded = api_avatar_url(creator_name) info['creator_avatar_url'] = url info['creator_email'] = creator_name info['creator_name'] = email2nickname(creator_name) @@ -665,11 +665,9 @@ class SeadocHistory(APIView): commit_id = repo.head_cmmt_id try: - avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE)) page = int(request.GET.get('page', 1)) per_page = int(request.GET.get('per_page', 25)) except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE page = 1 per_page = 25 @@ -707,7 +705,7 @@ class SeadocHistory(APIView): name_queryset = SeadocHistoryName.objects.list_by_obj_ids( doc_uuid=file_uuid, obj_id_list=obj_id_list) name_dict = {item.obj_id: item.name for item in name_queryset} - data = [self._get_new_file_history_info(ent, avatar_size, name_dict) for ent in file_revisions] + data = [self._get_new_file_history_info(ent, name_dict) for ent in file_revisions] result = { "histories": data } @@ -766,10 +764,10 @@ class SeadocDailyHistoryDetail(APIView): permission_classes = (IsAuthenticated,) throttle_classes = (UserRateThrottle, ) - def _get_new_file_history_info(self, ent, avatar_size, name_dict): + def _get_new_file_history_info(self, ent, name_dict): info = {} creator_name = ent.op_user - url, is_default, date_uploaded = api_avatar_url(creator_name, avatar_size) + url, is_default, date_uploaded = api_avatar_url(creator_name) info['creator_avatar_url'] = url info['creator_email'] = creator_name info['creator_name'] = email2nickname(creator_name) @@ -806,11 +804,6 @@ class SeadocDailyHistoryDetail(APIView): error_msg = 'Library %s not found.' % repo_id return api_error(status.HTTP_404_NOT_FOUND, error_msg) - try: - avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE)) - except ValueError: - avatar_size = AVATAR_DEFAULT_SIZE - op_date = request.GET.get('op_date', None) if not op_date: error_msg = 'op_date invalid.' @@ -840,7 +833,7 @@ class SeadocDailyHistoryDetail(APIView): name_queryset = SeadocHistoryName.objects.list_by_obj_ids( doc_uuid=file_uuid, obj_id_list=obj_id_list) name_dict = {item.obj_id: item.name for item in name_queryset} - data = [self._get_new_file_history_info(ent, avatar_size, name_dict) for ent in file_revisions] + data = [self._get_new_file_history_info(ent, name_dict) for ent in file_revisions] result = { "histories": data[1:] } @@ -873,7 +866,7 @@ class SeadocNotificationsView(APIView): for notification in notifications_query: data = notification.to_dict() data.update( - user_to_dict(notification.username, request=request, avatar_size=avatar_size)) + user_to_dict(notification.username, request=request)) notifications.append(data) result = {'notifications': notifications} @@ -991,7 +984,7 @@ class SeadocCommentsView(APIView): for file_comment in file_comments: comment = file_comment.to_dict(reply_queryset) - comment.update(user_to_dict(file_comment.author, request=request, avatar_size=avatar_size)) + comment.update(user_to_dict(file_comment.author, request=request)) comments.append(comment) result = {'comments': comments, 'total_count': total_count} @@ -1024,7 +1017,7 @@ class SeadocCommentsView(APIView): file_comment = FileComment.objects.add_by_file_uuid( file_uuid, username, comment, detail) comment = file_comment.to_dict() - comment.update(user_to_dict(username, request=request, avatar_size=avatar_size)) + comment.update(user_to_dict(username, request=request)) # notification to_users = set() @@ -1041,7 +1034,7 @@ class SeadocCommentsView(APIView): 'created_at': datetime_to_isoformat_timestr(file_comment.created_at), 'updated_at': datetime_to_isoformat_timestr(file_comment.updated_at), } - detail.update(user_to_dict(username, request=request, avatar_size=avatar_size)) + detail.update(user_to_dict(username, request=request)) new_notifications = [] for to_user in to_users: @@ -1092,7 +1085,7 @@ class SeadocCommentView(APIView): comment = file_comment.to_dict() comment.update(user_to_dict( - file_comment.author, request=request, avatar_size=avatar_size)) + file_comment.author, request=request)) return Response(comment) def delete(self, request, file_uuid, comment_id): @@ -1161,7 +1154,7 @@ class SeadocCommentView(APIView): file_comment.save() comment = file_comment.to_dict() - comment.update(user_to_dict(file_comment.author, request=request, avatar_size=avatar_size)) + comment.update(user_to_dict(file_comment.author, request=request)) return Response(comment) @@ -1206,7 +1199,7 @@ class SeadocCommentRepliesView(APIView): for reply in reply_queryset: data = reply.to_dict() data.update( - user_to_dict(reply.author, request=request, avatar_size=avatar_size)) + user_to_dict(reply.author, request=request)) replies.append(data) result = {'replies': replies, 'total_count': total_count} @@ -1250,7 +1243,7 @@ class SeadocCommentRepliesView(APIView): ) data = reply.to_dict() data.update( - user_to_dict(reply.author, request=request, avatar_size=avatar_size)) + user_to_dict(reply.author, request=request)) # notification to_users = set() @@ -1268,7 +1261,7 @@ class SeadocCommentRepliesView(APIView): 'created_at': datetime_to_isoformat_timestr(reply.created_at), 'updated_at': datetime_to_isoformat_timestr(reply.updated_at), } - detail.update(user_to_dict(username, request=request, avatar_size=avatar_size)) + detail.update(user_to_dict(username, request=request)) new_notifications = [] for to_user in to_users: @@ -1322,7 +1315,7 @@ class SeadocCommentReplyView(APIView): data = reply.to_dict() data.update( - user_to_dict(reply.author, request=request, avatar_size=avatar_size)) + user_to_dict(reply.author, request=request)) return Response(data) def delete(self, request, file_uuid, comment_id, reply_id): @@ -1381,7 +1374,7 @@ class SeadocCommentReplyView(APIView): data = reply.to_dict() data.update( - user_to_dict(reply.author, request=request, avatar_size=avatar_size)) + user_to_dict(reply.author, request=request)) return Response(data) diff --git a/seahub/seadoc/utils.py b/seahub/seadoc/utils.py index 125eb0972c..99bd290097 100644 --- a/seahub/seadoc/utils.py +++ b/seahub/seadoc/utils.py @@ -44,7 +44,7 @@ def uuid_str_to_36_chars(file_uuid): def gen_seadoc_access_token(file_uuid, filename, username, permission='rw', default_title=None): name = email2nickname(username) - url, is_default, date_uploaded = api_avatar_url(username, 72) + url, is_default, date_uploaded = api_avatar_url(username) if default_title is None: default_title = filename access_token = jwt.encode({ diff --git a/seahub/settings.py b/seahub/settings.py index 44832e631e..047f34f3e9 100644 --- a/seahub/settings.py +++ b/seahub/settings.py @@ -517,7 +517,7 @@ AVATAR_DEFAULT_URL = '/avatars/default.png' AVATAR_DEFAULT_NON_REGISTERED_URL = '/avatars/default-non-register.jpg' AVATAR_MAX_AVATARS_PER_USER = 1 AVATAR_CACHE_TIMEOUT = 14 * 24 * 60 * 60 -AUTO_GENERATE_AVATAR_SIZES = (16, 20, 24, 28, 32, 36, 40, 42, 48, 60, 64, 72, 80, 84, 96, 128, 160) +AVATAR_DEFAULT_SIZE = 256 # Group avatar GROUP_AVATAR_STORAGE_DIR = 'avatars/groups' GROUP_AVATAR_DEFAULT_URL = 'avatars/groups/default.png' diff --git a/seahub/templates/repo_snapshot_react.html b/seahub/templates/repo_snapshot_react.html index c6055d599f..ca8d0fa9c7 100644 --- a/seahub/templates/repo_snapshot_react.html +++ b/seahub/templates/repo_snapshot_react.html @@ -22,7 +22,7 @@ window.app.pageOptions = { {% if current_commit.props.creator_name %} showAuthor: true, - authorAvatarURL: "{% avatar_url current_commit.props.creator_name 40 %}", + authorAvatarURL: "{% avatar_url current_commit.props.creator_name %}", authorName: '{{ current_commit.props.creator_name|escapejs }}', authorNickName: '{{ current_commit.props.creator_name|email2nickname|escapejs }}', {% endif %} diff --git a/seahub/wiki/models.py b/seahub/wiki/models.py index ec22fc399e..0a64a905c0 100644 --- a/seahub/wiki/models.py +++ b/seahub/wiki/models.py @@ -99,7 +99,7 @@ class Wiki(models.Model): return True def to_dict(self): - avatar_url, is_default, date_uploaded = api_avatar_url(self.username, int(32)) + avatar_url, is_default, date_uploaded = api_avatar_url(self.username) return { 'id': self.pk, 'owner': self.username, diff --git a/seahub/wopi/views.py b/seahub/wopi/views.py index c2575a3ca9..2303c34efc 100644 --- a/seahub/wopi/views.py +++ b/seahub/wopi/views.py @@ -262,7 +262,7 @@ class WOPIFilesView(APIView): result['UserCanWrite'] = True if can_edit else False result['ReadOnly'] = True if not can_edit else False - avatar_url, _, _ = api_avatar_url(request_user, int(72)) + avatar_url, _, _ = api_avatar_url(request_user) result['UserExtraInfo'] = {'avatar': avatar_url, 'mail': request_user} # new file creation feature is not implemented on wopi host(seahub) diff --git a/tests/api/endpoints/test_user_avatar.py b/tests/api/endpoints/test_user_avatar.py index 487b2da344..0d4a69e191 100644 --- a/tests/api/endpoints/test_user_avatar.py +++ b/tests/api/endpoints/test_user_avatar.py @@ -15,18 +15,13 @@ class AvatarApiTest(ApiTestBase): avatar_url = urljoin(BASE_URL, avatar_url) avatar_file = os.path.join(os.getcwd(), 'media/img/seafile-logo.png') - random_avatar_size = random.randint(12, 128) + random_avatar_size = 256 with open(avatar_file, 'rb') as f: - json_resp = self.post(avatar_url, files={'avatar': f}, data={'avatar_size': random_avatar_size}).json() + json_resp = self.post(avatar_url, files={'avatar': f}, data={'avatar_size': 256}).json() assert 'avatar_url' in json_resp response_url = json_resp['avatar_url'] list_url = response_url.split('/') assert str(random_avatar_size) in list_url - # assert is NOT default avatar - avatar_url = urljoin(AVATAR_BASE_URL, 'user', self.username, '/resized/80/') - info = self.get(avatar_url).json() - assert 'resized' in info['url'] - assert info['is_default'] == False