diff options
author | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2015-09-29 17:42:38 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander.sulfrian@fu-berlin.de> | 2015-09-29 17:42:38 +0200 |
commit | b42fa30b4652bfc47b782d9aeee4a1f3ddfd0c88 (patch) | |
tree | cc912126f642231be65c4b833059036b3d414ac1 /tools/upgrade/1.3 | |
parent | edd623511a2238f60d99aa72322af67d875f3484 (diff) | |
download | bcfg2-b42fa30b4652bfc47b782d9aeee4a1f3ddfd0c88.tar.gz bcfg2-b42fa30b4652bfc47b782d9aeee4a1f3ddfd0c88.tar.bz2 bcfg2-b42fa30b4652bfc47b782d9aeee4a1f3ddfd0c88.zip |
tools/upgrade: Fix checking for related fields
If we check for the existance of a related object, newer django versions
(>= 1.5) raise a ObjectDoesNotExist exception and we have to handle it.
Diffstat (limited to 'tools/upgrade/1.3')
-rwxr-xr-x | tools/upgrade/1.3/migrate_dbstats.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/upgrade/1.3/migrate_dbstats.py b/tools/upgrade/1.3/migrate_dbstats.py index 8911266fb..d4b5f12d0 100755 --- a/tools/upgrade/1.3/migrate_dbstats.py +++ b/tools/upgrade/1.3/migrate_dbstats.py @@ -79,13 +79,15 @@ def _migrate_transaction(inter, entries, fperms): modified_count=inter.modified_entries, extra_count=inter.extra_entries) - if inter.metadata: - newint.profile_id = inter.metadata.profile.id - groups = [grp.pk for grp in inter.metadata.groups.all()] - bundles = [bun.pk for bun in inter.metadata.bundles.all()] - else: - groups = [] - bundles = [] + groups = [] + bundles = [] + try: + if inter.metadata: + newint.profile_id = inter.metadata.profile.id + groups = [grp.pk for grp in inter.metadata.groups.all()] + bundles = [bun.pk for bun in inter.metadata.bundles.all()] + except ObjectDoesNotExist: + pass super(new_models.Interaction, newint).save() if bundles: newint.bundles.add(*bundles) |