Skip to content

Ensure translatable resources save their fields as JSON objects#6587

Merged
tramuntanal merged 32 commits intodevelopfrom
ensure-ttranslatable-resource-are-properly-saved-as-json-object
Oct 8, 2020
Merged

Ensure translatable resources save their fields as JSON objects#6587
tramuntanal merged 32 commits intodevelopfrom
ensure-ttranslatable-resource-are-properly-saved-as-json-object

Conversation

@mrcasals
Copy link
Copy Markdown
Contributor

@mrcasals mrcasals commented Oct 2, 2020

🎩 What? Why?

We want to make sure translatable resources save their transaltable fields as they should: as key-value hashes and not plain strings. We're having problems because it turns out that a plain string is a valid value for a JSONB field in the db.

With this PR we add a validation to the translatable resources to make sure the fields are properly saved, and detect where they are not.

Todo:

  • Migrate Attachments' title and description

📌 Related Issues

Testing

Let tests run.

📋 Checklist

🚨 Please review the guidelines for contributing to this repository.

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

📷 Screenshots

None

♥️ Thank you!

oriolgual
oriolgual previously approved these changes Oct 2, 2020
@mrcasals mrcasals force-pushed the ensure-ttranslatable-resource-are-properly-saved-as-json-object branch 6 times, most recently from bca869c to ee55b77 Compare October 6, 2020 08:11
@mrcasals
Copy link
Copy Markdown
Contributor Author

mrcasals commented Oct 6, 2020

@decidim/core can you review this PR, please? This fixes some bugs with the i18n of proposals, comments and other models. More specifically, at some point some if these models get updated and instead of having their titles saved as a JSONB object they're saved as strings, thus breaking the whole i18n support and the machine translations service.

This Pr ensures that those fields are actually saved as JSONB objects.

@mrcasals mrcasals requested a review from a team October 6, 2020 09:52
@mrcasals mrcasals force-pushed the ensure-ttranslatable-resource-are-properly-saved-as-json-object branch from 559481f to fdff787 Compare October 6, 2020 12:23
@mrcasals
Copy link
Copy Markdown
Contributor Author

mrcasals commented Oct 6, 2020

@decidim/core all green now, can you reeview this please? It fixes bugs!

@mrcasals mrcasals requested a review from tramuntanal October 6, 2020 13:59
@mrcasals
Copy link
Copy Markdown
Contributor Author

mrcasals commented Oct 7, 2020

@tramuntanal @decidim/core friendly reminder about this PR! It fixes some bugs caused by the recent machine translation system :)

@mrcasals mrcasals force-pushed the ensure-ttranslatable-resource-are-properly-saved-as-json-object branch from 0fba5a9 to 136a3fe Compare October 8, 2020 08:36
@tramuntanal tramuntanal added in-review release: v0.23 Issues that need to be tackled for v0.23 labels Oct 8, 2020
@tramuntanal tramuntanal self-assigned this Oct 8, 2020
@tramuntanal tramuntanal merged commit b201b1b into develop Oct 8, 2020
@tramuntanal tramuntanal deleted the ensure-ttranslatable-resource-are-properly-saved-as-json-object branch October 8, 2020 09:34
@tramuntanal
Copy link
Copy Markdown
Contributor

tramuntanal commented Oct 8, 2020

we're taking care of the backport to 0.23

tramuntanal pushed a commit that referenced this pull request Oct 8, 2020
* Ensure translatable resources save their fields as JSON objects

Instead of strings.

* Lint files

* Don't make collaborative drafts translatable

* Don't make proposal notes translatable

* Don't make surveys translatable

* Remove missing field

* Fix pages specs

* Fix budgets specs

* Fix comments specs

* Fix assemblies specs

* Fix core tests

* Fix debates specs

* Don't translate answer choices

* Fix initiatives specs

* Lint files

* Lint more files

* Fix meetings

* Fix process specs

* Fix proposals unit tests

* Fix proposals admin system specs

* Remove unused property

* Fix proposal public system specs

* Fix spec

* Fix more accountability specs

* Fix core specs

* Fix proposals factories

* Ensure attachments title and description are hashes

* Lint file

* Fix migration

* Improve migration

* Lint file

* Fix proposals specs
tramuntanal added a commit that referenced this pull request Oct 8, 2020
… (#6646)

* Ensure translatable resources save their fields as JSON objects

Instead of strings.

* Lint files

* Don't make collaborative drafts translatable

* Don't make proposal notes translatable

* Don't make surveys translatable

* Remove missing field

* Fix pages specs

* Fix budgets specs

* Fix comments specs

* Fix assemblies specs

* Fix core tests

* Fix debates specs

* Don't translate answer choices

* Fix initiatives specs

* Lint files

* Lint more files

* Fix meetings

* Fix process specs

* Fix proposals unit tests

* Fix proposals admin system specs

* Remove unused property

* Fix proposal public system specs

* Fix spec

* Fix more accountability specs

* Fix core specs

* Fix proposals factories

* Ensure attachments title and description are hashes

* Lint file

* Fix migration

* Improve migration

* Lint file

* Fix proposals specs

Co-authored-by: Marc Riera <mrc2407@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants