Rushabh Mehta 11 лет назад
Родитель
Сommit
e665ce1907
20 измененных файлов: 116 добавлений и 62 удалений
  1. +1
    -1
      webnotes/__init__.py
  2. +2
    -2
      webnotes/boot.py
  3. +1
    -1
      webnotes/core/doctype/communication/communication.py
  4. +34
    -31
      webnotes/core/doctype/notification_count/notification_count.py
  5. +44
    -0
      webnotes/core/notifications.py
  6. +4
    -4
      webnotes/handler.py
  7. +5
    -4
      webnotes/hooks.txt
  8. +1
    -1
      webnotes/model/bean.py
  9. +1
    -1
      webnotes/modules/patch_handler.py
  10. +1
    -1
      webnotes/public/js/wn/app.js
  11. +1
    -1
      webnotes/public/js/wn/views/grid_report.js
  12. +1
    -1
      webnotes/public/js/wn/views/query_report.js
  13. +1
    -1
      webnotes/public/js/wn/views/reportview.js
  14. +1
    -1
      webnotes/public/js/wn/website/editable.js
  15. +9
    -2
      webnotes/sessions.py
  16. +2
    -5
      webnotes/utils/email_lib/smtp.py
  17. +0
    -1
      webnotes/website/doctype/website_script/templates/pages/wn_web.py
  18. +1
    -1
      webnotes/widgets/query_report.py
  19. +5
    -2
      webnotes/widgets/report_dump.py
  20. +1
    -1
      webnotes/widgets/search.py

+ 1
- 1
webnotes/__init__.py Просмотреть файл

@@ -461,7 +461,7 @@ def get_file_items(path):
else:
return []

def get_method(method_string):
def get_attr(method_string):
modulename = '.'.join(method_string.split('.')[:-1])
methodname = method_string.split('.')[-1]



+ 2
- 2
webnotes/boot.py Просмотреть файл

@@ -39,7 +39,7 @@ def get_bootinfo():
# home page
bootinfo.modules = {}
for get_desktop_icons in hooks.get_desktop_icons:
bootinfo.modules.update(webnotes.get_method(get_desktop_icons)())
bootinfo.modules.update(webnotes.get_attr(get_desktop_icons)())

