Show debug messages only if debug is true

This commit is contained in:
PCoder 2021-11-29 10:27:27 +05:30
parent fe32ab1e70
commit 5ef97645cb

View file

@ -1,5 +1,5 @@
import django.db.utils
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
from django.apps import apps
from django.db.utils import IntegrityError
@ -470,17 +470,20 @@ def handle_object_dict(object_dict, model_name, debug=False):
object_dict['taxon'] = object_dict['taxon_id']
object_dict.pop('taxon_id')
if model_name == 'Person' and 'organization_id' in object_dict:
if debug:
print("organization_id=%s" % object_dict['organization_id'])
if object_dict['organization_id'] == '' or object_dict['organization_id'] is None:
object_dict['organization_id'] = '-1'
else:
object_dict['organization_id'] = int(float(object_dict['organization_id']))
if 'status' in object_dict:
if debug:
print('Getting status of %s' % object_dict['status'])
if object_dict['status'] == '':
object_dict['status'] = 0
object_dict['status'] = PeopleStatus.objects.get(id=int(object_dict['status']))
if 'country_lookup' in object_dict:
if debug:
print('Getting country of %s' % object_dict['country_lookup'])
if object_dict['country_lookup'] == '':
object_dict['country_lookup'] = 0
@ -496,6 +499,7 @@ def handle_object_dict(object_dict, model_name, debug=False):
if i in object_dict:
object_dict[i] = True if object_dict[i].lower().strip() == 'true' else False
if object_dict is None:
if debug:
print("Object None for %s" % model_name)
# else:
# print(object_dict) if str(object_dict) is not None else "Str object dict is None"