Files
ACORE/apps/ad_connector/admin.py
T
lokses ae5c1f1848 Add RRO, portal section perms, dislocation presets, and hiring intern flow.
Ship cash-register registry, section-based portal access, configurable dislocation columns, and trial-hire intern accounts with credentials PDF.
2026-08-09 14:58:17 +03:00

29 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from django.contrib import admin
from unfold.admin import ModelAdmin
from .models import ADSyncLog
@admin.register(ADSyncLog)
class ADSyncLogAdmin(ModelAdmin):
list_display = ('employee', 'action', 'status', 'created_at')
list_filter = ('action', 'status')
search_fields = ('employee__username', 'employee__last_name', 'employee__first_name', 'message')
date_hierarchy = 'created_at'
# Журнал только для просмотра — без массового удаления из changelist.
actions = None
def has_add_permission(self, request):
return False
def has_change_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
# Нельзя False для всех: Django get_deleted_objects() зовёт этот метод
# при удалении Employee с CASCADE на ADSyncLog и блокирует удаление
# сообщением «нет прав на Запись синхронизации AD».
# Разрешаем CASCADE тем, кто может удалять сотрудников; UI журнала
# без delete_selected (actions = None).
return request.user.has_perm('employees.delete_employee')