Skip to content

Commit

Permalink
bring a small computation out of a loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyroberts committed Aug 27, 2013
1 parent ea64d73 commit c2fc400
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions casexml/apps/case/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,21 +729,21 @@ def _apply_action(self, action):
else:
raise ValueError("Can't apply action of type %s" % action.action_type)


def apply_updates(self, update_action):
"""
Applies updates to a case
"""
for k, v in update_action.updated_known_properties.items():
setattr(self, k, v)

properties = self.properties()
for item in update_action.updated_unknown_properties:
if item not in const.CASE_TAGS:
value = couchable_property(update_action.updated_unknown_properties[item])
if isinstance(self.properties().get(item), StringProperty):
if isinstance(properties.get(item), StringProperty):
value = unicode(value)
self[item] = value

def apply_attachments(self, attachment_action):
#the actions and _attachment must be added before the first saves canhappen
#todo attach cached attachment info
Expand Down

0 comments on commit c2fc400

Please sign in to comment.