From c26af858629c80efcc3db9ace589cd6a1cdcc2b1 Mon Sep 17 00:00:00 2001 From: Emil Date: Thu, 22 Aug 2019 11:38:41 +0300 Subject: [PATCH] file_with changes --- configuration/configuration.py | 53 ++++++++++++++++------------------ 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/configuration/configuration.py b/configuration/configuration.py index 2970cb3..0ab633e 100644 --- a/configuration/configuration.py +++ b/configuration/configuration.py @@ -4,45 +4,42 @@ def configure_app(): + disable_registration() configure_email() make_configuration() def configure_email(): - configure_info = get_configuration_from_file("/home/emil/Desktop/frappe-bench/apps/erpnext_autoinstall/configuration/email_config.txt") email_account = frappe.get_doc("Email Domain", "example.com") - email_account.email_server = configure_info['Example Email Address'] - email_account.email_id = configure_info['Example Email Address'] - email_account.domain_name = configure_info['Example Email Address'].split('@')[1] - email_account.smtp_server = configure_info.get('SMTP Server') - email_account.smtp_port = int(configure_info.get('Port')) - email_account.use_imap = int(configure_info.get('Use IMAP')) - email_account.use_ssl = int(configure_info.get('Use SSL')) - email_account.tls = int(configure_info.get('Use TLS')) - email_account.attachment_limit = int(configure_info.get('Attachment Limit (MB)')) + email_account.email_server = os.getenv('Example Email Address') + email_account.email_id = os.getenv('Example Email Address') + email_account.domain_name = os.getenv('Domain Name') + email_account.smtp_server = os.getenv('SMTP Server') + email_account.smtp_port = int(os.getenv('Port')) + email_account.use_imap = int(os.getenv('Use IMAP')) + email_account.use_ssl = int(os.getenv('Use SSL')) + email_account.tls = int(os.getenv('Use TLS')) + email_account.attachment_limit = int(os.getenv('Attachment Limit (MB)')) email_account.save() -def get_configuration_from_file(file_name): - dict_with_info = {} - print("Taking configuration from file: "+str(file_name)) - with open(file_name) as config_file: - for line in config_file: - dict_with_info[line.split(':')[0]] = line.split(':')[1].replace("\n",'') - print(dict_with_info) - return dict_with_info def make_configuration(): - configuration_dict = get_configuration_from_file("/home/emil/Desktop/frappe-bench/apps/erpnext_autoinstall/configuration/configuration_file.txt") doc = frappe.get_doc("LDAP Settings") - doc.ldap_email_field = configuration_dict['LDAP Email Field'] - doc.base_dn = configuration_dict['Base Distinguished Name (DN)'] - doc.ldap_first_name_field = configuration_dict['LDAP First Name Field'] - doc.ldap_search_string = configuration_dict['LDAP Search String'] - doc.ldap_server_url = configuration_dict['LDAP Server Url'] - doc.default_role = configuration_dict['Default Role on Creation'] - doc.ldap_username_field = configuration_dict['LDAP Username Field'] - doc.organizational_unit = configuration_dict['Organizational Unit for Users'] - doc.password = configuration_dict['Password for Base DN'] + doc.ldap_email_field = os.getenv('LDAP Email Field') + doc.base_dn = os.getenv('Base Distinguished Name (DN)') + doc.ldap_first_name_field = os.getenv('LDAP First Name Field') + doc.ldap_search_string = os.getenv('LDAP Search String') + doc.ldap_server_url = os.getenv('LDAP Server Url') + doc.default_role = os.getenv('Default Role on Creation') + doc.ldap_username_field = os.getenv('LDAP Username Field') + doc.organizational_unit = os.getenv('Organizational Unit for Users') + doc.password = os.getenv('Password for Base DN') + doc.save() + + +def disable_registration(): + doc = frappe.get_doc("Website Settings") + doc.disable_signup = 0 doc.save()