Files
ACORE/apps/employees/serializers.py
T
lokses 27a917e8c3 Replace role field with auth.Group membership
- Remove Employee.role CharField — was a display-only label with no
  actual permission logic
- 3 migrations: create groups, migrate data, remove field
- Admin: list/filter/fieldset now use groups; added groups_display method
- Serializer: role → groups (SlugRelatedField returning group names)
- Template: get_role_display → groups.first.name
- EmployeePermissionOverride and PermissionGroup remain for fine-grained
  per-employee and per-group permission management
2026-05-31 15:04:31 +03:00

18 lines
792 B
Python

from rest_framework import serializers
from apps.employees.models import Employee
class EmployeeSerializer(serializers.ModelSerializer):
groups = serializers.SlugRelatedField(many=True, read_only=True, slug_field='name')
class Meta:
model = Employee
fields = [
'id', 'username', 'first_name', 'last_name', 'middle_name', 'email',
'groups', 'phone', 'personal_phone', 'personal_email', 'inn_code', 'birth_date',
'emergency_contact_name', 'emergency_contact_phone', 'emergency_contact_relation',
'user_location_type', 'user_organization', 'photo',
'mattermost_username', 'mattermost_sync_enabled',
'is_staff', 'is_active', 'date_joined'
]
read_only_fields = ['id', 'date_joined']