247 lines
9.2 KiB
Python
247 lines
9.2 KiB
Python
"""
|
|
Management command to seed appreciation categories and badges
|
|
|
|
Usage:
|
|
python manage.py seed_appreciation_data
|
|
"""
|
|
from django.core.management.base import BaseCommand
|
|
from django.db import transaction
|
|
|
|
from apps.appreciation.models import (
|
|
AppreciationBadge,
|
|
AppreciationCategory,
|
|
)
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Seed appreciation categories and badges'
|
|
|
|
def handle(self, *args, **options):
|
|
self.stdout.write('Seeding appreciation data...')
|
|
|
|
with transaction.atomic():
|
|
# Seed categories
|
|
self.seed_categories()
|
|
|
|
# Seed badges
|
|
self.seed_badges()
|
|
|
|
self.stdout.write(self.style.SUCCESS('Successfully seeded appreciation data!'))
|
|
|
|
def seed_categories(self):
|
|
"""Seed appreciation categories"""
|
|
categories = [
|
|
{
|
|
'code': 'excellent_care',
|
|
'name_en': 'Excellent Care',
|
|
'name_ar': 'رعاية ممتازة',
|
|
'description_en': 'For providing exceptional patient care',
|
|
'description_ar': 'لتقديم رعاية استثنائية للمرضى',
|
|
'icon': 'fa-heart-pulse',
|
|
'color': '#FF5733',
|
|
'order': 1,
|
|
},
|
|
{
|
|
'code': 'team_player',
|
|
'name_en': 'Team Player',
|
|
'name_ar': 'لاعب فريق',
|
|
'description_en': 'For outstanding teamwork and collaboration',
|
|
'description_ar': 'للعمل الجماعي والتعاون المتميز',
|
|
'icon': 'fa-users',
|
|
'color': '#33FF57',
|
|
'order': 2,
|
|
},
|
|
{
|
|
'code': 'innovation',
|
|
'name_en': 'Innovation',
|
|
'name_ar': 'الابتكار',
|
|
'description_en': 'For introducing innovative solutions',
|
|
'description_ar': 'لتقديم حلول مبتكرة',
|
|
'icon': 'fa-lightbulb',
|
|
'color': '#F3FF33',
|
|
'order': 3,
|
|
},
|
|
{
|
|
'code': 'leadership',
|
|
'name_en': 'Leadership',
|
|
'name_ar': 'القيادة',
|
|
'description_en': 'For demonstrating exceptional leadership',
|
|
'description_ar': 'لإظهار قيادة استثنائية',
|
|
'icon': 'fa-crown',
|
|
'color': '#FFD700',
|
|
'order': 4,
|
|
},
|
|
{
|
|
'code': 'mentorship',
|
|
'name_en': 'Mentorship',
|
|
'name_ar': 'التوجيه',
|
|
'description_en': 'For guiding and supporting colleagues',
|
|
'description_ar': 'لإرشاد ودعم الزملاء',
|
|
'icon': 'fa-hands-holding-child',
|
|
'color': '#33FFF3',
|
|
'order': 5,
|
|
},
|
|
{
|
|
'code': 'going_extra_mile',
|
|
'name_en': 'Going the Extra Mile',
|
|
'name_ar': 'بذل جهد إضافي',
|
|
'description_en': 'For going above and beyond',
|
|
'description_ar': 'للتجاوز التوقعات',
|
|
'icon': 'fa-rocket',
|
|
'color': '#FF33F3',
|
|
'order': 6,
|
|
},
|
|
{
|
|
'code': 'reliability',
|
|
'name_en': 'Reliability',
|
|
'name_ar': 'الموثوقية',
|
|
'description_en': 'For consistent and dependable performance',
|
|
'description_ar': 'للأداء المتسابق والموثوق',
|
|
'icon': 'fa-shield-check',
|
|
'color': '#3357FF',
|
|
'order': 7,
|
|
},
|
|
{
|
|
'code': 'positive_attitude',
|
|
'name_en': 'Positive Attitude',
|
|
'name_ar': 'التفاؤل',
|
|
'description_en': 'For maintaining a positive outlook',
|
|
'description_ar': 'للحفاظ على التفاؤل',
|
|
'icon': 'fa-face-smile',
|
|
'color': '#FFA500',
|
|
'order': 8,
|
|
},
|
|
]
|
|
|
|
for category_data in categories:
|
|
category, created = AppreciationCategory.objects.get_or_create(
|
|
code=category_data['code'],
|
|
hospital=None, # System-wide categories
|
|
defaults=category_data
|
|
)
|
|
|
|
if created:
|
|
self.stdout.write(
|
|
self.style.SUCCESS(f"Created category: {category.name_en}")
|
|
)
|
|
else:
|
|
self.stdout.write(
|
|
self.style.WARNING(f"Category already exists: {category.name_en}")
|
|
)
|
|
|
|
def seed_badges(self):
|
|
"""Seed appreciation badges"""
|
|
badges = [
|
|
{
|
|
'code': 'first_appreciation',
|
|
'name_en': 'First Appreciation',
|
|
'name_ar': 'أول تكريم',
|
|
'description_en': 'Received your first appreciation',
|
|
'description_ar': 'حصلت على أول تكريم',
|
|
'icon': 'fa-star',
|
|
'color': '#FFD700',
|
|
'criteria_type': 'received_count',
|
|
'criteria_value': 1,
|
|
'order': 1,
|
|
},
|
|
{
|
|
'code': 'appreciated_5',
|
|
'name_en': 'Rising Star',
|
|
'name_ar': 'نجم صاعد',
|
|
'description_en': 'Received 5 appreciations',
|
|
'description_ar': 'حصلت على 5 تكريمات',
|
|
'icon': 'fa-star-half-stroke',
|
|
'color': '#C0C0C0',
|
|
'criteria_type': 'received_count',
|
|
'criteria_value': 5,
|
|
'order': 2,
|
|
},
|
|
{
|
|
'code': 'appreciated_10',
|
|
'name_en': 'Shining Star',
|
|
'name_ar': 'نجم لامع',
|
|
'description_en': 'Received 10 appreciations',
|
|
'description_ar': 'حصلت على 10 تكريمات',
|
|
'icon': 'fa-star',
|
|
'color': '#FFD700',
|
|
'criteria_type': 'received_count',
|
|
'criteria_value': 10,
|
|
'order': 3,
|
|
},
|
|
{
|
|
'code': 'appreciated_25',
|
|
'name_en': 'Super Star',
|
|
'name_ar': 'نجم خارق',
|
|
'description_en': 'Received 25 appreciations',
|
|
'description_ar': 'حصلت على 25 تكريم',
|
|
'icon': 'fa-trophy',
|
|
'color': '#FFA500',
|
|
'criteria_type': 'received_count',
|
|
'criteria_value': 25,
|
|
'order': 4,
|
|
},
|
|
{
|
|
'code': 'appreciated_50',
|
|
'name_en': 'Legendary',
|
|
'name_ar': 'أسطوري',
|
|
'description_en': 'Received 50 appreciations',
|
|
'description_ar': 'حصلت على 50 تكريم',
|
|
'icon': 'fa-crown',
|
|
'color': '#FF5733',
|
|
'criteria_type': 'received_count',
|
|
'criteria_value': 50,
|
|
'order': 5,
|
|
},
|
|
{
|
|
'code': 'monthly_champion',
|
|
'name_en': 'Monthly Champion',
|
|
'name_ar': 'بطل الشهر',
|
|
'description_en': 'Received 10 appreciations in a month',
|
|
'description_ar': 'حصلت على 10 تكريمات في شهر واحد',
|
|
'icon': 'fa-medal',
|
|
'color': '#33FF57',
|
|
'criteria_type': 'received_month',
|
|
'criteria_value': 10,
|
|
'order': 6,
|
|
},
|
|
{
|
|
'code': 'streak_4_weeks',
|
|
'name_en': 'Consistent',
|
|
'name_ar': 'مستمر',
|
|
'description_en': 'Received appreciations for 4 consecutive weeks',
|
|
'description_ar': 'حصلت على تكريمات لمدة 4 أسابيع متتالية',
|
|
'icon': 'fa-fire',
|
|
'color': '#FF4500',
|
|
'criteria_type': 'streak_weeks',
|
|
'criteria_value': 4,
|
|
'order': 7,
|
|
},
|
|
{
|
|
'code': 'diverse_appreciation',
|
|
'name_en': 'Well-Loved',
|
|
'name_ar': 'محبوب',
|
|
'description_en': 'Received appreciations from 10 different people',
|
|
'description_ar': 'حصلت على تكريمات من 10 أشخاص مختلفين',
|
|
'icon': 'fa-heart',
|
|
'color': '#FF1493',
|
|
'criteria_type': 'diverse_senders',
|
|
'criteria_value': 10,
|
|
'order': 8,
|
|
},
|
|
]
|
|
|
|
for badge_data in badges:
|
|
badge, created = AppreciationBadge.objects.get_or_create(
|
|
code=badge_data['code'],
|
|
defaults=badge_data
|
|
)
|
|
|
|
if created:
|
|
self.stdout.write(
|
|
self.style.SUCCESS(f"Created badge: {badge.name_en}")
|
|
)
|
|
else:
|
|
self.stdout.write(
|
|
self.style.WARNING(f"Badge already exists: {badge.name_en}")
|
|
)
|