Skip to content

Fix bug that list item failed to keep original order and dict item failed to save its all items#21

Open
dalang wants to merge 2 commits intoabbasovalex:masterfrom
dalang:master
Open

Fix bug that list item failed to keep original order and dict item failed to save its all items#21
dalang wants to merge 2 commits intoabbasovalex:masterfrom
dalang:master

Conversation

@dalang
Copy link

@dalang dalang commented Jun 12, 2016

for example, the json object I want to save via django form as below:

{
    "FAT": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
    "UAT": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
    "PROD": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
    "TEST": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
}

after saved, the json changed as below:

{
    'FAT': {'CMS': {'group': ['True', '']}},
    'PROD': {'CDPortal': {'group': ['True', '']}},
    'TEST': {'TARS': {'server': ['', 'True']}},
    'UAT': {'CDPortal': {'server': ['', 'True']}}
}

there are two issues this patch to fix:

  1. value of json_obj['UAT']['CDPortal']['server'] should be ['True', ''], not ['', 'True'] # order changed
  2. once item in json_obj is a dict, like json_obj['FAT'], it should have 3
    items ('TARS', 'CMS', 'CDPortal'), but only one item saved.

dalang added 2 commits June 12, 2016 10:58
… item in json failed to save its all items

for example, the json I want to save via django form as below:

{
    "FAT": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
    "UAT": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
    "PROD": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
    "TEST": {
        "TARS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CMS": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
        "CDPortal": {"application": [True, ""], "group": [True, ""], "server": [True, ""]},
    },
}

after saved, the json changed as below:

{
    'FAT': {'CMS': {'group': ['True', '']}},
    'PROD': {'CDPortal': {'group': ['True', '']}},
    'TEST': {'TARS': {'server': ['', 'True']}},
    'UAT': {'CDPortal': {'server': ['', 'True']}}
}

there are two issues this patch to fix:
1. value of json_obj['UAT']['CDPortal']['server'] should be ['True',
''], not ['', 'True']  # order changed
2. once item in json_obj is a dict, like json['FAT'], it should have 3
items ('TARS', 'CMS', 'CDPortal'), but only one item saved.
Since OrderedDict is not a build-in lib in python 2.6.9, last commit can
not pass the ci verification.
this commit removed the dependency of OrderedDict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant