Created
April 15, 2020 22:10
-
-
Save dorey/faf04cba96d239763d3f2dbcbf084d3f to your computer and use it in GitHub Desktop.
place in kpi's directory "kpi/scripts"
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
from kpi.models.asset import Asset | |
ASSET_CONTENT = {'choices': [{'$autovalue': 'red', | |
'$kuid': 'odkr1fAsW', | |
'label': ['Red'], | |
'list_name': 'ri2bk45', | |
'value': 'red'}, | |
{'$autovalue': 'yellow', | |
'$kuid': 'odkr2f3cX', | |
'label': ['Yellow'], | |
'list_name': 'ri2bk45', | |
'value': 'yellow'}, | |
{'$autovalue': 'blue', | |
'$kuid': 'odkr3f3cX', | |
'label': ['Blue'], | |
'list_name': 'ri2bk45', | |
'value': 'blue'}, | |
{'$autovalue': 'red', | |
'$kuid': 'kr111fAsW', | |
'label': ['Red'], | |
'list_name': 'legacyrankitems', | |
'value': 'red'}, | |
{'$autovalue': 'yellow', | |
'$kuid': 'kr222f3cX', | |
'label': ['Yellow'], | |
'list_name': 'legacyrankitems', | |
'value': 'yellow'}, | |
{'$autovalue': 'blue', | |
'$kuid': 'kr333f3cX', | |
'label': ['Blue'], | |
'list_name': 'legacyrankitems', | |
'value': 'blue'}], | |
'schema': '1', | |
'settings': {}, | |
'survey': [{'$autoname': 's1', | |
'$kuid': '0000m42', | |
'kobo--rank-items': 'legacyrankitems', | |
'label': ['legacy koborank'], | |
'required': False, | |
'type': 'begin_rank'}, | |
{'label': ['first choice'], 'name': 'rl1', 'type': 'rank__level'}, | |
{'label': ['second choice'], 'name': 'rl2', 'type': 'rank__level'}, | |
{'type': 'end_rank'}, | |
{'$autoname': 's1', | |
'$kuid': 'rn69m42', | |
'label': ['s1'], | |
'rank_from': 'ri2bk45', | |
'required': False, | |
'type': 'odkrank'}], | |
'translated': ['label'], | |
'translations': [None]} | |
def run(): | |
# most_recent_asset | |
asset = Asset.objects.order_by('date_created').last() | |
asset.content = ASSET_CONTENT | |
Asset.objects.bulk_update([asset], ['content']) | |
uid = asset.uid | |
print(''' | |
Your asset has been updated with the example odkrank form. | |
http://kf.kobo.local/#/forms/{}/landing | |
'''.format(uid)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment