HH/apps/accounts/management/commands/seed_acknowledgements.py
2026-03-09 16:10:24 +03:00

153 lines
5.0 KiB
Python

"""
Management command to seed the 14 default acknowledgement categories.
Usage:
python manage.py seed_acknowledgements
"""
from django.core.management.base import BaseCommand
from django.utils.translation import gettext_lazy as _
class Command(BaseCommand):
help = 'Seed the 14 default acknowledgement categories'
# 14 default categories as specified
DEFAULT_CATEGORIES = [
{
'code': 'CLINICS',
'name_en': 'Clinics',
'name_ar': 'العيادات',
'icon': 'building',
'color': '#007bbd',
},
{
'code': 'ADMISSIONS_SOCIAL',
'name_en': 'Admissions / Social Services',
'name_ar': 'القبول / الخدمات الاجتماعية',
'icon': 'users',
'color': '#005696',
},
{
'code': 'MED_APPROVALS',
'name_en': 'Medical Approvals',
'name_ar': 'الموافقات الطبية',
'icon': 'file-check',
'color': '#10b981',
},
{
'code': 'CALL_CENTER',
'name_en': 'Call Center',
'name_ar': 'مركز الاتصال',
'icon': 'phone',
'color': '#f59e0b',
},
{
'code': 'PAYMENTS',
'name_en': 'Payments',
'name_ar': 'المدفوعات',
'icon': 'credit-card',
'color': '#6366f1',
},
{
'code': 'EMERGENCY',
'name_en': 'Emergency Services',
'name_ar': 'خدمات الطوارئ',
'icon': 'alert-circle',
'color': '#ef4444',
},
{
'code': 'MED_REPORTS',
'name_en': 'Medical Reports',
'name_ar': 'التقارير الطبية',
'icon': 'file-text',
'color': '#8b5cf6',
},
{
'code': 'ADMISSIONS_OFFICE',
'name_en': 'Admissions Office',
'name_ar': 'مكتب القبول',
'icon': 'briefcase',
'color': '#06b6d4',
},
{
'code': 'CBAHI',
'name_en': 'CBAHI',
'name_ar': 'الهلال الأحمر',
'icon': 'shield',
'color': '#dc2626',
},
{
'code': 'HR_PORTAL',
'name_en': 'HR Portal',
'name_ar': 'بوابة الموارد البشرية',
'icon': 'user-cog',
'color': '#059669',
},
{
'code': 'GENERAL_ORIENTATION',
'name_en': 'General Orientation',
'name_ar': 'التوجيه العام',
'icon': 'info',
'color': '#0891b2',
},
{
'code': 'SEHATY',
'name_en': 'Sehaty App (sick leaves)',
'name_ar': 'تطبيق صحتي (إجازات مرضية)',
'icon': 'smartphone',
'color': '#7c3aed',
},
{
'code': 'MOH_CARE',
'name_en': 'MOH Care Portal',
'name_ar': 'بوابة رعاية وزارة الصحة',
'icon': 'heart-pulse',
'color': '#db2777',
},
{
'code': 'CHI_CARE',
'name_en': 'CHI Care Portal',
'name_ar': 'بوابة رعاية مجلس الصحة',
'icon': 'activity',
'color': '#0284c7',
},
]
def handle(self, *args, **options):
from apps.accounts.models import AcknowledgementCategory
self.stdout.write(self.style.WARNING('Seeding 14 default acknowledgement categories...'))
created_count = 0
updated_count = 0
for category_data in self.DEFAULT_CATEGORIES:
category, created = AcknowledgementCategory.objects.update_or_create(
code=category_data['code'],
defaults={
'name_en': category_data['name_en'],
'name_ar': category_data['name_ar'],
'icon': category_data['icon'],
'color': category_data['color'],
'is_default': True,
'is_active': True,
}
)
if created:
created_count += 1
self.stdout.write(self.style.SUCCESS(f'✓ Created: {category.name_en}'))
else:
updated_count += 1
self.stdout.write(self.style.WARNING(f'↻ Updated: {category.name_en}'))
# Summary
total = AcknowledgementCategory.objects.filter(is_default=True).count()
self.stdout.write(self.style.SUCCESS('\n' + '='*50))
self.stdout.write(self.style.SUCCESS(f'✓ Seeding complete!'))
self.stdout.write(self.style.SUCCESS(f' Created: {created_count}'))
self.stdout.write(self.style.SUCCESS(f' Updated: {updated_count}'))
self.stdout.write(self.style.SUCCESS(f' Total default categories: {total}'))
self.stdout.write(self.style.SUCCESS('='*50))