Rename doctype Standard Reply to Email Template (#5444)
* Rename Standard Reply to Email Template * rename occurrences
This commit is contained in:
parent
a5cca5ae73
commit
655e6daee5
12 changed files with 57 additions and 49 deletions
|
|
@ -162,8 +162,8 @@ def get_data():
|
|||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
"name": "Standard Reply",
|
||||
"description": _("Standard replies to common queries.")
|
||||
"name": "Email Template",
|
||||
"description": _("Email Templates for common queries.")
|
||||
},
|
||||
{
|
||||
"type": "doctype",
|
||||
|
|
|
|||
8
frappe/email/doctype/email_template/email_template.js
Normal file
8
frappe/email/doctype/email_template/email_template.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) 2018, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Email Template', {
|
||||
refresh: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
@ -40,6 +40,7 @@
|
|||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
|
|
@ -69,6 +70,7 @@
|
|||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
|
|
@ -100,6 +102,7 @@
|
|||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
|
|
@ -129,6 +132,7 @@
|
|||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
|
|
@ -137,7 +141,7 @@
|
|||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "standard_reply_help",
|
||||
"fieldname": "email_reply_help",
|
||||
"fieldtype": "HTML",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
|
|
@ -146,10 +150,10 @@
|
|||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Standard Reply Help",
|
||||
"label": "Email Reply Help",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "<h4>Standard Reply Example</h4>\n\n<pre>Order Overdue\n\nTransaction {{ name }} has exceeded Due Date. Please take necessary action.\n\nDetails\n\n- Customer: {{ customer }}\n- Amount: {{ grand_total }}\n</pre>\n\n<h4>How to get fieldnames</h4>\n\n<p>The fieldnames you can use in your standard reply are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)</p>\n\n<h4>Templating</h4>\n\n<p>Templates are compiled using the Jinja Templating Langauge. To learn more about Jinja, <a class=\"strong\" href=\"http://jinja.pocoo.org/docs/dev/templates/\">read this documentation.</a></p>\n",
|
||||
"options": "<h4>Email Reply Example</h4>\n\n<pre>Order Overdue\n\nTransaction {{ name }} has exceeded Due Date. Please take necessary action.\n\nDetails\n\n- Customer: {{ customer }}\n- Amount: {{ grand_total }}\n</pre>\n\n<h4>How to get fieldnames</h4>\n\n<p>The fieldnames you can use in your email template are the fields in the document from which you are sending the email. You can find out the fields of any documents via Setup > Customize Form View and selecting the document type (e.g. Sales Invoice)</p>\n\n<h4>Templating</h4>\n\n<p>Templates are compiled using the Jinja Templating Langauge. To learn more about Jinja, <a class=\"strong\" href=\"http://jinja.pocoo.org/docs/dev/templates/\">read this documentation.</a></p>\n",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
|
|
@ -160,6 +164,7 @@
|
|||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
|
|
@ -174,16 +179,15 @@
|
|||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-11-10 08:25:07.708599",
|
||||
"modified": "2018-04-14 16:46:39.792082",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Email",
|
||||
"name": "Standard Reply",
|
||||
"name": "Email Template",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 0,
|
||||
|
|
@ -203,7 +207,6 @@
|
|||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"apply_user_permissions": 0,
|
||||
"cancel": 0,
|
||||
"create": 1,
|
||||
"delete": 1,
|
||||
12
frappe/email/doctype/standard_reply/standard_reply.py → frappe/email/doctype/email_template/email_template.py
Executable file → Normal file
12
frappe/email/doctype/standard_reply/standard_reply.py → frappe/email/doctype/email_template/email_template.py
Executable file → Normal file
|
|
@ -7,16 +7,16 @@ from frappe.model.document import Document
|
|||
from frappe.utils.jinja import validate_template
|
||||
from six import string_types
|
||||
|
||||
class StandardReply(Document):
|
||||
class EmailTemplate(Document):
|
||||
def validate(self):
|
||||
validate_template(self.response)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_standard_reply(template_name, doc):
|
||||
'''Returns the processed HTML of a standard reply with the given doc'''
|
||||
def get_email_template(template_name, doc):
|
||||
'''Returns the processed HTML of a email template with the given doc'''
|
||||
if isinstance(doc, string_types):
|
||||
doc = json.loads(doc)
|
||||
|
||||
standard_reply = frappe.get_doc("Standard Reply", template_name)
|
||||
return {"subject" : frappe.render_template(standard_reply.subject, doc),
|
||||
"message" : frappe.render_template(standard_reply.response, doc)}
|
||||
email_template = frappe.get_doc("Email Template", template_name)
|
||||
return {"subject" : frappe.render_template(email_template.subject, doc),
|
||||
"message" : frappe.render_template(email_template.response, doc)}
|
||||
|
|
@ -2,15 +2,15 @@
|
|||
// rename this file from _test_[name] to test_[name] to activate
|
||||
// and remove above this line
|
||||
|
||||
QUnit.test("test: Standard Reply", function (assert) {
|
||||
QUnit.test("test: Email Template", function (assert) {
|
||||
let done = assert.async();
|
||||
|
||||
// number of asserts
|
||||
assert.expect(1);
|
||||
|
||||
frappe.run_serially([
|
||||
// insert a new Standard Reply
|
||||
() => frappe.tests.make('Standard Reply', [
|
||||
// insert a new Email Template
|
||||
() => frappe.tests.make('Email Template', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
]),
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018, Frappe Technologies and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import unittest
|
||||
|
||||
class TestEmailTemplate(unittest.TestCase):
|
||||
pass
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
// Copyright (c) 2016, Frappe Technologies and contributors
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Standard Reply', {
|
||||
refresh: function(frm) {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
# test_records = frappe.get_test_records('Standard Reply')
|
||||
|
||||
class TestStandardReply(unittest.TestCase):
|
||||
pass
|
||||
|
|
@ -206,3 +206,4 @@ frappe.patches.v10_0.refactor_social_login_keys
|
|||
frappe.patches.v10_0.enable_chat_by_default_within_system_settings
|
||||
frappe.patches.v10_0.remove_custom_field_for_disabled_domain
|
||||
execute:frappe.delete_doc("Page", "chat")
|
||||
frappe.patches.v11_0.rename_standard_reply_to_email_template
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
import frappe
|
||||
from frappe.model.rename_doc import rename_doc
|
||||
|
||||
def execute():
|
||||
if frappe.db.table_exists("Standard Reply") and not frappe.db.table_exists("Email Template"):
|
||||
rename_doc('DocType', 'Standard Reply', 'Email Template')
|
||||
frappe.reload_doc('setup', 'doctype', 'email_template')
|
||||
|
|
@ -48,11 +48,11 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
get_fields: function() {
|
||||
var fields= [
|
||||
{label:__("To"), fieldtype:"Data", reqd: 0, fieldname:"recipients",length:524288},
|
||||
{fieldtype: "Section Break", collapsible: 1, label: __("CC, BCC & Standard Reply")},
|
||||
{fieldtype: "Section Break", collapsible: 1, label: __("CC, BCC & Email Template")},
|
||||
{label:__("CC"), fieldtype:"Data", fieldname:"cc", length:524288},
|
||||
{label:__("BCC"), fieldtype:"Data", fieldname:"bcc", length:524288},
|
||||
{label:__("Standard Reply"), fieldtype:"Link", options:"Standard Reply",
|
||||
fieldname:"standard_reply"},
|
||||
{label:__("Email Template"), fieldtype:"Link", options:"Email Template",
|
||||
fieldname:"email_template"},
|
||||
{fieldtype: "Section Break"},
|
||||
{label:__("Subject"), fieldtype:"Data", reqd: 1,
|
||||
fieldname:"subject", length:524288},
|
||||
|
|
@ -106,7 +106,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
this.setup_email();
|
||||
this.setup_awesomplete();
|
||||
this.setup_last_edited_communication();
|
||||
this.setup_standard_reply();
|
||||
this.setup_email_template();
|
||||
|
||||
this.dialog.fields_dict.recipients.set_value(this.recipients || '');
|
||||
this.dialog.fields_dict.cc.set_value(this.cc || '');
|
||||
|
|
@ -163,14 +163,14 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
}
|
||||
},
|
||||
|
||||
setup_standard_reply: function() {
|
||||
setup_email_template: function() {
|
||||
var me = this;
|
||||
|
||||
this.dialog.fields_dict["standard_reply"].df.onchange = () => {
|
||||
var standard_reply = me.dialog.fields_dict.standard_reply.get_value();
|
||||
this.dialog.fields_dict["email_template"].df.onchange = () => {
|
||||
var email_template = me.dialog.fields_dict.email_template.get_value();
|
||||
|
||||
var prepend_reply = function(reply) {
|
||||
if(me.reply_added===standard_reply) {
|
||||
if(me.reply_added===email_template) {
|
||||
return;
|
||||
}
|
||||
var content_field = me.dialog.fields_dict.content;
|
||||
|
|
@ -191,13 +191,13 @@ frappe.views.CommunicationComposer = Class.extend({
|
|||
subject_field.set_value(reply.subject);
|
||||
}
|
||||
|
||||
me.reply_added = standard_reply;
|
||||
me.reply_added = email_template;
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
method: 'frappe.email.doctype.standard_reply.standard_reply.get_standard_reply',
|
||||
method: 'frappe.email.doctype.email_template.email_template.get_email_template',
|
||||
args: {
|
||||
template_name: standard_reply,
|
||||
template_name: email_template,
|
||||
doc: me.frm.doc,
|
||||
_lang: me.dialog.get_value("language_sel")
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue