from django.db import models


class Organization(models.Model):
    name = models.CharField(max_length=100, verbose_name='公司名称')
    parent = models.ForeignKey(
        'self', null=True, blank=True,
        on_delete=models.SET_NULL,
        related_name='children',
        verbose_name='上级公司'
    )
    logo = models.ImageField(upload_to='org_logos/', null=True, blank=True)
    description = models.TextField(blank=True, verbose_name='公司简介')
    email = models.EmailField(blank=True, verbose_name='联系邮箱')
    is_active = models.BooleanField(default=True)
    created_at = models.DateTimeField(auto_now_add=True)

    class Meta:
        app_label = 'organizations'
        verbose_name = '组织架构'
        verbose_name_plural = '组织架构'

    def __str__(self):
        return self.name
