Skip to content

Commit 74bc1bb

Browse files
committed
ADDED new management command create connection for erp-service
1 parent f29c598 commit 74bc1bb

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sleep 5
1616

1717
python manage.py algorithm
1818
python manage.py createadmin
19-
#python manage.py stanowisko
19+
python manage.py create_erp_connection
2020

2121
while true; do
2222
sleep 1
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import logging
2+
3+
from django.core.management.base import BaseCommand
4+
from src.DatabaseConnections.models import ConnectionInfo
5+
6+
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
7+
logger = logging.getLogger(__name__)
8+
9+
10+
class Command(BaseCommand):
11+
help = "Create connection for erp-service."
12+
13+
def handle(self, *args, **options):
14+
connection, created = ConnectionInfo.objects.get_or_create(
15+
erp_system="5s_control",
16+
defaults={
17+
"type": "api",
18+
"dbms": "postgres",
19+
"is_active": True,
20+
"host": "http://erp-service",
21+
"server": None,
22+
"database": None,
23+
"username": "admin",
24+
"password": "admin",
25+
"port": 3005,
26+
"used_in_orders_view": True,
27+
},
28+
)
29+
30+
if created:
31+
logger.info("Connection created successfully.")
32+
self.stdout.write(self.style.SUCCESS("✅ Connection created successfully."))
33+
else:
34+
logger.info("Connection already exists.")
35+
self.stdout.write(self.style.SUCCESS("ℹ️ Connection already exists."))

0 commit comments

Comments
 (0)