bootinfo.hidden_modules = webnotes.conn.get_global("hidden_modules")
bootinfo.doctype_icons = dict(webnotes.conn.sql("""select name, icon from
@@ -60,7 +60,7 @@ def get_bootinfo():
bootinfo['docs'] = doclist
for method in hooks.boot_session:
webnotes.get_method(method)(bootinfo)
webnotes.get_attr(method)(bootinfo)
from webnotes.model.utils import compress
bootinfo['docs'] = compress(bootinfo['docs'])


+ 1
- 1
webnotes/core/doctype/communication/communication.py Просмотреть файл

@@ -14,7 +14,7 @@ class DocType():
def update_parent(self):
"""update status of parent Lead or Contact based on who is replying"""
observer = self.get_parent_bean().get_method("on_communication")
observer = self.get_parent_bean().get_attr("on_communication")
if observer:
observer()


+ 34
- 31
webnotes/core/doctype/notification_count/notification_count.py Просмотреть файл

@@ -5,21 +5,14 @@

from __future__ import unicode_literals
import webnotes
try:
from erpnext.startup.open_count import for_doctype, for_module, for_module_doctypes
all_doctypes = for_doctype.keys() + for_module_doctypes.keys()
except ImportError:
for_doctype = {}
for_module = {}
for_module_doctypes = []
all_doctypes = []

class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl

@webnotes.whitelist()
def get():
def get_notifications():
config = get_notification_config()
can_read = webnotes.user.get_can_read()
open_count_doctype = {}
open_count_module = {}
@@ -27,12 +20,11 @@ def get():
notification_count = dict(webnotes.conn.sql("""select for_doctype, open_count
from `tabNotification Count` where owner=%s""", webnotes.session.user))

for d in for_doctype:
for d in config.for_doctype:
if d in can_read:
condition = for_doctype[d]
condition = config.for_doctype[d]
key = condition.keys()[0]

if d in notification_count:
open_count_doctype[d] = notification_count[d]
else:
@@ -44,11 +36,11 @@ def get():
open_count_doctype[d] = result

for m in for_module:
for m in config.for_module:
if m in notification_count:
open_count_module[m] = notification_count[m]
else:
open_count_module[m] = for_module[m]()
open_count_module[m] = webnotes.get_attr(config.for_module[m])()
webnotes.doc({"doctype":"Notification Count", "for_doctype":m,
"open_count":open_count_module[m]}).insert()

@@ -58,33 +50,35 @@ def get():
}

def delete_notification_count_for(doctype):
try:
webnotes.conn.sql("""delete from `tabNotification Count` where for_doctype = %s""", doctype)
except webnotes.SQLError:
pass # during install
webnotes.conn.sql("""delete from `tabNotification Count` where for_doctype = %s""", doctype)

def clear_doctype_notifications(controller, method=None):
if webnotes.flags.in_import:
return
config = get_notification_config()
doctype = controller.doc.doctype
if doctype in all_doctypes:
delete_notification_count_for(for_module_doctypes[doctype] if doctype in \
for_module_doctypes else doctype)

if doctype in config.for_doctype:
delete_notification_count_for(doctype)
return
if doctype in config.for_module_doctypes:
delete_notification_count_for(config.for_module_doctypes[doctype])
def get_notification_info_for_boot():
out = get()
out = get_notifications()

config = get_notification_config()

can_read = webnotes.user.get_can_read()
conditions = {}
module_doctypes = {}
doctype_info = dict(webnotes.conn.sql("""select name, module from tabDocType"""))

try:
from erpnext.startup.open_count import for_doctype
except ImportError:
for_doctype = {}
for d in list(set(can_read + for_doctype.keys())):
if d in for_doctype:
conditions[d] = for_doctype[d]
for d in list(set(can_read + config.for_doctype.keys())):
if d in config.for_doctype:
conditions[d] = config.for_doctype[d]
if d in doctype_info:
module_doctypes.setdefault(doctype_info[d], []).append(d)
@@ -95,7 +89,16 @@ def get_notification_info_for_boot():
})
return out

def get_notification_config():
config = webnotes._dict()
for notification_config in webnotes.get_hooks().notification_config:
nc = webnotes.get_attr(notification_config)()
for key in ("for_doctype", "for_module", "for_module_doctypes"):
config.setdefault(key, {})
config[key].update(nc.get(key, {}))
return config

def on_doctype_update():
if not webnotes.conn.sql("""show index from `tabNotification Count`
where Key_name="notification_count_owner_index" """):


+ 44
- 0
webnotes/core/notifications.py Просмотреть файл

@@ -0,0 +1,44 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import webnotes

def get_notification_config():
return {
"for_module_doctypes": {
"ToDo": "To Do",
"Event": "Calendar",
"Comment": "Messages"
},
"for_module": {
"To Do": "webnotes.core.notifications.get_things_todo",
"Calendar": "webnotes.core.notifications.get_todays_events",
"Messages": "webnotes.core.notifications.get_unread_messages"
}
}

def get_things_todo():
"""Returns a count of incomplete todos"""
incomplete_todos = webnotes.conn.sql("""\
SELECT COUNT(*) FROM `tabToDo`
WHERE IFNULL(checked, 0) = 0
AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user))
return incomplete_todos[0][0]

def get_todays_events():
"""Returns a count of todays events in calendar"""
from webnotes.core.doctype.event.event import get_events
from webnotes.utils import nowdate
today = nowdate()
return len(get_events(today, today))

def get_unread_messages():
"returns unread (docstatus-0 messages for a user)"
return webnotes.conn.sql("""\
SELECT count(*)
FROM `tabComment`
WHERE comment_doctype IN ('My Company', 'Message')
AND comment_docname = %s
AND ifnull(docstatus,0)=0
""", webnotes.user.name)[0][0]

