Procházet zdrojové kódy

[feature] [customer login] send links in email for portal access of Sales Order, Sales Invoice, Delivery Note and Suppor Ticket

version-14
Anand Doshi před 12 roky
rodič
revize
2f5bc8b73f
4 změnil soubory, kde provedl 50 přidání a 13 odebrání
  1. +34
    -7
      public/js/wn/views/communication.js
  2. +2
    -1
      templates/js/login.js
  3. +4
    -0
      webnotes/boot.py
  4. +10
    -5
      webnotes/webutils.py

+ 34
- 7
public/js/wn/views/communication.js Zobrazit soubor

@@ -288,7 +288,8 @@ wn.views.CommunicationComposer = Class.extend({
? cur_frm.communication_view.list
: [];
var signature = wn.boot.profile.email_signature || "";

var portal_link = this.setup_portal_link();
if(!wn.utils.is_html(signature)) {
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 || "");
}
var reply = (this.message || "")
+ "<p></p>" + signature
+ "<p></p>" + portal_link;
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>"
+ comm_list[0].content);
} 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() {
var me = this;


+ 2
- 1
templates/js/login.js Zobrazit soubor

@@ -62,8 +62,9 @@ login.do_login = function(){
window.location.href = "app.html";
} else if(data.message=="No App") {
if(localStorage) {
window.location.href = localStorage.getItem("last_visited") || "index";
var last_visited = localStorage.getItem("last_visited") || "index";
localStorage.removeItem("last_visited");
window.location.href = last_visited;
} else {
window.location.href = "index";
}


+ 4
- 0
webnotes/boot.py Zobrazit soubor

@@ -11,6 +11,7 @@ import webnotes.defaults
import webnotes.model.doc
import webnotes.widgets.page
import json
import webnotes.webutils

def get_bootinfo():
"""build and return boot info"""
@@ -42,6 +43,9 @@ def get_bootinfo():
tabDocType where ifnull(icon,'')!=''"""))
bootinfo.doctype_icons.update(dict(webnotes.conn.sql("""select name, icon from
tabPage where ifnull(icon,'')!=''""")))
# portal links for sending in email
bootinfo.portal_links = webnotes.webutils.get_portal_links()

add_home_page(bootinfo, doclist)
add_allowed_pages(bootinfo)


+ 10
- 5
webnotes/webutils.py Zobrazit soubor

@@ -3,7 +3,6 @@

from __future__ import unicode_literals

import os
import conf
import webnotes
import webnotes.utils
@@ -113,9 +112,6 @@ def build_html(args):
return html
def get_standard_pages():
return webnotes.get_config()["web"]["pages"].keys()
def prepare_args(page_name):

has_app = True
@@ -240,4 +236,13 @@ def get_generators():
def get_page_settings():
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

Načítá se…
Zrušit
Uložit