added in db.py, bulk unsubscribe optional
This commit is contained in:
parent
359cc30d6c
commit
f3046abd46
3 changed files with 25 additions and 15 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 + """<div style="padding: 7px; border-top: 1px solid #aaa;
|
||||
margin-top: 17px;">
|
||||
<small><a href="%s/?%s">
|
||||
Unsubscribe</a> from this list.</small></div>""" % (get_url(),
|
||||
urllib.urlencode({
|
||||
"cmd": "webnotes.utils.email_lib.bulk.unsubscribe",
|
||||
"email": doc.get(email_field),
|
||||
"type": doctype,
|
||||
"email_field": email_field
|
||||
}))
|
||||
updated = message
|
||||
if add_unsubscribe_link:
|
||||
updated += """<div style="padding: 7px; border-top: 1px solid #aaa;
|
||||
margin-top: 17px;">
|
||||
<small><a href="%s/?%s">
|
||||
Unsubscribe</a> from this list.</small></div>""" % (get_url(),
|
||||
urllib.urlencode({
|
||||
"cmd": "webnotes.utils.email_lib.bulk.unsubscribe",
|
||||
"email": doc.get(email_field),
|
||||
"type": doctype,
|
||||
"email_field": email_field
|
||||
}))
|
||||
|
||||
return updated
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ $.extend(wn, {
|
|||
require: function(url) {
|
||||
if(wn._assets_loaded.indexOf(url)!==-1) return;
|
||||
$.ajax({
|
||||
url: url + "?q=" + Math.floor(Math.random() * 1000),
|
||||
url: url, //+ "?q=" + Math.floor(Math.random() * 1000),
|
||||
async: false,
|
||||
dataType: "text",
|
||||
success: function(data) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue