File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
src/Core/management/commands Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ sleep 5
1616
1717python manage.py algorithm
1818python manage.py createadmin
19- # python manage.py stanowisko
19+ python manage.py create_erp_connection
2020
2121while true ; do
2222 sleep 1
Original file line number Diff line number Diff line change 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." ))
You can’t perform that action at this time.
0 commit comments