Files
tripwithbonus/GeneralApp/init_options.py
2023-12-02 13:45:54 +03:00

67 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from .models import *
from django.utils.translation import gettext as _
required_options_Dict = {
'mail_server_url': {
'name_ru': 'Адрес почтового сервера',
'opt_type': 'mail_server_url',
'value': '213.142.147.40',
},
'mail_server_smtp_port': {
'name_ru': 'SMTP порт почтового сервера',
'opt_type': 'mail_server_smtp_port',
'value': 587,
},
'sender_mail_login': {
'name_ru': 'email для отправки писем с сайта',
'opt_type': 'sender_mail_login',
'value': 'admin@tripwb.com',
},
'sender_email': {
'name_ru': 'email для отправки',
'opt_type': 'sender_email',
'value': 'admin@tripwb.com',
},
'sender_mail_password': {
'name_ru': 'пароль для отправки писем с сайта',
'opt_type': 'sender_mail_password',
'value': 't5Fdcah^gdajY',
},
'project_name': {
'name_ru': 'Название проекта',
'opt_type': 'project_name',
'value': 'TWB',
},
'domain': {
'name_ru': 'Адрес сайта',
'opt_type': 'domain',
'value': 'tripwb.com',
},
'support_email': {
'name_ru': 'email техподдержки',
'opt_type': 'support_email',
'value': 'admin@tripwb.com',
},
'corp_email': {
'name_ru': 'корпоративный email',
'opt_type': 'corp_email',
'value': 'admin@tripwb.com',
},
}
def init_options():
options = Option.objects.all()
option_types_list = options.values_list('opt_type', flat=True)
opts_for_create = []
for opt_type, data_Dict in required_options_Dict.items():
if not opt_type in option_types_list:
opt = Option(**data_Dict)
opts_for_create.append(opt)
Option.objects.bulk_create(opts_for_create)
return True