Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sdoc comment avatar size use default #5731

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions seahub/seadoc/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from seahub.seadoc.sdoc_server_api import SdocServerAPI
from seahub.file_participants.models import FileParticipant
from seahub.base.accounts import User
from seahub.avatar.settings import AVATAR_DEFAULT_SIZE


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -562,11 +563,11 @@ def get(self, request, file_uuid):
commit_id = repo.head_cmmt_id

try:
avatar_size = int(request.GET.get('avatar_size', 32))
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 = 32
avatar_size = AVATAR_DEFAULT_SIZE
page = 1
per_page = 25

Expand Down Expand Up @@ -804,9 +805,9 @@ def get(self, request, file_uuid):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE

resolved = request.GET.get('resolved', None)
if resolved not in ('true', 'false', None):
Expand Down Expand Up @@ -856,9 +857,9 @@ def post(self, request, file_uuid):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE

comment = request.data.get('comment', '')
detail = request.data.get('detail', '')
Expand Down Expand Up @@ -889,9 +890,9 @@ def get(self, request, file_uuid, comment_id):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE

# resource check
try:
Expand Down Expand Up @@ -935,9 +936,9 @@ def put(self, request, file_uuid, comment_id):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE

# argument check
resolved = request.data.get('resolved')
Expand Down Expand Up @@ -989,9 +990,9 @@ def get(self, request, file_uuid, comment_id):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE
start = None
end = None
page = request.GET.get('page', '')
Expand Down Expand Up @@ -1034,9 +1035,9 @@ def post(self, request, file_uuid, comment_id):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE
reply_content = request.data.get('reply', '')
type_content = request.data.get('type', 'reply')
author = request.data.get('author', '')
Expand Down Expand Up @@ -1078,9 +1079,9 @@ def get(self, request, file_uuid, comment_id, reply_id):
return api_error(status.HTTP_403_FORBIDDEN, error_msg)

try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE

# resource check
file_comment = FileComment.objects.filter(
Expand Down Expand Up @@ -1132,9 +1133,9 @@ def put(self, request, file_uuid, comment_id, reply_id):
if reply_content is None:
return api_error(status.HTTP_400_BAD_REQUEST, 'reply invalid.')
try:
avatar_size = int(request.GET.get('avatar_size', 32))
avatar_size = int(request.GET.get('avatar_size', AVATAR_DEFAULT_SIZE))
except ValueError:
avatar_size = 32
avatar_size = AVATAR_DEFAULT_SIZE

# resource check
file_comment = FileComment.objects.filter(
Expand Down
Loading