Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move extraction of params from request to outside SubmissionPost
breaks SubmissionPost API
- Loading branch information
1 parent
e3954a7
commit e4b4af9
Showing
5 changed files
with
48 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .getters import * | ||
from .util import SubmissionPost |
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,29 @@ | ||
from django.utils.datastructures import MultiValueDictKeyError | ||
from couchforms.const import MAGIC_PROPERTY, MULTIPART_FILENAME_ERROR | ||
|
||
__all__ = ['get_path', 'get_instance_and_attachment'] | ||
|
||
|
||
def get_path(request): | ||
return request.path | ||
|
||
|
||
def get_instance_and_attachment(request): | ||
attachments = {} | ||
if request.META['CONTENT_TYPE'].startswith('multipart/form-data'): | ||
# it's an standard form submission (eg ODK) | ||
# this does an assumption that ODK submissions submit using the form parameter xml_submission_file | ||
# todo: this should be made more flexibly to handle differeing params for xform submission | ||
try: | ||
instance = request.FILES[MAGIC_PROPERTY].read() | ||
except MultiValueDictKeyError: | ||
instance = MULTIPART_FILENAME_ERROR | ||
else: | ||
for key, item in request.FILES.items(): | ||
if key != MAGIC_PROPERTY: | ||
attachments[key] = item | ||
else: | ||
#else, this is a raw post via a j2me client of xml (or touchforms) | ||
#todo, multipart raw submissions need further parsing capacity. | ||
instance = request.raw_post_data | ||
return instance, attachments |
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