diff --git a/webnotes/db.py b/webnotes/db.py index 98df387a41..77233dbcb0 100644 --- a/webnotes/db.py +++ b/webnotes/db.py @@ -508,6 +508,14 @@ class Database: def get_table_columns(self, doctype): return [r[0] for r in self.sql("DESC `tab%s`" % doctype)] + + def add_index(self, doctype, fields, index_name=None): + if not index_name: + index_name = "_".join(fields) + "_index" + if not webnotes.conn.sql("""show index from `tab%s` where Key_name="%s" """ % (doctype, index_name)): + webnotes.conn.commit() + webnotes.conn.sql("""alter table `tab%s` + add index %s(%s)""" % (doctype, index_name, ", ".join(fields))) def close(self): if self._conn: diff --git a/webnotes/utils/email_lib/bulk.py b/webnotes/utils/email_lib/bulk.py index 30bcf02c8c..d9eb0facdd 100644 --- a/webnotes/utils/email_lib/bulk.py +++ b/webnotes/utils/email_lib/bulk.py @@ -4,12 +4,14 @@ from __future__ import unicode_literals import webnotes from webnotes.model.doc import Document -from webnotes.utils import cint +from webnotes.utils import cint, get_url +import urllib class BulkLimitCrossedError(webnotes.ValidationError): pass def send(recipients=None, sender=None, doctype='Profile', email_field='email', - subject='[No Subject]', message='[No Content]', ref_doctype=None, ref_docname=None): + subject='[No Subject]', message='[No Content]', ref_doctype=None, ref_docname=None, + add_unsubscribe_link=True): """send bulk mail if not unsubscribed and within conf.bulk_mail_limit""" import webnotes @@ -31,18 +33,18 @@ def send(recipients=None, sender=None, doctype='Profile', email_field='email', raise_exception=BulkLimitCrossedError) def update_message(doc): - from webnotes.utils import get_url - import urllib - updated = message + """