dimagi/commcare-hq — pull request #439 by sravfeyn (2013-06-11 12:54:48+00:00)
Title: Adds 'upload fixtures through API' functionality

Adds following functionality http://manage.dimagi.com/default.asp?61884#357275. Implements a view to upload fixtures.

I had started implementing this, on top of tastypie library that we are using. But seems, tastypie has no file-upload support as of now (https://github.com/toastdriven/django-tastypie/issues/42). Accessing multipart-form data is not yet implemented. There are some experimental solutions though.

So I implemented this as a separate view. I haven't yet added proper URL structure that agree with current API. I am looking forward to change this after discussing with you. Currently following is the URL structure to upload fixtures.
curl -F "file-to-upload=@sample_fixture.xlsx" -v --digest -u sreddy@dimagi.com:password http://127.0.0.1:8000/a/{domain}/fixtures/fixapi/

It responds with a json output of the format {"code": (depending on success/failure/warning), "message": (helpful message to debug)}
Currently the codes are randomly chosen just to exemplify the implementation.