+ 4
- 4
webnotes/handler.py Просмотреть файл

@@ -58,7 +58,7 @@ def uploadfile():
webnotes.conn.rollback()
else:
if webnotes.form_dict.get('method'):
ret = webnotes.get_method(webnotes.form_dict.method)()
ret = webnotes.get_attr(webnotes.form_dict.method)()
except Exception, e:
webnotes.errprint(webnotes.utils.getTraceback())
ret = None
@@ -102,7 +102,7 @@ def handle():

def execute_cmd(cmd):
"""execute a request as python module"""
method = get_method(cmd)
method = get_attr(cmd)

# check if whitelisted
if webnotes.session['user'] == 'Guest':
@@ -139,10 +139,10 @@ def call(fn, args):
newargs[a] = args.get(a)
return fn(**newargs)

def get_method(cmd):
def get_attr(cmd):
"""get method object from cmd"""
if '.' in cmd:
method = webnotes.get_method(cmd)
method = webnotes.get_attr(cmd)
else:
method = globals()[cmd]
webnotes.log("method:" + cmd)


+ 5
- 4
webnotes/hooks.txt Просмотреть файл

@@ -1,4 +1,5 @@
app_include_js assets/js/webnotes.min.js
app_include_css assets/webnotes/css/splash.css
app_include_css assets/css/webnotes.css
get_desktop_icons webnotes.manage.get_desktop_icons
app_include_js assets/js/webnotes.min.js
app_include_css assets/webnotes/css/splash.css
app_include_css assets/css/webnotes.css
get_desktop_icons webnotes.manage.get_desktop_icons
notification_config webnotes.core.notifications.get_notification_config

+ 1
- 1
webnotes/model/bean.py Просмотреть файл

@@ -244,7 +244,7 @@ class Bean:
self.set_doclist(self.controller.doclist)
def get_method(self, method):
def get_attr(self, method):
self.make_controller()
return getattr(self.controller, method, None)



+ 1
- 1
webnotes/modules/patch_handler.py Просмотреть файл

@@ -59,7 +59,7 @@ def execute_patch(patchmodule, method=None, methodargs=None):
if patchmodule.startswith("execute:"):
exec patchmodule.split("execute:")[1] in globals()
else:
webnotes.get_method(patchmodule + ".execute")()
webnotes.get_attr(patchmodule + ".execute")()
update_patch_log(patchmodule)
elif method:
method(**methodargs)


+ 1
- 1
webnotes/public/js/wn/app.js Просмотреть файл

