-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3757 from kobotoolbox/allow-duplicate-choices-in-…
…snapshots Allow duplicate choices in snapshots
- Loading branch information
Showing
8 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pyxform.constants import ALLOW_CHOICE_DUPLICATES | ||
|
||
def allow_choice_duplicates(content: dict) -> None: | ||
""" | ||
Modify `content` to include `allow_choice_duplicates=Yes` in the settings | ||
so long as that setting does not already exist. | ||
This should *not* be done for content that's being newly updated by a user, | ||
but rather *only* for internal conversions of existing content, e.g. when | ||
generating XML for an `AssetVersion` that was created prior to pyxform | ||
prohibiting duplicate choice values (aka choice names). | ||
See https://github.com/kobotoolbox/kpi/issues/3751 | ||
""" | ||
settings = content.setdefault('settings', {}) | ||
if ALLOW_CHOICE_DUPLICATES not in settings: | ||
settings[ALLOW_CHOICE_DUPLICATES] = 'yes' |