def from_parsed_action(cls, date, user_id, xformdoc, action): if not action.action_type_slug in const.CASE_ACTIONS: raise ValueError("%s not a valid case action!" % action.action_type_slug) ret = CommCareCaseAction(action_type=action.action_type_slug, date=date, user_id=user_id) ret.server_date = xformdoc.received_on ret.xform_id = xformdoc.form_id ret.xform_xmlns = xformdoc.xmlns ret.xform_name = getattr(xformdoc, 'name', '') ret.updated_known_properties = action.get_known_properties() ret.updated_unknown_properties = action.dynamic_properties ret.indices = [ CommCareCaseIndex.from_case_index_update(i) for i in action.indices ] ret.attachments = dict( (attach_id, CommCareCaseAttachment.from_case_index_update(attach)) for attach_id, attach in action.attachments.items()) if hasattr(xformdoc, "last_sync_token"): ret.sync_log_id = xformdoc.last_sync_token return ret
def from_parsed_action(cls, date, user_id, xformdoc, action): if not action.action_type_slug in const.CASE_ACTIONS: raise ValueError("%s not a valid case action!" % action.action_type_slug) ret = CommCareCaseAction(action_type=action.action_type_slug, date=date, user_id=user_id) ret.server_date = xformdoc.received_on ret.xform_id = xformdoc.get_id ret.xform_xmlns = xformdoc.xmlns ret.xform_name = xformdoc.name ret.updated_known_properties = action.get_known_properties() ret.updated_unknown_properties = action.dynamic_properties ret.indices = [CommCareCaseIndex.from_case_index_update(i) for i in action.indices] ret.attachments = dict((attach_id, CommCareCaseAttachment.from_case_index_update(attach)) for attach_id, attach in action.attachments.items()) if hasattr(xformdoc, "last_sync_token"): ret.sync_log_id = xformdoc.last_sync_token return ret
user_id='user-abc123', modified_on=datetime.datetime(2011, 12, 20, 0, 11, 2), owner_id='group-abc123', name='Jessica', version='2.0', indices=[], case_attachments={ 'fruity_file': CommCareCaseAttachment( attachment_from=u'local', attachment_name=None, attachment_properties={ 'width': 240, 'height': 164 }, attachment_size=22731, attachment_src= u'./corehq/ex-submodules/casexml/apps/case/tests/data/attachments/fruity.jpg', doc_type=u'CommCareCaseAttachment', identifier=u'fruity_file', server_md5=None, server_mime=u'image/jpeg', ) }, age='25', ), { u'fruity_file': u'./corehq/ex-submodules/casexml/apps/case/tests/data/attachments/fruity.jpg' }, """ <case case_id="new-case-abc123" date_modified="2011-12-20T00:11:02.000000Z" user_id="user-abc123"