Show debug messages only if debug is true
This commit is contained in:
parent
fe32ab1e70
commit
5ef97645cb
1 changed files with 9 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
||||||
import django.db.utils
|
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.apps import apps
|
||||||
|
|
||||||
from django.db.utils import IntegrityError
|
from django.db.utils import IntegrityError
|
||||||
|
@ -470,18 +470,21 @@ def handle_object_dict(object_dict, model_name, debug=False):
|
||||||
object_dict['taxon'] = object_dict['taxon_id']
|
object_dict['taxon'] = object_dict['taxon_id']
|
||||||
object_dict.pop('taxon_id')
|
object_dict.pop('taxon_id')
|
||||||
if model_name == 'Person' and 'organization_id' in object_dict:
|
if model_name == 'Person' and 'organization_id' in object_dict:
|
||||||
print("organization_id=%s" % object_dict['organization_id'])
|
if debug:
|
||||||
|
print("organization_id=%s" % object_dict['organization_id'])
|
||||||
if object_dict['organization_id'] == '' or object_dict['organization_id'] is None:
|
if object_dict['organization_id'] == '' or object_dict['organization_id'] is None:
|
||||||
object_dict['organization_id'] = '-1'
|
object_dict['organization_id'] = '-1'
|
||||||
else:
|
else:
|
||||||
object_dict['organization_id'] = int(float(object_dict['organization_id']))
|
object_dict['organization_id'] = int(float(object_dict['organization_id']))
|
||||||
if 'status' in object_dict:
|
if 'status' in object_dict:
|
||||||
print('Getting status of %s' % object_dict['status'])
|
if debug:
|
||||||
|
print('Getting status of %s' % object_dict['status'])
|
||||||
if object_dict['status'] == '':
|
if object_dict['status'] == '':
|
||||||
object_dict['status'] = 0
|
object_dict['status'] = 0
|
||||||
object_dict['status'] = PeopleStatus.objects.get(id=int(object_dict['status']))
|
object_dict['status'] = PeopleStatus.objects.get(id=int(object_dict['status']))
|
||||||
if 'country_lookup' in object_dict:
|
if 'country_lookup' in object_dict:
|
||||||
print('Getting country of %s' % object_dict['country_lookup'])
|
if debug:
|
||||||
|
print('Getting country of %s' % object_dict['country_lookup'])
|
||||||
if object_dict['country_lookup'] == '':
|
if object_dict['country_lookup'] == '':
|
||||||
object_dict['country_lookup'] = 0
|
object_dict['country_lookup'] = 0
|
||||||
object_dict['country'] = Country.objects.get(id=int(object_dict['country_lookup']))
|
object_dict['country'] = Country.objects.get(id=int(object_dict['country_lookup']))
|
||||||
|
@ -496,7 +499,8 @@ def handle_object_dict(object_dict, model_name, debug=False):
|
||||||
if i in object_dict:
|
if i in object_dict:
|
||||||
object_dict[i] = True if object_dict[i].lower().strip() == 'true' else False
|
object_dict[i] = True if object_dict[i].lower().strip() == 'true' else False
|
||||||
if object_dict is None:
|
if object_dict is None:
|
||||||
print("Object None for %s" % model_name)
|
if debug:
|
||||||
|
print("Object None for %s" % model_name)
|
||||||
# else:
|
# else:
|
||||||
# print(object_dict) if str(object_dict) is not None else "Str object dict is None"
|
# print(object_dict) if str(object_dict) is not None else "Str object dict is None"
|
||||||
return object_dict
|
return object_dict
|
||||||
|
|
Loading…
Reference in a new issue