options init
This commit is contained in:
SDE
2023-11-29 20:51:36 +03:00
parent 42cf20137b
commit 23de94b8cd
3 changed files with 62 additions and 27 deletions

View File

@@ -0,0 +1,27 @@
from .models import *
def get_options_by_opt_types(opt_types, only_vals=False):
if type(opt_types) == str:
kwargs = {'opt_type': opt_types}
elif type(opt_types) == dict:
kwargs = opt_types
else:
kwargs = {'opt_type__in': opt_types}
opts = Option.objects.filter(**kwargs)
if opts and only_vals:
opts = opts.values('name', 'value')
opts = {item['name']: item['value'] for item in opts}
return opts
def get_first_option_value_by_opt_type(opt_type):
opts = get_options_by_opt_types(opt_type)
if opts:
return opts[0].value
else:
return None
def get_mail_send_options():
opt_types = ['mail_server_url', 'mail_server_smtp_port', 'sender_mail_login', 'sender_mail_password', 'sender_email']
return get_options_by_opt_types(opt_types, only_vals=True)

View File

@@ -5,31 +5,47 @@ required_options_Dict = {
'Адрес почтового сервера': {
'name': 'Адрес почтового сервера',
'opt_type': 'mail_server_url',
'value': '213.142.147.40',
},
'SMTP порт почтового сервера': {
'name': 'SMTP порт почтового сервера',
'opt_type': 'mail_server_smtp_port',
'value': 587,
},
'email для отправки писем с сайта': {
'login для отправки писем с сайта': {
'name': 'email для отправки писем с сайта',
'opt_type': 'sender_mail_login',
'value': 'admin@tripwb.com',
},
'email для отправки': {
'name': 'email для отправки',
'opt_type': 'sender_email',
'value': 'admin@tripwb.com',
},
'Пароль для отправки писем с сайта': {
'name': 'пароль для отправки писем с сайта',
'opt_type': 'sender_mail_password',
'value': 't5Fdcah^gdajY',
},
'Название проекта': {
'name': 'Название проекта',
'opt_type': 'project_name',
'value': 'TWB'
'value': 'TWB',
},
'Адрес сайта': {
'name': 'Адрес сайта',
'opt_type': 'domain',
'value': 'tripwb.com',
},
'email техподдержки': {
'name': 'email техподдержки',
'opt_type': 'support_email',
'value': 'admin@tripwb.com',
},
'корпоративный email': {
'name': 'корпоративный email',
'opt_type': 'corp_email',
'value': 'admin@tripwb.com',
},
}