Merge branch 'master' of github.com:webnotes/wnframework
This commit is contained in:
commit
8cb2d046cb
9 changed files with 38 additions and 25 deletions
|
|
@ -77,7 +77,7 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s
|
|||
d.content = sent_via.get_content(d)
|
||||
|
||||
from webnotes.utils.email_lib.smtp import get_email
|
||||
mail = get_email(d.recipients.split(","), sender=d.sender, subject=d.subject,
|
||||
mail = get_email(d.recipients, sender=d.sender, subject=d.subject,
|
||||
msg=d.content)
|
||||
|
||||
if send_me_a_copy:
|
||||
|
|
|
|||
|
|
@ -199,12 +199,13 @@ _f.Frm.prototype.print_doc = function() {
|
|||
}
|
||||
|
||||
// email the form
|
||||
_f.Frm.prototype.email_doc = function() {
|
||||
_f.Frm.prototype.email_doc = function(message) {
|
||||
new wn.views.CommunicationComposer({
|
||||
doc: this.doc,
|
||||
subject: get_doctype_label(this.meta.name) + ': ' + this.docname,
|
||||
recipients: this.doc.email || this.doc.email_id || this.doc.contact_email,
|
||||
attach_document_print: true
|
||||
attach_document_print: true,
|
||||
message: message
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1139,7 +1140,7 @@ _f.Frm.prototype.call_server = function(method, args, callback) {
|
|||
|
||||
_f.Frm.prototype.get_files = function() {
|
||||
return $.map((cur_frm.doc.file_list || "").split("\n"), function(f) {
|
||||
return f.split(",")[0];
|
||||
return f.split(",")[0] || null;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ wn.views.CommunicationList = Class.extend({
|
|||
this.comm_list[0].find('.comm-content').toggle(true);
|
||||
} else {
|
||||
this.body.remove()
|
||||
$("<div class='alert'>No Communication with this "
|
||||
$("<div class='alert'>No Communication tagged with this "
|
||||
+ this.doc.doctype +" yet.</div>").appendTo(this.wrapper);
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ wn.views.CommunicationList = Class.extend({
|
|||
<div style='margin-bottom: 8px;'>\
|
||||
<button class='btn btn-small' \
|
||||
onclick='cur_frm.communication_view.add_reply()'>\
|
||||
<i class='icon-plus'></i> Add Reply</button></div>\
|
||||
<i class='icon-plus'></i> Add Message</button></div>\
|
||||
</div>")
|
||||
.appendTo(this.parent);
|
||||
|
||||
|
|
@ -103,7 +103,8 @@ wn.views.CommunicationComposer = Class.extend({
|
|||
title: "Add Reply: " + (this.subject || ""),
|
||||
no_submit_on_enter: true,
|
||||
fields: [
|
||||
{label:"To", fieldtype:"Data", reqd: 1, fieldname:"recipients"},
|
||||
{label:"To", fieldtype:"Data", reqd: 1, fieldname:"recipients",
|
||||
description:"Email addresses, separted by commas"},
|
||||
{label:"Subject", fieldtype:"Data", reqd: 1},
|
||||
{label:"Message", fieldtype:"Text Editor", reqd: 1, fieldname:"content"},
|
||||
{label:"Add Reply", fieldtype:"Button"},
|
||||
|
|
@ -147,9 +148,9 @@ wn.views.CommunicationComposer = Class.extend({
|
|||
var attach = $(fields.select_attachments.wrapper);
|
||||
|
||||
var files = cur_frm.get_files();
|
||||
if(files) {
|
||||
if(files.length) {
|
||||
$("<p><b>Add Attachments:</b></p>").appendTo(attach);
|
||||
$.each(cur_frm.get_files(), function(i, f) {
|
||||
$.each(files, function(i, f) {
|
||||
$(repl("<p><input type='checkbox' \
|
||||
data-file-name='%(file)s'> %(file)s</p>", {file:f})).appendTo(attach)
|
||||
});
|
||||
|
|
@ -205,6 +206,7 @@ wn.views.CommunicationComposer = Class.extend({
|
|||
? cur_frm.communication_view.list
|
||||
: [];
|
||||
var signature = wn.boot.profile.email_signature || "";
|
||||
|
||||
if(signature.indexOf("<br>")==-1 && signature.indexOf("<p")==-1
|
||||
&& signature.indexOf("<img")==-1 && signature.indexOf("<div")==-1) {
|
||||
signature = signature.replace(/\n/g, "<br>");
|
||||
|
|
@ -217,7 +219,8 @@ wn.views.CommunicationComposer = Class.extend({
|
|||
+"-----In response to-----<p></p>"
|
||||
+ comm_list[0].content);
|
||||
} else {
|
||||
fields.content.input.set_input("<p></p>" + signature)
|
||||
fields.content.input.set_input((this.message || "")
|
||||
+ "<p></p>" + signature)
|
||||
}
|
||||
},
|
||||
setup_autosuggest: function() {
|
||||
|
|
|
|||
|
|
@ -356,9 +356,6 @@ class Document:
|
|||
tmp = webnotes.conn.sql("""SELECT name FROM `tab%s`
|
||||
WHERE name = %s""" % (dt, '%s'), dn)
|
||||
return tmp and tmp[0][0] or ''# match case
|
||||
|
||||
# Update query
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _update_values(self, issingle, link_list, ignore_fields=0, keep_timestamps=False):
|
||||
if issingle:
|
||||
|
|
@ -568,6 +565,17 @@ class Document:
|
|||
|
||||
return d
|
||||
|
||||
def get_values(self):
|
||||
"""get non-null fields dict withouth standard fields"""
|
||||
from webnotes.model import default_fields
|
||||
ret = {}
|
||||
for key in self.fields:
|
||||
if key not in default_fields and self.fields[key]:
|
||||
ret[key] = self.fields[key]
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def addchild(parent, fieldname, childtype = '', local=0, doclist=None):
|
||||
"""
|
||||
|
||||
|
|
|
|||
|
|
@ -408,7 +408,6 @@ class DocTypeDocList(webnotes.model.doclist.DocList):
|
|||
def get_parent_doclist(self):
|
||||
return webnotes.doclist([self[0]] + self.get({"parent": self[0].name}))
|
||||
|
||||
|
||||
def rename_field(doctype, old_fieldname, new_fieldname, lookup_field=None):
|
||||
"""this function assumes that sync is NOT performed"""
|
||||
import webnotes.model
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ def walk_and_sync(start_path, force=0):
|
|||
if doctype == 'doctype':
|
||||
sync(module_name, name, force)
|
||||
elif doctype in document_type:
|
||||
if reload_doc(module_name, doctype, name):
|
||||
if reload_doc(module_name, doctype, name, force):
|
||||
print module_name + ' | ' + doctype + ' | ' + name
|
||||
|
||||
return modules
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ def get_doc_path(module, doctype, name):
|
|||
dt, dn = scrub_dt_dn(doctype, name)
|
||||
return os.path.join(get_module_path(module), dt, dn)
|
||||
|
||||
def reload_doc(module, dt=None, dn=None):
|
||||
def reload_doc(module, dt=None, dn=None, force=True):
|
||||
from webnotes.modules.import_file import import_files
|
||||
return import_files(module, dt, dn, force=True)
|
||||
return import_files(module, dt, dn, force)
|
||||
|
||||
def export_doc(doctype, name, module=None):
|
||||
"""write out a doc"""
|
||||
|
|
|
|||
|
|
@ -89,23 +89,23 @@ class UpdateDocument:
|
|||
if self.exists:
|
||||
self.delete_existing()
|
||||
self.save()
|
||||
self.update_modified()
|
||||
self.run_on_update()
|
||||
self.update_modified()
|
||||
webnotes.conn.commit()
|
||||
|
||||
# check modified
|
||||
def is_modified(self):
|
||||
try:
|
||||
timestamp = webnotes.conn.sql("select modified from `tab%s` where name=%s" % (self.doc.doctype, '%s'), self.doc.name)
|
||||
timestamp = webnotes.conn.get_value(self.doc.doctype, self.doc.name, "modified")
|
||||
except Exception ,e:
|
||||
if(e.args[0]==1146):
|
||||
return
|
||||
else:
|
||||
raise e
|
||||
|
||||
|
||||
if timestamp:
|
||||
self.exists = 1
|
||||
if str(timestamp[0][0]) == self.doc.modified:
|
||||
if str(timestamp) == self.doc.modified:
|
||||
self.log.append('%s %s, No change' % (self.doc.doctype, self.doc.name))
|
||||
else: return 1
|
||||
|
||||
|
|
@ -116,7 +116,9 @@ class UpdateDocument:
|
|||
|
||||
# update modified timestamp
|
||||
def update_modified(self):
|
||||
webnotes.conn.set(self.doc, 'modified', self.modified)
|
||||
webnotes.conn.sql("""update `tab{doctype}`
|
||||
SET modified=%s WHERE name=%s""".format(doctype=self.doc.doctype),
|
||||
(self.modified, self.doc.name))
|
||||
|
||||
def save(self):
|
||||
# parent
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ roles = []
|
|||
@webnotes.whitelist()
|
||||
def get(arg=None):
|
||||
query = build_query(arg)
|
||||
return compress(webnotes.conn.sql(query, as_dict=1))
|
||||
return compress(webnotes.conn.sql(query, as_dict=1, debug=1))
|
||||
|
||||
def build_query(arg=None):
|
||||
"""
|
||||
|
|
@ -189,7 +189,7 @@ def build_match_conditions(data, conditions):
|
|||
match_conditions = []
|
||||
match = True
|
||||
for d in doctypes[data['doctype']]:
|
||||
if d.doctype == 'DocPerm':
|
||||
if d.doctype == 'DocPerm' and d.parent == data['doctype']:
|
||||
if d.role in roles:
|
||||
if d.match: # role applicable
|
||||
for v in webnotes.user.defaults.get(d.match, ['**No Match**']):
|
||||
|
|
@ -199,7 +199,7 @@ def build_match_conditions(data, conditions):
|
|||
# don't restrict if another read permission at level 0
|
||||
# exists without a match restriction
|
||||
match = False
|
||||
|
||||
|
||||
if match_conditions and match:
|
||||
conditions.append('('+ ' or '.join(match_conditions) +')')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue