@@ -288,7 +288,8 @@ wn.views.CommunicationComposer = Class.extend({ | |||||
? cur_frm.communication_view.list | ? cur_frm.communication_view.list | ||||
: []; | : []; | ||||
var signature = wn.boot.profile.email_signature || ""; | var signature = wn.boot.profile.email_signature || ""; | ||||
var portal_link = this.setup_portal_link(); | |||||
if(!wn.utils.is_html(signature)) { | if(!wn.utils.is_html(signature)) { | ||||
signature = signature.replace(/\n/g, "<br>"); | signature = signature.replace(/\n/g, "<br>"); | ||||
} | } | ||||
@@ -297,17 +298,43 @@ wn.views.CommunicationComposer = Class.extend({ | |||||
this.message = '<p>'+wn._('Dear') +' ' + this.real_name + ",</p>" + (this.message || ""); | this.message = '<p>'+wn._('Dear') +' ' + this.real_name + ",</p>" + (this.message || ""); | ||||
} | } | ||||
var reply = (this.message || "") | |||||
+ "<p></p>" + signature | |||||
+ "<p></p>" + portal_link; | |||||
if(comm_list.length > 0) { | if(comm_list.length > 0) { | ||||
fields.content.set_input((this.message || "") + | |||||
"<p></p>" | |||||
+ signature | |||||
+"<p></p>" | |||||
fields.content.set_input(reply | |||||
+ "<p></p>" | |||||
+"-----"+wn._("In response to")+"-----<p></p>" | +"-----"+wn._("In response to")+"-----<p></p>" | ||||
+ comm_list[0].content); | + comm_list[0].content); | ||||
} else { | } else { | ||||
fields.content.set_input((this.message || "") | |||||
+ "<p></p>" + signature) | |||||
fields.content.set_input(reply); | |||||
} | |||||
}, | |||||
setup_portal_link: function() { | |||||
var me = this; | |||||
var portal_link = ""; | |||||
var show_portal_link = wn.boot.portal_links[this.doc.doctype] && | |||||
!(wn.boot.website_settings && cint(wn.boot.website_settings.disable_signup)); | |||||
if(show_portal_link) { | |||||
var portal_args = wn.boot.portal_links[this.doc.doctype]; | |||||
var valid = true; | |||||
if(portal_args.conditions) { | |||||
$.each(portal_args.conditions, function(k, v) { | |||||
if(me.doc[k] !== v) valid = false; | |||||
}); | |||||
} | |||||
if(valid) { | |||||
// set portal link | |||||
portal_link = repl("%(location)s/%(page)s?name=%(name)s", { | |||||
location: window.location.origin, | |||||
page: portal_args["page"], | |||||
name: encodeURIComponent(this.doc.name) | |||||
}); | |||||
portal_link = '--<br><a href="'+portal_link+'" target="_blank">View this on our website</a>'; | |||||
} | |||||
} | } | ||||
return portal_link; | |||||
}, | }, | ||||
setup_autosuggest: function() { | setup_autosuggest: function() { | ||||
var me = this; | var me = this; | ||||
@@ -62,8 +62,9 @@ login.do_login = function(){ | |||||
window.location.href = "app.html"; | window.location.href = "app.html"; | ||||
} else if(data.message=="No App") { | } else if(data.message=="No App") { | ||||
if(localStorage) { | if(localStorage) { | ||||
window.location.href = localStorage.getItem("last_visited") || "index"; | |||||
var last_visited = localStorage.getItem("last_visited") || "index"; | |||||
localStorage.removeItem("last_visited"); | localStorage.removeItem("last_visited"); | ||||
window.location.href = last_visited; | |||||
} else { | } else { | ||||
window.location.href = "index"; | window.location.href = "index"; | ||||
} | } | ||||
@@ -11,6 +11,7 @@ import webnotes.defaults | |||||
import webnotes.model.doc | import webnotes.model.doc | ||||
import webnotes.widgets.page | import webnotes.widgets.page | ||||
import json | import json | ||||
import webnotes.webutils | |||||
def get_bootinfo(): | def get_bootinfo(): | ||||
"""build and return boot info""" | """build and return boot info""" | ||||
@@ -42,6 +43,9 @@ def get_bootinfo(): | |||||
tabDocType where ifnull(icon,'')!=''""")) | tabDocType where ifnull(icon,'')!=''""")) | ||||
bootinfo.doctype_icons.update(dict(webnotes.conn.sql("""select name, icon from | bootinfo.doctype_icons.update(dict(webnotes.conn.sql("""select name, icon from | ||||
tabPage where ifnull(icon,'')!=''"""))) | tabPage where ifnull(icon,'')!=''"""))) | ||||
# portal links for sending in email | |||||
bootinfo.portal_links = webnotes.webutils.get_portal_links() | |||||
add_home_page(bootinfo, doclist) | add_home_page(bootinfo, doclist) | ||||
add_allowed_pages(bootinfo) | add_allowed_pages(bootinfo) | ||||
@@ -3,7 +3,6 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import os | |||||
import conf | import conf | ||||
import webnotes | import webnotes | ||||
import webnotes.utils | import webnotes.utils | ||||
@@ -113,9 +112,6 @@ def build_html(args): | |||||
return html | return html | ||||
def get_standard_pages(): | |||||
return webnotes.get_config()["web"]["pages"].keys() | |||||
def prepare_args(page_name): | def prepare_args(page_name): | ||||
has_app = True | has_app = True | ||||
@@ -240,4 +236,13 @@ def get_generators(): | |||||
def get_page_settings(): | def get_page_settings(): | ||||
return webnotes.get_config()["web"]["pages"] | return webnotes.get_config()["web"]["pages"] | ||||
def get_portal_links(): | |||||
portal_args = {} | |||||
for page, opts in webnotes.get_config()["web"]["pages"].items(): | |||||
if opts.get("portal"): | |||||
portal_args[opts["portal"]["doctype"]] = { | |||||
"page": page, | |||||
"conditions": opts["portal"].get("conditions") | |||||
} | |||||
return portal_args |