telephony: автоформат +380, тип линии SIP/АТС и звонок через Asterisk AMI.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-13 14:52:09 +03:00
parent cc62324b69
commit 5d06d4d3ce
42 changed files with 1158 additions and 57 deletions
+23 -1
View File
@@ -338,6 +338,7 @@ class AccessSystemAdmin(ModelAdmin):
class ConnectorConfigAdmin(ModelAdmin):
list_display = ('connector_type_display', 'is_enabled', 'host', 'port', 'use_ssl', 'updated_at')
list_filter = ('is_enabled', 'use_ssl', 'connector_type')
actions = ('ping_asterisk_ami',)
fieldsets = (
(_('Основное'), {
@@ -355,7 +356,10 @@ class ConnectorConfigAdmin(ModelAdmin):
'description': _(
'OnlyOffice: {"public_url": "https://docs.example", '
'"callback_base": "https://portal.example"} — '
'token = JWT_SECRET Document Server. Nextcloud остаётся хранилищем файлов.'
'token = JWT_SECRET Document Server. '
'Asterisk AMI: {"originate_context": "from-internal", '
'"sip_channel": "PJSIP/{exten}", "analog_channel": "DAHDI/{exten}"}. '
'Логин/пароль = AMI user/secret, порт по умолчанию 5038.'
),
}),
)
@@ -369,6 +373,24 @@ class ConnectorConfigAdmin(ModelAdmin):
connector_type_display.short_description = _('Коннектор')
connector_type_display.admin_order_field = 'connector_type'
@admin.action(description=_('Проверить AMI (Ping)'))
def ping_asterisk_ami(self, request, queryset):
from apps.asterisk_connector.ami import AmiError
from apps.asterisk_connector.services import TelephonyError, ping_ami
for cfg in queryset:
if cfg.connector_type != 'asterisk':
self.message_user(
request,
_('%s: это не коннектор Asterisk AMI') % cfg,
messages.WARNING,
)
continue
try:
ping_ami(cfg)
self.message_user(request, _('%s: AMI отвечает') % cfg, messages.SUCCESS)
except (AmiError, TelephonyError) as exc:
self.message_user(request, f'{cfg}: {exc}', messages.ERROR)
class DashboardDefaultsForm(forms.ModelForm):
"""Наборы виджетов дашборда по умолчанию — чекбоксами по типу локации."""