Skip to content

Commit

Permalink
Merge pull request #5731 from haiwen/feat-sdoc-comment-avatar-size
Browse files Browse the repository at this point in the history
feat: sdoc comment avatar size use default
  • Loading branch information
shuntian authored Nov 4, 2023
2 parents db11007 + 33c43ca commit c5a75c7
Showing 1 changed file with 19 additions and 18 deletions.
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

0 comments on commit c5a75c7

Please sign in to comment.