[minor] fixes for import conf
diff --git a/portal/templates/pages/profile.py b/portal/templates/pages/profile.py
index 8edd830..3d6a86f 100644
--- a/portal/templates/pages/profile.py
+++ b/portal/templates/pages/profile.py
@@ -33,7 +33,7 @@
return _("Name is required")
webnotes.conn.set_value("Profile", webnotes.session.user, "first_name", fullname)
- webnotes.add_cookies["full_name"] = fullname
+ webnotes._response.set_cookie("full_name", fullname)
return _("Updated")
\ No newline at end of file
diff --git a/selling/utils/cart.py b/selling/utils/cart.py
index fc7d062..92d37ea 100644
--- a/selling/utils/cart.py
+++ b/selling/utils/cart.py
@@ -12,8 +12,8 @@
def set_cart_count(quotation=None):
if not quotation:
quotation = _get_cart_quotation()
- webnotes.add_cookies["cart_count"] = cstr(len(quotation.doclist.get(
- {"parentfield": "quotation_details"})) or "")
+ cart_count = cstr(len(quotation.doclist.get({"parentfield": "quotation_details"})))
+ webnotes._response.set_cookie("cart_count", cart_count)
@webnotes.whitelist()
def get_cart_quotation(doclist=None):
@@ -47,7 +47,7 @@
sales_order.ignore_permissions = True
sales_order.insert()
sales_order.submit()
- webnotes.add_cookies["cart_count"] = ""
+ webnotes._response.set_cookie("cart_count", "")
return sales_order.doc.name
diff --git a/setup/doctype/backup_manager/backup_googledrive.py b/setup/doctype/backup_manager/backup_googledrive.py
index ee79518..daf852c 100644
--- a/setup/doctype/backup_manager/backup_googledrive.py
+++ b/setup/doctype/backup_manager/backup_googledrive.py
@@ -115,7 +115,7 @@
from oauth2client.client import OAuth2WebServerFlow
from webnotes import conf
- if not hasattr(conf, "gdrive_client_id"):
+ if not "gdrive_client_id" in conf:
webnotes.msgprint(_("Please set Google Drive access keys in") + " conf.py",
raise_exception=True)
diff --git a/setup/doctype/email_digest/email_digest.py b/setup/doctype/email_digest/email_digest.py
index 2a9acaa..a05bae9 100644
--- a/setup/doctype/email_digest/email_digest.py
+++ b/setup/doctype/email_digest/email_digest.py
@@ -458,7 +458,7 @@
now_date = now_datetime().date()
from webnotes import conf
- if hasattr(conf, "expires_on") and now_date > getdate(conf.expires_on):
+ if "expires_on" in conf and now_date > getdate(conf.expires_on):
# do not send email digests to expired accounts
return
diff --git a/startup/boot.py b/startup/boot.py
index 20887f7..d27c0b7 100644
--- a/startup/boot.py
+++ b/startup/boot.py
@@ -34,7 +34,7 @@
# load subscription info
from webnotes import conf
for key in ['max_users', 'expires_on', 'max_space', 'status', 'commercial_support']:
- if hasattr(conf, key): bootinfo[key] = getattr(conf, key)
+ if key in conf: bootinfo[key] = conf.get(key)
bootinfo['docs'] += webnotes.conn.sql("""select name, default_currency, cost_center
from `tabCompany`""", as_dict=1, update={"doctype":":Company"})
diff --git a/startup/event_handlers.py b/startup/event_handlers.py
index a333857..fc95414 100644
--- a/startup/event_handlers.py
+++ b/startup/event_handlers.py
@@ -35,13 +35,13 @@
set_cart_count()
def on_logout(login_manager):
- webnotes.add_cookies["cart_count"] = ""
+ webnotes._response.set_cookie("cart_count", "")
def check_if_expired():
"""check if account is expired. If expired, do not allow login"""
from webnotes import conf
# check if expires_on is specified
- if not hasattr(conf, 'expires_on'): return
+ if not 'expires_on' in conf: return
# check if expired
from datetime import datetime, date
diff --git a/support/doctype/newsletter/newsletter.py b/support/doctype/newsletter/newsletter.py
index 13ad47a..a6b5aa2 100644
--- a/support/doctype/newsletter/newsletter.py
+++ b/support/doctype/newsletter/newsletter.py
@@ -91,7 +91,7 @@
raise_exception=1)
from webnotes import conf
- if getattr(conf, "status", None) == "Trial":
+ if (conf.get("status") or None) == "Trial":
webnotes.msgprint(_("""Sending newsletters is not allowed for Trial users, \
to prevent abuse of this feature."""), raise_exception=1)
diff --git a/utilities/demo/demo_control_panel.py b/utilities/demo/demo_control_panel.py
index 1da6902..3123f41 100644
--- a/utilities/demo/demo_control_panel.py
+++ b/utilities/demo/demo_control_panel.py
@@ -2,7 +2,7 @@
def on_login(self):
from webnotes.utils import validate_email_add
from webnotes import conf
- if hasattr(conf, "demo_notify_url"):
+ if "demo_notify_url" in conf:
if webnotes.form_dict.lead_email and validate_email_add(webnotes.form_dict.lead_email):
import requests
response = requests.post(conf.demo_notify_url, data={
diff --git a/utilities/demo/make_demo.py b/utilities/demo/make_demo.py
index 8831867..99bc018 100644
--- a/utilities/demo/make_demo.py
+++ b/utilities/demo/make_demo.py
@@ -36,11 +36,15 @@
if reset:
setup()
+ else:
+ webnotes.connect()
+
if simulate:
_simulate()
-
+
def setup():
install()
+ webnotes.connect()
complete_setup()
make_customers_suppliers_contacts()
make_items()
diff --git a/utilities/demo/make_erpnext_demo.py b/utilities/demo/make_erpnext_demo.py
index 6426367..4a72e4b 100644
--- a/utilities/demo/make_erpnext_demo.py
+++ b/utilities/demo/make_erpnext_demo.py
@@ -5,9 +5,9 @@
import webnotes, os
import utilities.demo.make_demo
-def make_demo_app():
+def make_demo_app(site=None):
webnotes.mute_emails = 1
- webnotes.connect()
+ webnotes.connect(site)
utilities.demo.make_demo.make(reset=True, simulate=False)
# setup demo user etc so that the site it up faster, while the data loads
make_demo_user()