2024-03-19 12:38:28 +00:00
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
"""
|
|
|
|
|
|
@project: maxkb
|
|
|
|
|
|
@Author:虎
|
|
|
|
|
|
@file: system_setting.py
|
|
|
|
|
|
@date:2024/3/19 16:05
|
|
|
|
|
|
@desc:
|
|
|
|
|
|
"""
|
|
|
|
|
|
from drf_yasg import openapi
|
|
|
|
|
|
|
|
|
|
|
|
from common.mixins.api_mixin import ApiMixin
|
2025-01-13 03:15:51 +00:00
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
2024-03-19 12:38:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SystemSettingEmailApi(ApiMixin):
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_request_body_api():
|
|
|
|
|
|
return openapi.Schema(type=openapi.TYPE_OBJECT,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Email related parameters'),
|
|
|
|
|
|
description=_('Email related parameters'),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
required=['email_host', 'email_port', 'email_host_user', 'email_host_password',
|
|
|
|
|
|
'email_use_tls', 'email_use_ssl', 'from_email'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'email_host': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('SMTP host'),
|
|
|
|
|
|
description=_('SMTP host')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_port': openapi.Schema(type=openapi.TYPE_NUMBER,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('SMTP port'),
|
|
|
|
|
|
description=_('SMTP port')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_host_user': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Sender\'s email'),
|
|
|
|
|
|
description=_('Sender\'s email')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_host_password': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Password'),
|
|
|
|
|
|
description=_('Password')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_use_tls': openapi.Schema(type=openapi.TYPE_BOOLEAN,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Whether to enable TLS'),
|
|
|
|
|
|
description=_('Whether to enable TLS')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_use_ssl': openapi.Schema(type=openapi.TYPE_BOOLEAN,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Whether to enable SSL'),
|
|
|
|
|
|
description=_('Whether to enable SSL')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'from_email': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Sender\'s email'),
|
|
|
|
|
|
description=_('Sender\'s email'))
|
2024-03-19 12:38:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
|
def get_response_body_api():
|
|
|
|
|
|
return openapi.Schema(type=openapi.TYPE_OBJECT,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Email related parameters'),
|
|
|
|
|
|
description=_('Email related parameters'),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
required=['email_host', 'email_port', 'email_host_user', 'email_host_password',
|
|
|
|
|
|
'email_use_tls', 'email_use_ssl', 'from_email'],
|
|
|
|
|
|
properties={
|
|
|
|
|
|
'email_host': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('SMTP host'),
|
|
|
|
|
|
description=_('SMTP host')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_port': openapi.Schema(type=openapi.TYPE_NUMBER,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('SMTP port'),
|
|
|
|
|
|
description=_('SMTP port')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_host_user': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Sender\'s email'),
|
|
|
|
|
|
description=_('Sender\'s email')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_host_password': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Password'),
|
|
|
|
|
|
description=_('Password')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_use_tls': openapi.Schema(type=openapi.TYPE_BOOLEAN,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Whether to enable TLS'),
|
|
|
|
|
|
description=_('Whether to enable TLS')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'email_use_ssl': openapi.Schema(type=openapi.TYPE_BOOLEAN,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Whether to enable SSL'),
|
|
|
|
|
|
description=_('Whether to enable SSL')),
|
2024-03-19 12:38:28 +00:00
|
|
|
|
'from_email': openapi.Schema(type=openapi.TYPE_STRING,
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title=_('Sender\'s email'),
|
|
|
|
|
|
description=_('Sender\'s email'))
|
2024-03-19 12:38:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
)
|