from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from allauth.account.signals import user_signed_up
from B_main.models import Person

@receiver(user_signed_up)
def create_person_profile(sender, request, user, **kwargs):
    """회원가입 시 Person 프로필 생성"""
    try:
        # 이미 Person 프로필이 있는지 확인
        Person.objects.get_or_create(
            user=user,
            defaults={
                '이름': user.get_full_name() or user.username,
                '소속': '',
                '직책': '',
                '연락처': '',
                '주소': '',
                '사진': 'B_main/images/강경옥.png'
            }
        )
    except Exception as e:
        print(f"Person 프로필 생성 중 오류: {e}")
