Fixed Dropbox, Scheduler, 3to4 migration
diff --git a/erpnext/hooks.txt b/erpnext/hooks.txt
index b6969dd..6793890 100644
--- a/erpnext/hooks.txt
+++ b/erpnext/hooks.txt
@@ -39,18 +39,18 @@
 
 #### Frequently
 
-scheduler_event = all:erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails
-scheduler_event = all:erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications
-scheduler_event = all:erpnext.selling.doctype.lead.get_leads.get_leads
+scheduler_event:all = erpnext.support.doctype.support_ticket.get_support_mails.get_support_mails
+scheduler_event:all = erpnext.hr.doctype.job_applicant.get_job_applications.get_job_applications
+scheduler_event:all = erpnext.selling.doctype.lead.get_leads.get_leads
 
 #### Daily
 
-scheduler_event = daily:erpnext.accounts.doctype.sales_invoice.sales_invoice.manage_recurring_invoices
-scheduler_event = daily:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_daily
-scheduler_event = daily:erpnext.stock.utils.reorder_item
-scheduler_event = daily:erpnext.setup.doctype.email_digest.email_digest.send
-scheduler_event = daily:support.doctype.support_ticket.support_ticket.auto_close_tickets
+scheduler_event:daily = erpnext.accounts.doctype.sales_invoice.sales_invoice.manage_recurring_invoices
+scheduler_event:daily_long = erpnext.setup.doctype.backup_manager.backup_manager.take_backups_daily
+scheduler_event:daily = erpnext.stock.utils.reorder_item
+scheduler_event:daily = erpnext.setup.doctype.email_digest.email_digest.send
+scheduler_event:daily = erpnext.support.doctype.support_ticket.support_ticket.auto_close_tickets
 
 #### Weekly
 
-scheduler_event = weekly:erpnext.setup.doctype.backup_manager.backup_manager.take_backups_weekly
+scheduler_event:weekly_long = erpnext.setup.doctype.backup_manager.backup_manager.take_backups_weekly
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 824fe60..fec9bb0 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -1,3 +1,4 @@
+erpnext.patches.4_0.validate_v3_patch
 erpnext.patches.4_0.update_user_properties
 erpnext.patches.4_0.move_warehouse_user_to_restrictions
 erpnext.patches.4_0.new_permissions
diff --git a/erpnext/patches/4_0/validate_v3_patch.py b/erpnext/patches/4_0/validate_v3_patch.py
new file mode 100644
index 0000000..5041a81
--- /dev/null
+++ b/erpnext/patches/4_0/validate_v3_patch.py
@@ -0,0 +1,12 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	from frappe.modules.patch_handler import executed
+	last_v3_patch = 'patches.1401.fix_planned_qty'
+	if not executed(last_v3_patch):
+		raise Exception, "site not ready to migrate to version 4"
+	
\ No newline at end of file
diff --git a/erpnext/setup/doctype/backup_manager/backup_dropbox.py b/erpnext/setup/doctype/backup_manager/backup_dropbox.py
index 212efbc..91cb442 100644
--- a/erpnext/setup/doctype/backup_manager/backup_dropbox.py
+++ b/erpnext/setup/doctype/backup_manager/backup_dropbox.py
@@ -21,7 +21,7 @@
 	sess = get_dropbox_session()
 	request_token = sess.obtain_request_token()
 	return_address = get_request_site_address(True) \
-		+ "?cmd=setup.doctype.backup_manager.backup_dropbox.dropbox_callback"
+		+ "?cmd=erpnext.setup.doctype.backup_manager.backup_dropbox.dropbox_callback"
 
 	url = sess.build_authorize_url(request_token, return_address)
 
@@ -71,13 +71,12 @@
 
 def backup_to_dropbox():
 	from dropbox import client, session
-	from conf import dropbox_access_key, dropbox_secret_key
 	from frappe.utils.backups import new_backup
 	from frappe.utils import get_files_path, get_backups_path
 	if not frappe.db:
 		frappe.connect()
 
-	sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
+	sess = session.DropboxSession(frappe.conf.dropbox_access_key, frappe.conf.dropbox_secret_key, "app_folder")
 
 	sess.set_token(frappe.db.get_value("Backup Manager", None, "dropbox_access_key"),
 		frappe.db.get_value("Backup Manager", None, "dropbox_access_secret"))
@@ -120,13 +119,11 @@
 		from dropbox import session
 	except:
 		frappe.msgprint(_("Please install dropbox python module"), raise_exception=1)
-		
-	try:
-		from conf import dropbox_access_key, dropbox_secret_key
-	except ImportError:
-		frappe.msgprint(_("Please set Dropbox access keys in") + " conf.py", 
-		raise_exception=True)
-	sess = session.DropboxSession(dropbox_access_key, dropbox_secret_key, "app_folder")
+	
+	if not (frappe.conf.dropbox_access_key or frappe.conf.dropbox_secret_key):
+		frappe.throw(_("Please set Dropbox access keys in your site config"))
+
+	sess = session.DropboxSession(frappe.conf.dropbox_access_key, frappe.conf.dropbox_secret_key, "app_folder")
 	return sess
 
 def upload_file_to_dropbox(filename, folder, dropbox_client):
diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index 0cdbcb9..00b2362 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -314,8 +314,10 @@
 			return 0, "<p>Calendar Events</p>"
 	
 	def get_todo_list(self, user_id):
-		from frappe.core.page.todo.todo import get
-		todo_list = get()
+		todo_list = frappe.db.sql("""select *
+			from `tabToDo` where (owner=%s or assigned_by=%s)
+			order by field(priority, 'High', 'Medium', 'Low') asc, date asc""",
+			(user_id, user_id), as_dict=True)
 		
 		html = ""
 		if todo_list:
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.js b/erpnext/setup/page/setup_wizard/setup_wizard.js
index 6e28bbb..ad9aefa 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.js
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.js
@@ -30,7 +30,7 @@
 									frappe.app.logout();
 								}, 2000);
 							} else {
-								window.location = "app.html";
+								window.location = "/desk";
 							}
 						}, 2000);
 					}