feat: implement consumable inventory module, network LAN access, and CI/CD enhancements
- Modul Consumable Item: model master, buku besar transaksi (stock ledger), purchase unit conversion, stock opname, dan transaction reversal - Integrasi ke Employee Management, Asset Unit, dan tiket/work order - Konfigurasi akses jaringan lokal (LAN) via 0.0.0.0:8000, ALLOWED_HOSTS, dan CSRF_TRUSTED_ORIGINS otomatis - Script pembuka firewall Windows (buka_firewall_lan.bat) dan menu interaktif run.bat - Skema migrasi 0019_consumableitem_consumabletransaction - Seeder 11 item consumable riil (seed_consumables.py) - Test suite komprehensif (41 automated tests, 100% lulus) - Pipeline CI/CD GitHub Actions (.github/workflows/ci.yml)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Creates or updates a superuser based on credentials in the .env file.'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
User = get_user_model()
|
||||
|
||||
username = os.getenv('SUPERUSER_USERNAME')
|
||||
email = os.getenv('SUPERUSER_EMAIL', '')
|
||||
password = os.getenv('SUPERUSER_PASSWORD')
|
||||
|
||||
if not username or not password:
|
||||
self.stdout.write(self.style.ERROR('SUPERUSER_USERNAME and SUPERUSER_PASSWORD must be set in .env'))
|
||||
return
|
||||
|
||||
user, created = User.objects.get_or_create(username=username)
|
||||
if created:
|
||||
user.email = email
|
||||
user.is_superuser = True
|
||||
user.is_staff = True
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
self.stdout.write(self.style.SUCCESS(f'Successfully created new superuser: {username}'))
|
||||
else:
|
||||
user.email = email
|
||||
user.is_superuser = True
|
||||
user.is_staff = True
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
self.stdout.write(self.style.SUCCESS(f'Successfully updated password and permissions for existing user: {username}'))
|
||||
Reference in New Issue
Block a user