telephony: автоформат +380, тип линии SIP/АТС и звонок через Asterisk AMI.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,7 @@ class ConnectorConfig(BaseModel):
|
||||
('mail', 'Почта (IMAP/SMTP)'),
|
||||
('nextcloud', 'Nextcloud'),
|
||||
('onlyoffice', 'OnlyOffice'),
|
||||
('asterisk', 'Asterisk AMI'),
|
||||
]
|
||||
|
||||
connector_type = models.CharField(
|
||||
@@ -41,9 +42,9 @@ class ConnectorConfig(BaseModel):
|
||||
_('Дополнительные параметры'), default=dict, blank=True,
|
||||
help_text=_(
|
||||
'JSON. Nextcloud: verify_ssl, timeout. '
|
||||
'OnlyOffice: public_url (URL Document Server), '
|
||||
'callback_base (публичный URL портала для скачивания/сохранения файла), '
|
||||
'verify_ssl.'
|
||||
'OnlyOffice: public_url, callback_base, verify_ssl. '
|
||||
'Asterisk AMI: originate_context (from-internal), '
|
||||
'sip_channel (PJSIP/{exten}), analog_channel (DAHDI/{exten}), timeout.'
|
||||
),
|
||||
)
|
||||
|
||||
@@ -62,7 +63,15 @@ class ConnectorConfig(BaseModel):
|
||||
super().clean()
|
||||
if self.is_enabled and not self.host:
|
||||
raise ValidationError({'host': _('Хост обязателен для включённого коннектора')})
|
||||
if self.is_enabled and not self.token and not self.username:
|
||||
if self.connector_type == 'asterisk' and self.is_enabled:
|
||||
errors = {}
|
||||
if not self.username:
|
||||
errors['username'] = _('Для AMI нужен логин менеджера')
|
||||
if not self.password:
|
||||
errors['password'] = _('Для AMI нужен секрет (password)')
|
||||
if errors:
|
||||
raise ValidationError(errors)
|
||||
elif self.is_enabled and not self.token and not self.username:
|
||||
raise ValidationError(
|
||||
_('Для включённого коннектора необходимо указать токен или логин')
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user