Files
tripwithbonus/GeneralApp/init_options.py
SDE 2b6bbba265 0.8.0
options init
2023-11-29 20:18:22 +03:00

50 lines
1.5 KiB
Python
Raw 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 *
required_options_Dict = {
'Адрес почтового сервера': {
'name': 'Адрес почтового сервера',
'opt_type': 'mail_server_url',
},
'SMTP порт почтового сервера': {
'name': 'SMTP порт почтового сервера',
'opt_type': 'mail_server_smtp_port',
},
'email для отправки писем с сайта': {
'name': 'email для отправки писем с сайта',
'opt_type': 'sender_mail_login',
},
'Пароль для отправки писем с сайта': {
'name': 'пароль для отправки писем с сайта',
'opt_type': 'sender_mail_password',
},
'Название проекта': {
'name': 'Название проекта',
'opt_type': 'project_name',
'value': 'TWB'
},
'Адрес сайта': {
'name': 'Адрес сайта',
'opt_type': 'domain',
},
'email техподдержки': {
'name': 'email техподдержки',
'opt_type': 'support_email',
},
}
def init_options():
options = Option.objects.all()
option_names = options.values_list('name', flat=True)
opts_for_create = []
for name, data_Dict in required_options_Dict.items():
if not name in option_names:
opt = Option(**data_Dict)
opts_for_create.append(opt)
Option.objects.bulk_create(opts_for_create)
return True