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
Added data
as optional JSONField to extra price models.
#216
Added data
as optional JSONField to extra price models.
#216
Conversation
@jrief, requirements should be added to `ìnstall_requires``: https://github.com/divio/django-shop/blob/master/setup.py#L27 Otherwise, I am for using json field instead of text field too. |
So I found the problem: Previous versions (the versions that "work") simply pass in case of ValueError... Newer versions raise a ValidationError instead (which is desirable - it is not valid JSON). I think we should simply not allow plain ASCII, it's a JSON field so we should have at least one key/value. Having a hybrid approach seems a little unclean: either it's structured data or it's not, but not "both"... So I think we should not allow the case of the failing test (we should just enforce data to be JSON if it goes into the JSON field). |
The maintainer of jsonfield also agreed on this, see rpkilby/jsonfield#33. |
jsonfield is available in version 0.9.6 which fixes the pending issue, all unit tests pass. |
Nice! I'll try to test this on some real shops soon. I would also like to implement something similar for addresses on the order model #218 |
@jrief could you please add >=0.9.6 to the jsonfield dependency? Apart from that, I'm ok to merge. |
@chrisglass done: jsonfield>=0.9.6 |
Yay! Finally merging requested feature number 1 :) |
Added ``data`` as optional JSONField to extra price models.
Cart modifiers can add an optional
data
field besidelabel
andvalue
for both, the ExtraOrderPriceField and the ExtraOrderItemPriceField model.This extra
data
field can contain anything, which is serializable as JSON.This is based on issue #139 which however used a TextField for the
data
field. Since additional data can have any format, this pull request uses a JSONfield. This avoids additional string-to-object conversions.