Skip to content

Commit

Permalink
file_with changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AminovE99 committed Aug 22, 2019
1 parent e246b0c commit c26af85
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit c26af85

Please sign in to comment.