Skip to content

Commit a20adb2

Browse files
authored
- **Added logging for development environment debugging:** (#288)
- **Optimized `UNIT_MODEL_CHOICES` initialization in `data_import.py`:** - Simplified choice list creation by concatenating the default choice with enumerated unit models. - Removed unnecessary conditional logic for the first choice in the previous implementation.
1 parent 123309e commit a20adb2

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

dev_env/settings.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import os
22
from pathlib import Path
3+
import logging
4+
5+
logger = logging.getLogger(__name__)
6+
37

48
BASE_DIR = Path(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
59

610
SECRET_KEY = os.getenv('SECRET_KEY')
711
if not SECRET_KEY:
812
SECRET_KEY = 'djangoledger1234!DoNotUse!BadIdea!VeryInsecure!'
913

10-
DEBUG = False
14+
DEBUG = True
15+
if DEBUG:
16+
logger.setLevel(logging.DEBUG)
17+
logger.warning('DEBUG MODE ON. Do NOT use this Development Environment!')
1118

1219
ALLOWED_HOSTS = ['127.0.0.1', '192.168.1.102', 'localhost']
1320
CSRF_TRUSTED_ORIGINS = ['https://*.preview.app.github.dev']
@@ -28,7 +35,7 @@
2835
]
2936

3037
INTERNAL_IPS = [
31-
"127.0.0.1",
38+
'127.0.0.1',
3239
]
3340

3441
MIDDLEWARE = [
@@ -59,7 +66,7 @@
5966
'django.template.context_processors.request',
6067
'django.contrib.auth.context_processors.auth',
6168
'django.contrib.messages.context_processors.messages',
62-
'django_ledger.context.django_ledger_context'
69+
'django_ledger.context.django_ledger_context',
6370
],
6471
},
6572
},

django_ledger/forms/data_import.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,8 @@ def __init__(
281281
]
282282

283283
self.unit_model_qs = entity_model.entityunitmodel_set.all()
284-
self.UNIT_MODEL_CHOICES = [
285-
(u.uuid, u) if i > 0 else (None, '----')
286-
for i, u in enumerate(self.unit_model_qs)
284+
self.UNIT_MODEL_CHOICES = [(None, '----')] + [
285+
(u.uuid, u) for i, u in enumerate(self.unit_model_qs)
287286
]
288287

289288
self.VENDOR_MODEL_QS = entity_model.vendormodel_set.visible()

0 commit comments

Comments
 (0)