[hot] fix socket js

This commit is contained in:
Rushabh Mehta 2017-02-24 16:01:30 +05:30
parent 155cdff99b
commit c0ef741ce8
6 changed files with 24 additions and 15 deletions

View file

@ -2325,7 +2325,7 @@
"Asia/Dushanbe"
]
},
"Tanzania, United Republic of": {
"Tanzania": {
"code": "tz",
"currency": "TZS",
"currency_name": "Tanzanian Shilling",

View file

@ -160,3 +160,4 @@ execute:frappe.db.sql("update tabCommunication set communication_date = creation
frappe.patches.v7_2.fix_email_queue_recipient
frappe.patches.v7_2.update_feedback_request
execute:frappe.rename_doc('Country', 'Macedonia, Republic of', 'Macedonia', ignore_if_exists=True)
execute:frappe.rename_doc('Country', 'Tanzania, United Republic of', 'Tanzania', ignore_if_exists=True)

View file

@ -137,7 +137,8 @@ frappe.socket = {
},
doc_open: function(doctype, docname) {
// notify that the user has opened this doc, if not already notified
if(frappe.socket.last_doc[0]!=doctype && frappe.socket.last_doc[0]!=docname) {
if(!frappe.socket.last_doc
|| (frappe.socket.last_doc[0]!=doctype && frappe.socket.last_doc[0]!=docname)) {
frappe.socket.socket.emit('doc_open', doctype, docname);
}
frappe.socket.last_doc = [doctype, docname];

View file

@ -925,8 +925,8 @@ _f.Frm.prototype.validate_form_action = function(action) {
var allowed_for_workflow = false;
var perms = frappe.perm.get_perm(this.doc.doctype)[0];
// Allow submit, write and create permissions for read only documents that are assigned by
// workflows if the user already have those permissions. This is to allow for users to
// Allow submit, write and create permissions for read only documents that are assigned by
// workflows if the user already have those permissions. This is to allow for users to
// continue through the workflow states and to allow execution of functions like Duplicate.
if (frappe.workflow.is_read_only(this.doctype, this.docname) && (perms["write"] ||
perms["create"] || perms["submit"])) {

View file

@ -75,7 +75,7 @@ def build_context(context):
# provide doc
if context.doc:
context.update(context.doc.as_dict())
context.update(context.doc.website)
context.update(context.doc.get_website_properties())
if hasattr(context.doc, "get_context"):
ret = context.doc.get_context(context)

View file

@ -3,13 +3,10 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import quoted
from frappe.model.document import Document
from frappe.model.naming import append_number_if_name_exists
from frappe.website.utils import cleanup_page_name, get_home_page
from frappe.website.utils import cleanup_page_name
from frappe.website.render import clear_cache
from frappe.modules import get_module_name
from frappe.website.router import get_page_context_from_template, get_page_context
class WebsiteGenerator(Document):
website = frappe._dict(
@ -20,9 +17,16 @@ class WebsiteGenerator(Document):
self.route = None
super(WebsiteGenerator, self).__init__(*args, **kwargs)
def get_website_properties(self, key=None, default=None):
out = getattr(self, '_website', None) or getattr(self, 'website', None) or {}
if key:
return out.get(key, default)
else:
return out
def autoname(self):
if not self.name and self.meta.autoname != "hash":
self.name = self.scrub(self.get(self.website.page_title_field or "title"))
self.name = self.make_route()
def onload(self):
self.get("__onload").update({
@ -38,7 +42,7 @@ class WebsiteGenerator(Document):
self.route = self.route.strip('/.')[:139]
def make_route(self):
return self.scrub(self.get(self.website.page_title_field or "name"))
return self.scrub(self.get(self.get_website_properties('page_title_field', 'title')))
def clear_cache(self):
clear_cache(self.route)
@ -55,8 +59,8 @@ class WebsiteGenerator(Document):
def is_website_published(self):
"""Return true if published in website"""
if self.website.condition_field:
return self.get(self.website.condition_field) and True or False
if self.get_website_properties('condition_field'):
return self.get(self.get_website_properties('condition_field')) and True or False
else:
return True
@ -71,9 +75,12 @@ class WebsiteGenerator(Document):
"controller": get_module_name(self.doctype, self.meta.module),
})
route.update(self.website)
print self.get_website_properties()
route.update(self.get_website_properties())
if not route.page_title:
route.page_title = self.get(self.website.page_title_field or "name")
route.page_title = self.get(self.get_website_properties('page_title'), 'title') \
or self.get('name')
return route