-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[GSoC2024] Modified Attribute Serializer to retain values after request #7736
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, thank you for the contribution.
I see one problem here:
In the current REST API implementation, it is possible to specify several values for text attributes too (even though it looks useless). But in that case, after these changes, all values will be merged into one and this is wrong.
We use one CharField to store values and \n to separate them. Probably you can change the separator (e.g. \\n
), but in that case, Django migration must be added.
Hey @Marishka17, I understand what you are trying to say here, But how does a user trigger this intended use case in the first place? I understand you want User Input like this:
To be stored like this:
Instead of this:
So I need to:
Question: How will the User know how to use it? |
For example, users can use REST API directly
A user can check the server endpoint specification.
It is possible to fix this issue using one more way - we can restrict specifying values for text attributes since this makes no sense at all. In that case, we don't need to change the separator. IMHO, the second approach is more preferable. |
Hi @mach-12 Do you have any plans regarding the pull request? |
Yes, I need some help with understanding how to restrict specification of text values. Going to finish this PR |
@Marishka17, please, work together with @mach-12 to finish the PR. |
Hello @mach-12, sorry for the delay, I'm going to close this PR now, but do not hesitate to reopen it when you implement more appropriate solution. You can use the following approach to fix the issue:
|
Motivation and context
Fixing #6502: While creating or editing a multiline text attribute on a label, it was replacing the default newlines with commas.
This behavior was not appropriate. The cause of this issue was identified as the
DelimitedStringListField
serializer:cvat/cvat/apps/engine/serializers.py
Lines 226 to 240 in 70a7cc0
The fix was implemented by overriding the
to_representation()
method in the parentAttributeSerializer
. This method converts theListField
into a list with only a single object with the text concatenated if theinput_type
in the context is 'text'.Nested Label Serializers:
LabelSerializer
SublabelSerializer
AttributeSerializer
DelimitedStringListField
How has this been tested?
Changes persist as intended in the Tasks, Projects and Job views.
Checklist
develop
branch(cvat-canvas,
cvat-core,
cvat-data and
cvat-ui)
License
Feel free to contact the maintainers if that's a concern.