Add configurable pharmacy card tab visibility matrix.
Let admins set per-section access levels so operational data on pharmacy detail is no longer all-or-nothing for every logged-in user. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+29
-1
@@ -9,7 +9,10 @@ from unfold.admin import ModelAdmin, TabularInline
|
||||
from import_export.admin import ImportExportModelAdmin
|
||||
from unfold.contrib.import_export.forms import ExportForm, ImportForm
|
||||
from core.models import Directory
|
||||
from .models import Location, Pharmacy, PharmacyPhone, PharmacyHistory, DislocationColumnPreset
|
||||
from .models import (
|
||||
Location, Pharmacy, PharmacyPhone, PharmacyHistory,
|
||||
DislocationColumnPreset, PharmacyCardVisibility,
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -398,3 +401,28 @@ class DislocationColumnPresetAdmin(ModelAdmin):
|
||||
list_select_related = ['department']
|
||||
ordering = ['name']
|
||||
readonly_fields = ['created_at', 'updated_at', 'uuid']
|
||||
|
||||
|
||||
@admin.register(PharmacyCardVisibility)
|
||||
class PharmacyCardVisibilityAdmin(ModelAdmin):
|
||||
"""Єдиний запис політики — хто бачить вкладки картки аптеки."""
|
||||
|
||||
def has_add_permission(self, request):
|
||||
return not PharmacyCardVisibility.objects.exists()
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
fieldsets = (
|
||||
(_('Операционные вкладки карточки аптеки'), {
|
||||
'description': _(
|
||||
'Для каждой вкладки: кто может видеть данные. '
|
||||
'«Своя аптека или staff» — поведение по умолчанию. '
|
||||
'Суперпользователь всегда видит всё.'
|
||||
),
|
||||
'fields': (
|
||||
'show_staff', 'show_equipment', 'show_internet',
|
||||
'show_rro', 'show_utilities', 'show_documents',
|
||||
),
|
||||
}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user