dimagi/commcare-hq — pull request #482 by kennknowles (2013-06-17 19:51:02+00:00)
Title: App structure API

I would describe this API as "moderately gross" principally because it directly exposes some JSON serialization of apps & modules. However, I'm working on the assumption that all of this structure _is_ actually necessary and it would be hasty to imagine I could clean anything up without some context.

Example result (a one-module one-form app I just threw together)

```json
{
"meta": {
"limit": 20,
"next": null,
"offset": 0,
"previous": null,
"total_count": 2
},
"objects": [
{
"modules": [
{
"case_label": {
"en": "Cases"
},
"case_list": {
"doc_type": "CaseList",
"label": {

},
"show": false
},
"case_type": "ffff_case",
"details": [
{
"columns": [
{
"advanced": "",
"enum": {

},
"field": "case_property_a",
"filter_xpath": "",
"format": "plain",
"header": {
"en": "Case Property A"
},
"late_flag": 30,
"model": "case",
"time_ago_interval": 365.25
}
],
"doc_type": "Detail",
"type": "case_short"
},
{
"columns": [
{
"advanced": "",
"enum": {

},
"field": "case_property_a",
"filter_xpath": "",
"format": "plain",
"header": {
"en": "Case Property A"
},
"late_flag": 30,
"model": "case",
"time_ago_interval": 365.25
}
],
"doc_type": "Detail",
"type": "case_long"
},
{
"columns": [

],
"doc_type": "Detail",
"type": "ref_short"
},
{
"columns": [

],
"doc_type": "Detail",
"type": "ref_long"
}
],
"doc_type": "Module",
"forms": [
{
"actions": {
"case_preload": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "PreloadAction",
"preload": {

}
},
"close_case": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "FormAction"
},
"close_referral": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "FormAction"
},
"doc_type": "FormActions",
"open_case": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "OpenCaseAction",
"external_id": null,
"name_path": null
},
"open_referral": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "OpenReferralAction",
"followup_date": null,
"name_path": null
},
"referral_preload": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "PreloadAction",
"preload": {

}
},
"subcases": [

],
"update_case": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "UpdateCaseAction",
"update": {

}
},
"update_referral": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "UpdateReferralAction",
"followup_date": null
}
},
"doc_type": "Form",
"form_filter": "",
"media_audio": null,
"media_image": null,
"name": {
"en": "dddd"
},
"questions": [
{
"label": "fffddfasdfasdf",
"tag": "input",
"value": "\/data\/zzzz"
}
],
"requires": "none",
"show_count": false,
"unique_id": "1440bc01387379c721c72b0d5308cd57c4e8d115",
"version": null,
"xmlns": "http:\/\/openrosa.org\/formdesigner\/2EEAA1B8-8779-4028-8723-8C42E5C6ED09"
}
],
"media_audio": null,
"media_image": null,
"name": {
"en": "ffff"
},
"put_in_root": false,
"referral_label": {
"en": "Referrals"
},
"referral_list": {
"doc_type": "CaseList",
"label": {

},
"show": false
},
"task_list": {
"doc_type": "CaseList",
"label": {

},
"show": false
}
}
],
"name": "asdf",
"resource_uri": "",
"xforms": [

]
},
{
"modules": [
{
"case_label": {
"en": "Cases"
},
"case_list": {
"doc_type": "CaseList",
"label": {

},
"show": false
},
"case_type": "",
"details": [
{
"columns": [

],
"doc_type": "Detail",
"type": "case_short"
},
{
"columns": [

],
"doc_type": "Detail",
"type": "case_long"
},
{
"columns": [

],
"doc_type": "Detail",
"type": "ref_short"
},
{
"columns": [

],
"doc_type": "Detail",
"type": "ref_long"
}
],
"doc_type": "Module",
"forms": [
{
"actions": {
"case_preload": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "PreloadAction",
"preload": {

}
},
"close_case": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "FormAction"
},
"close_referral": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "FormAction"
},
"doc_type": "FormActions",
"open_case": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "OpenCaseAction",
"external_id": null,
"name_path": null
},
"open_referral": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "OpenReferralAction",
"followup_date": null,
"name_path": null
},
"referral_preload": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "PreloadAction",
"preload": {

}
},
"subcases": [

],
"update_case": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "UpdateCaseAction",
"update": {

}
},
"update_referral": {
"condition": {
"answer": null,
"doc_type": "FormActionCondition",
"question": null,
"type": "never"
},
"doc_type": "UpdateReferralAction",
"followup_date": null
}
},
"doc_type": "Form",
"form_filter": null,
"media_audio": null,
"media_image": null,
"name": {
"en": "Untitled Form"
},
"questions": [

],
"requires": "none",
"show_count": false,
"unique_id": "6b9066717165f1463b6c038ec29eb5d6574cb043",
"version": null,
"xmlns": null
}
],
"media_audio": null,
"media_image": null,
"name": {
"en": "Untitled Module"
},
"put_in_root": false,
"referral_label": {
"en": "Referrals"
},
"referral_list": {
"doc_type": "CaseList",
"label": {

},
"show": false
},
"task_list": {
"doc_type": "CaseList",
"label": {

},
"show": false
}
}
],
"name": "Untitled Application",
"resource_uri": "",
"xforms": [

]
}
]
}
```