Skip to content

Commit

Permalink
* assigning a name that shouldn't conflict
Browse files Browse the repository at this point in the history
* avoiding changes to asset_version.content on save

Certain incorrectly deployed surveys (lacking names) might
have records that fail to export correctly, but we can
make adjustments in the future
  • Loading branch information
dorey committed Oct 18, 2016
1 parent 96a0e1c commit 0b9996b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
9 changes: 3 additions & 6 deletions kpi/models/asset_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ class AssetVersion(models.Model):
class Meta:
ordering = ['-date_modified']

def save(self, *args, **kwargs):
if self.deployed and self.deployed_content is None:
self.deployed_content = self._deployed_content()
super(AssetVersion, self).save(*args, **kwargs)

def _deployed_content(self):
if self.deployed_content is not None:
return self.deployed_content
legacy_names = self._reversion_version is not None
if legacy_names:
return to_xlsform_structure(self.version_content,
Expand All @@ -49,7 +46,7 @@ def _deployed_content(self):

def to_formpack_schema(self):
return {
'content': self.deployed_content or self._deployed_content(),
'content': self._deployed_content(),
'version': self.uid,
'version_id_key': '__version__',
}
Expand Down
5 changes: 2 additions & 3 deletions kpi/utils/autoname.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from kpi.utils.sluggify import (sluggify, sluggify_label, is_valid_nodeName)


from formpack.utils.json_hash import json_hash



Expand Down Expand Up @@ -51,8 +51,7 @@ def autoname_fields__depr(surv_content):
if 'label' in surv_row:
next_name = sluggify_valid_xml__depr(surv_row['label'])
else:
raise ValueError('Label cannot be translated: %s' %
json.dumps(surv_row))
next_name = 'unnamable_row_{}'.format(json_hash(surv_row))
while next_name in kuid_names.values():
next_name = _increment(next_name)
if 'kuid' not in surv_row:
Expand Down

0 comments on commit 0b9996b

Please sign in to comment.