Add an extra_data field to FileAttachment.
Review Request #12747 — Created Jan. 13, 2023 and submitted
This adds an
extra_data
field to ourFileAttachment
model and support
for modifying the field through file attachment forms and the web API.
Upgraded the database and ran unit tests.
Summary | ID |
---|---|
be70a777ce1bf9610ee57f96372de91185e2e08f |
Description | From | Last Updated |
---|---|---|
While here, since we're adding typing, we're also going to need a from __future__ import annotations import (in its own … |
chipx86 | |
I was trying to determine if it was safe to use Django's forms.JSONField, as it's meant to be used with … |
chipx86 | |
This can just be review_request. |
chipx86 | |
For this test and the others, let's be more comprehensive with the data and the results. We should cover: Strings … |
chipx86 | |
Since this is changing anyway, can you convert this to single quotes? |
chipx86 | |
Can you add a __future__ import here as well? |
chipx86 | |
The type should ideally be Dict[str, Any]. |
chipx86 | |
Add a trailing comma here. |
david | |
You'll want to make sure you have mypy and pyright set up and checking code. None can't be assigned to … |
chipx86 | |
Add a trailing comma here. |
david | |
Can you add a __future__ import here? |
chipx86 | |
Same comments as above. |
chipx86 | |
Add a trailing comma here. |
david | |
Same comments as above. |
chipx86 | |
Add a trailing comma here. |
david |
-
-
While here, since we're adding typing, we're also going to need a
from __future__ import annotations
import (in its own import group at the top).Mind also moving the
import os
to go before thefrom
imports? This is older code, but would be nice to get that to conform to standards while making related changes. -
I was trying to determine if it was safe to use Django's
forms.JSONField
, as it's meant to be used withmodels.JSONField
. I think it is, but I don't think it's ideal. We have some transformative stuff for JSON that isn't built into Django's version.So I think we should be using
djblets.db.fields.json_field.JSONFormField
instead.In either case, though, I don't think you need
clean_extra_data
. Were you hitting a case where this was needed? -
-
For this test and the others, let's be more comprehensive with the data and the results. We should cover:
- Strings
- Integers
- Booleans
- None
- Nested objects
- Nested lists,
- Date/time fields (important: Django and Djblets serialize this differently)
Given that,
data
should be in a multi-line dict form, as should the value going intojson.dumps
, for here and other new tests. -
-
-
-
You'll want to make sure you have mypy and pyright set up and checking code.
None
can't be assigned to something that isn't wrapped inOptional
.Similar to above,
extra_fields
should be aDict[str, Any]
. -
-
-
- Commits:
-
Summary ID 9c8f727923e76276f50ffcc97928c28df5781870 8872e6cacaa1ebcc835f4fb341968ec5c2b33d4d - Diff:
-
Revision 2 (+972 -70)
Checks run (2 succeeded)
- Commits:
-
Summary ID 8872e6cacaa1ebcc835f4fb341968ec5c2b33d4d be70a777ce1bf9610ee57f96372de91185e2e08f - Diff:
-
Revision 3 (+1122 -70)