diff options
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, | 