@@ -114,7 +114,7 @@ wn.Application = Class.extend({
refresh_notifications: function() {
if(wn.session_alive) {
return wn.call({
method: "webnotes.core.doctype.notification_count.notification_count.get",
method: "webnotes.core.doctype.notification_count.notification_count.get_notifications",
callback: function(r) {
if(r.message) {
$.extend(wn.boot.notification_info, r.message);


+ 1
- 1
webnotes/public/js/wn/views/grid_report.js Просмотреть файл

@@ -95,7 +95,7 @@ $.extend(wn.report_dump, {
wn.provide("wn.views");
wn.views.GridReport = Class.extend({
init: function(opts) {
wn.require("js/slickgrid.min.js");
wn.require("assets/js/slickgrid.min.js");
this.filter_inputs = {};
this.preset_checks = [];


+ 1
- 1
webnotes/public/js/wn/views/query_report.js Просмотреть файл

@@ -7,7 +7,7 @@ wn.provide("wn.query_reports");
wn.standard_pages["query-report"] = function() {
var wrapper = wn.container.add_page('query-report');

wn.require("js/slickgrid.min.js");
wn.require("assets/js/slickgrid.min.js");

wn.ui.make_app_page({
parent: wrapper,


+ 1
- 1
webnotes/public/js/wn/views/reportview.js Просмотреть файл

@@ -14,7 +14,7 @@ wn.views.ReportViewPage = Class.extend({
return;
};

wn.require("js/slickgrid.min.js");
wn.require("assets/js/slickgrid.min.js");
this.doctype = doctype;
this.docname = docname;


+ 1
- 1
webnotes/public/js/wn/website/editable.js Просмотреть файл

@@ -1,5 +1,5 @@
wn.make_editable = function(editor, doctype, name, fieldname) {
wn.require("js/editor.min.js");
wn.require("assets/js/editor.min.js");
WebPageEditor = bsEditor.extend({
onhide: function(action) {


+ 9
- 2
webnotes/sessions.py Просмотреть файл

@@ -30,6 +30,10 @@ def clear_cache(user=None):
if user:
cache.delete_value("bootinfo:" + user)
# clear notifications
webnotes.conn.sql("""delete from `tabNotification Count` where owner=%s""", user)
if webnotes.session:
if user==webnotes.session.user and webnotes.session.sid:
cache.delete_value("session:" + webnotes.session.sid)
@@ -54,8 +58,9 @@ def clear_sessions(user=None, keep_current=False):

def get():
"""get session boot info"""
from webnotes.core.doctype.notification_count.notification_count import get_notification_info_for_boot

from webnotes.core.doctype.notification_count.notification_count import \
get_notification_info_for_boot, get_notifications
bootinfo = None
if not getattr(webnotes.conf,'disable_session_cache',None):
# check if cache exists
@@ -63,6 +68,8 @@ def get():
if bootinfo:
bootinfo['from_cache'] = 1
bootinfo["notification_info"].update(get_notifications())
if not bootinfo:
if not webnotes.cache().get_stats():
webnotes.msgprint("memcached is not working / stopped. Please start memcached for best results.")


+ 2
- 5
webnotes/utils/email_lib/smtp.py Просмотреть файл

@@ -107,11 +107,8 @@ class EMail:
footer = footer or ""
footer += webnotes.conn.get_value('Control Panel',None,'mail_footer') or ''
try:
import startup
footer += getattr(startup, 'mail_footer', '')
except ImportError:
pass
for f in webnotes.get_hooks().mail_footer:
footer += f
return footer


+ 0
- 1
webnotes/website/doctype/website_script/templates/pages/wn_web.py Просмотреть файл

@@ -7,7 +7,6 @@ import webnotes
no_sitemap = True

def get_context():
"""returns web startup script"""
return {
"javascript": webnotes.conn.get_value('Website Script', None, 'javascript'),
"google_analytics_id": webnotes.conn.get_value("Website Settings", "Website Settings", "google_analytics_id")

+ 1
- 1
webnotes/widgets/query_report.py Просмотреть файл

@@ -67,7 +67,7 @@ def run(report_name, filters=None):
module = webnotes.conn.get_value("DocType", report.ref_doctype, "module")
if report.is_standard=="Yes":
method_name = scrub(module) + ".report." + scrub(report.name) + "." + scrub(report.name) + ".execute"
columns, result = webnotes.get_method(method_name)(filters or {})
columns, result = webnotes.get_attr(method_name)(filters or {})
result = get_filtered_data(report.ref_doctype, columns, result)


+ 5
- 2
webnotes/widgets/report_dump.py Просмотреть файл

@@ -7,8 +7,11 @@ import json
import copy

@webnotes.whitelist()
def get_data(doctypes, last_modified):
from erpnext.startup.report_data_map import data_map
def get_data(doctypes, last_modified):
data_map = {}
for dump_report_map in webnotes.get_hooks().dump_report_map:
data_map.update(webnotes.get_attr(dump_report_map))
import datetime
out = {}


+ 1
- 1
webnotes/widgets/search.py Просмотреть файл

@@ -30,7 +30,7 @@ def search_widget(doctype, txt, query=None, searchfield="name", start=0,
if query and query.split()[0].lower()!="select":
# by method
webnotes.response["values"] = webnotes.get_method(query)(doctype, txt,
webnotes.response["values"] = webnotes.get_attr(query)(doctype, txt,
searchfield, start, page_len, filters)
elif not query and doctype in standard_queries:
# from standard queries


Загрузка…
Отмена
Сохранить