feat: report auto-bumped version on form replace#3125
Open
kelvin-muchiri wants to merge 2 commits into
Open
Conversation
When a form is replaced with an XLSForm that reuses an existing version string, the version is auto-bumped (-2, -3, ...). Communicate that back to the client, mirroring has_id_string_changed: - track the change via a transient _version_changed flag on DataDictionary, exposed as XForm.has_version_changed - add XFormUpdateSerializer (version-only) and use it for the replace response, serializing the freshly-published form so the returned version reflects the bump - has_version_changed is True only when the version was bumped
Prospector (pylint protected-access) flagged setting dd._version_changed on an external object. Scope a pylint disable to that line and reuse the computed version_changed boolean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes / Features implemented
Follow-up to #3075. When a form is replaced with an XLSForm that reuses an existing version string, onadata auto-bumps the version (
-2,-3, …). Previously this happened silently — the client was never told. This surfaces it on the replace response (PATCH /api/v1/forms/{pk}), mirroring the existinghas_id_string_changedpattern._version_changedflag onDataDictionary(set insave()for the XLS path and inpublish_xml_formfor the XML path), exposed as theXForm.has_version_changedproperty.XFormUpdateSerializer(adds onlyhas_version_changed, nohas_id_string_changedcoupling) and use it in_try_update_xlsform.versionreflects the bump (also fixes a latent staleness bug where the replace response returned the old version).The client reads both answers from the replace response: "to what?" via the existing
versionfield (now accurate), and "was it auto-bumped?" viahas_version_changed.has_version_changedisTrueonly when the submitted version collided with an existingXFormVersion; it is scoped to the replace response and absent from form GET/list responses.Steps taken to verify this change does what is intended
Added/extended tests in
test_xform_viewset.py, run via docker (no regressions against existing form-replacement tests):versionis the bumped value andhas_version_changedisTrue.transportation_version.xlsx): version used as-is,has_version_changedisFalse.has_version_changedabsent (confirms scoping).Side effects of implementing this change
PATCH /api/v1/forms/{pk}replace response now serializes the freshly-published form rather than the stale pre-replace object, and gains ahas_version_changedboolean field. Both are additive; the previously-staleversionfield is now correct.Before submitting this PR for review, please make sure you have:
Closes #