Skip to content

Conversation

@amCap1712
Copy link
Contributor

Update the /api/units/{unit_id}/comments/ endpoint to accept user and timestamp for a comment if the user making the request is a project admin. Return the comment id in the response as it is useful in testing and can also be useful in future resolve/delete comment APIs.

Fixes #14232.

Update the /api/units/{unit_id}/comments/ endpoint to accept user and timestamp for a comment
if the user making the request is a project admin. Return the comment id in the response as
it is useful in testing and can also be useful in future resolve/delete comment APIs.
comment=text,
userdetails={
kwargs = {
"user": user,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is no longer set from request?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set from the request but in in the views, I'll shift that logic to here.

Enhanced API response to include serialized comment details.
# Is this source or target comment?
unit_scope = unit.source_unit if scope in {"global", "report"} else unit

user = request.user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user variable is also used later in the code, and keeping it None value causes crashes (as can be seen in the tests).

@nijel nijel self-assigned this May 12, 2025
@nijel nijel merged commit fd959d9 into WeblateOrg:main May 12, 2025
47 of 49 checks passed
@nijel
Copy link
Member

nijel commented May 12, 2025

Merged, thanks for your contribution!

@nijel nijel added this to the 5.12 milestone May 21, 2025
@amCap1712 amCap1712 deleted the import-comments branch July 4, 2025 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose 'add comment' API endpoint

3 participants