[fix] minor update realtime

This commit is contained in:
Rushabh Mehta 2016-02-17 16:32:16 +05:30
parent 1e8f032b14
commit c955e001b4
3 changed files with 16 additions and 7 deletions

View file

@ -170,10 +170,6 @@ def after_request(rollback):
update_comments_in_parent_after_request()
# publish realtime
for args in frappe.local.realtime_log:
frappe.async.emit_via_redis(*args)
return rollback
application = local_manager.make_middleware(application)

View file

@ -12,6 +12,7 @@ import warnings
import datetime
import frappe
import frappe.defaults
import frappe.async
import re
import frappe.model.meta
from frappe.utils import now, get_datetime, cstr
@ -672,6 +673,14 @@ class Database:
"""Commit current transaction. Calls SQL `COMMIT`."""
self.sql("commit")
frappe.local.rollback_observers = []
self.flush_realtime_log()
def flush_realtime_log(self):
for args in frappe.local.realtime_log:
frappe.async.emit_via_redis(*args)
frappe.local.realtime_log = []
def rollback(self):
"""`ROLLBACK` current transaction."""

View file

@ -423,9 +423,13 @@ _f.Frm.prototype.refresh = function(docname) {
_f.Frm.prototype.show_if_needs_refresh = function() {
if(this.doc.__needs_refresh) {
this.dashboard.set_headline_alert(__("This form has been modified after you have loaded it")
+ '<a class="btn btn-xs btn-primary pull-right" onclick="cur_frm.reload_doc()">'
+ __("Refresh") + '</a>', "alert-warning");
if(this.doc.__unsaved) {
this.dashboard.set_headline_alert(__("This form has been modified after you have loaded it")
+ '<a class="btn btn-xs btn-primary pull-right" onclick="cur_frm.reload_doc()">'
+ __("Refresh") + '</a>', "alert-warning");
} else {
this.reload_doc();
}
}
}