locations: право редактирования аптеки, формы и дислокация
Отдельное право на редактирование карточки аптеки, формы, пресеты колонок дислокации и правки видимости карточки. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+14
-4
@@ -1,7 +1,7 @@
|
||||
from django import forms
|
||||
from django.contrib import admin
|
||||
from django.db import models
|
||||
from django.utils.html import format_html
|
||||
from django.utils.html import format_html, format_html_join
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils import timezone
|
||||
@@ -256,7 +256,7 @@ class PharmacyAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
search_fields = ['pharmacy_number', 'address', 'phone', 'license_number',
|
||||
'head_pharmacist__last_name', 'responsible_manager__last_name', 'curator__last_name']
|
||||
list_select_related = ['organization', 'location_region', 'head_pharmacist', 'responsible_manager', 'curator']
|
||||
ordering = ['organization', 'pharmacy_number']
|
||||
ordering = ['organization__name', 'pharmacy_number']
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Detail view — tabs
|
||||
@@ -327,6 +327,10 @@ class PharmacyAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
|
||||
inlines = [PharmacyPhoneInline, PharmacyHistoryInline]
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
obj._history_user = request.user
|
||||
super().save_model(request, obj, form, change)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Queryset
|
||||
# ------------------------------------------------------------------
|
||||
@@ -379,7 +383,6 @@ class PharmacyAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
employees_count_display.short_description = _('Сотрудников')
|
||||
|
||||
def phone_numbers_display(self, obj):
|
||||
from django.utils.safestring import mark_safe
|
||||
numbers = []
|
||||
if obj.phone:
|
||||
numbers.append(obj.phone)
|
||||
@@ -389,7 +392,7 @@ class PharmacyAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
)
|
||||
if not numbers:
|
||||
return '—'
|
||||
return mark_safe('<br>'.join(numbers))
|
||||
return format_html_join('<br>', '{}', ((n,) for n in numbers))
|
||||
phone_numbers_display.short_description = _('Телефоны')
|
||||
|
||||
|
||||
@@ -425,4 +428,11 @@ class PharmacyCardVisibilityAdmin(ModelAdmin):
|
||||
'show_rro', 'show_utilities', 'show_documents',
|
||||
),
|
||||
}),
|
||||
(_('Редактирование в портале'), {
|
||||
'description': _(
|
||||
'Кто может менять реквизиты аптеки на странице /pharmacies/<id>/ '
|
||||
'(кнопка «Редактировать»). Суперпользователь всегда может.'
|
||||
),
|
||||
'fields': ('edit_pharmacy',),
|
||||
}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user