From 7627a051da62e2113ef2ef19e6f368986eb99833 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 5 Aug 2011 17:43:53 +0530 Subject: [PATCH 1/4] restore db fix. Allow dbname with $. Terminal didn't allow $ without escape char. --- cgi-bin/webnotes/model/db_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgi-bin/webnotes/model/db_schema.py b/cgi-bin/webnotes/model/db_schema.py index 0ab2de0b78..e1e02058d2 100644 --- a/cgi-bin/webnotes/model/db_schema.py +++ b/cgi-bin/webnotes/model/db_schema.py @@ -358,7 +358,7 @@ class DbManager: mysql = mysql_path and os.path.join(mysql_path, 'mysql') or 'mysql' try: - ret = os.system("%s -u root -p%s %s < %s"%(mysql, root_password.replace(" ", "\ "), target, source)) + ret = os.system("%s -u root -p%s %s < %s"%(mysql, root_password.replace(" ", "\ "), target.replace("$", "\$"), source)) except Exception,e: raise e From 1db133f81c1900ea795c8677a2ff9ddf1e877289 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 8 Aug 2011 12:55:23 +0530 Subject: [PATCH 2/4] delete all childs from localdb while deleting parent --- js/form.compressed.js | 2 +- js/widgets/form/form.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/form.compressed.js b/js/form.compressed.js index 32c2369634..0965a48d2b 100644 --- a/js/form.compressed.js +++ b/js/form.compressed.js @@ -181,7 +181,7 @@ _f.Frm.prototype.savedoc=function(save_action,onsave,onerr){this.error_in_sectio _f.Frm.prototype.saveupdate=function(){this.save('Update');} _f.Frm.prototype.savesubmit=function(){var answer=confirm("Permanently Submit "+this.docname+"?");if(answer)this.save('Submit');} _f.Frm.prototype.savecancel=function(){var answer=confirm("Permanently Cancel "+this.docname+"?");if(answer)this.save('Cancel');} -_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){delete locals[me.doctype][me.docname];if(page_body.wntoolbar)page_body.wntoolbar.rdocs.remove(me.doctype,me.docname);nav_obj.show_last_open();}})}} +_f.Frm.prototype.savetrash=function(){var me=this;var answer=confirm("Permanently Delete "+this.docname+"? This action cannot be reversed");if(answer){$c('webnotes.model.delete_doc',{dt:this.doctype,dn:this.docname},function(r,rt){if(r.message=='okay'){LocalDB.delete_doc(me.doctype,me.docname);if(page_body.wntoolbar)page_body.wntoolbar.rdocs.remove(me.doctype,me.docname);nav_obj.show_last_open();}})}} _f.Frm.prototype.amend_doc=function(){if(!this.fields_dict['amended_from']){alert('"amended_from" field must be present to do an amendment.');return;} var me=this;var fn=function(newdoc){newdoc.amended_from=me.docname;if(me.fields_dict&&me.fields_dict['amendment_date']) newdoc.amendment_date=dateutil.obj_to_str(new Date());} diff --git a/js/widgets/form/form.js b/js/widgets/form/form.js index 207f45f841..0202f92e03 100644 --- a/js/widgets/form/form.js +++ b/js/widgets/form/form.js @@ -1118,7 +1118,7 @@ _f.Frm.prototype.savetrash = function() { $c('webnotes.model.delete_doc', {dt:this.doctype, dn:this.docname}, function(r,rt) { if(r.message=='okay') { // delete from locals - delete locals[me.doctype][me.docname]; + LocalDB.delete_doc(me.doctype, me.docname); // delete from recent if(page_body.wntoolbar) page_body.wntoolbar.rdocs.remove(me.doctype, me.docname); From d99d252a702e10618732e31f5a311529e466ec39 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 8 Aug 2011 16:28:10 +0530 Subject: [PATCH 3/4] Block unregistered users from resetting password --- cgi-bin/webnotes/profile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index dd135ee1ba..57d938f2a4 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -149,11 +149,14 @@ class Profile: pwd = self.get_random_password() # get profile - profile = webnotes.conn.sql("SELECT name, email, first_name, last_name FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) + profile = webnotes.conn.sql("SELECT name, email, first_name, last_name, registered FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) if not profile: raise Exception, "Profile %s not found" % self.name - + elif not profile[0][4]: + # if an unregistered user tries to reset password + raise Exception, "You cannot reset your password as you have not completed registration. You need to complete registration using the link provided in the email." + # update tab Profile webnotes.conn.sql("UPDATE tabProfile SET password=password(%s) WHERE name=%s", (pwd, profile[0][0])) From ce61112bfd44f5ce74d446b4ae9a8b19349b1488 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 8 Aug 2011 16:52:09 +0530 Subject: [PATCH 4/4] Block a user from resetting password if registration is not complete --- cgi-bin/webnotes/profile.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cgi-bin/webnotes/profile.py b/cgi-bin/webnotes/profile.py index 57d938f2a4..bb9a201da2 100644 --- a/cgi-bin/webnotes/profile.py +++ b/cgi-bin/webnotes/profile.py @@ -149,13 +149,16 @@ class Profile: pwd = self.get_random_password() # get profile - profile = webnotes.conn.sql("SELECT name, email, first_name, last_name, registered FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) - + profile = webnotes.conn.sql("SELECT name, email, first_name, last_name FROM tabProfile WHERE name=%s OR email=%s",(self.name, self.name)) + + profile_cols = [desc[0] for desc in webnotes.conn.sql("DESCRIBE tabProfile")] + if not profile: raise Exception, "Profile %s not found" % self.name - elif not profile[0][4]: + elif 'registered' in profile_cols: + if not webnotes.conn.sql("SELECT registered FROM tabProfile WHERE name=%s", self.name)[0][0]: # if an unregistered user tries to reset password - raise Exception, "You cannot reset your password as you have not completed registration. You need to complete registration using the link provided in the email." + raise Exception, "You cannot reset your password as you have not completed registration. You need to complete registration using the link provided in the email." # update tab Profile webnotes.conn.sql("UPDATE tabProfile SET password=password(%s) WHERE name=%s", (pwd, profile[0][0]))