2024-05-30 13:40:50 +08:00
|
|
|
# accounts/models.py
|
2024-05-29 15:25:17 +08:00
|
|
|
from django.db import models
|
2024-05-30 13:40:50 +08:00
|
|
|
from django.conf import settings
|
|
|
|
from application.hrm_mgnt.models import EmployeeInformation
|
2024-05-29 15:25:17 +08:00
|
|
|
|
2024-05-30 13:40:50 +08:00
|
|
|
|
|
|
|
class AccountProfile(models.Model):
|
2024-06-26 11:09:07 +08:00
|
|
|
ROLE_CHOICES = [
|
|
|
|
('all_permissions', 'All Permissions'),
|
|
|
|
('department_permissions', 'Department Permissions'),
|
|
|
|
('own_permissions', 'Own Permissions'),
|
|
|
|
]
|
|
|
|
|
2024-05-30 13:40:50 +08:00
|
|
|
user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='profile')
|
|
|
|
employee_information = models.OneToOneField(EmployeeInformation, on_delete=models.CASCADE, related_name='account_profile', verbose_name='员工信息')
|
2024-06-26 11:09:07 +08:00
|
|
|
role = models.CharField(max_length=255, choices=ROLE_CHOICES, verbose_name='角色', default='own_permissions')
|
2024-05-30 13:40:50 +08:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = '账户信息'
|
|
|
|
verbose_name_plural = '账户信息'
|
|
|
|
|
|
|
|
def __str__(self):
|
2024-06-26 11:09:07 +08:00
|
|
|
return self.employee_information.name
|
2024-06-26 09:52:00 +08:00
|
|
|
|