diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-05-11 12:33:54 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-06-12 08:44:18 +0200 |
commit | 8b0b3cf749588394320af64b5350a1f09998f119 (patch) | |
tree | 67981f597f7b7a98b782d2db02687d83f1024772 /ishtar_common/utils.py | |
parent | 29df409889edeecc11b39021df6f4e6fb39535cc (diff) | |
download | Ishtar-8b0b3cf749588394320af64b5350a1f09998f119.tar.bz2 Ishtar-8b0b3cf749588394320af64b5350a1f09998f119.zip |
Migrate single image to M2M (refs #4076)
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 52ea98547..2af5212ca 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -424,7 +424,7 @@ def get_field_labels_from_path(model, path): return labels -def create_default_areas(models=None): +def create_default_areas(models=None, verbose=False): # can be used on migrations if models are provided if not models: from ishtar_common.models import Area, Town, Department, State @@ -444,7 +444,8 @@ def create_default_areas(models=None): areas['state-{}'.format(state.pk)] = area if created: idx += 1 - print("\n* {} state areas added".format(idx)) + if verbose: + print("\n* {} state areas added".format(idx)) idx, idx2 = 0, 0 for dep in Department.objects.all(): @@ -464,10 +465,11 @@ def create_default_areas(models=None): idx2 += 1 area.parent = areas[state_slug] area.save() - print( - "* {} department areas added with {} associations to state".format( - idx, idx2) - ) + if verbose: + print( + "* {} department areas added with {} associations to state".format( + idx, idx2) + ) idx = 0 for town in Town.objects.all(): @@ -484,7 +486,8 @@ def create_default_areas(models=None): areas[code_dep_dom].towns.add(town) idx += 1 - print("* {} town associated to department area".format(idx)) + if verbose: + print("* {} town associated to department area".format(idx)) def get_relations_for_graph(rel_model, obj_pk, above_relations=None, |