frappe/frappe#478 fixed todo and renamed hooks

This commit is contained in:
Rushabh Mehta 2014-04-02 12:08:05 +05:30
parent 0e239c1a3b
commit da2de64e03
5 changed files with 23 additions and 29 deletions

View file

@ -66,7 +66,7 @@ def post(arg=None):
import json
arg = json.loads(arg)
d = frappe.get_doc('Comment')
d = frappe.new_doc('Comment')
d.parenttype = arg.get("parenttype")
d.comment = arg['txt']
d.comment_docname = arg['contact']
@ -87,13 +87,16 @@ def delete(arg=None):
def notify(arg=None):
from frappe.utils import cstr, get_fullname, get_url
frappe.sendmail(\
recipients=[frappe.db.get_value("User", arg["contact"], "email") or arg["contact"]],
sender= frappe.db.get_value("User", frappe.session.user, "email"),
subject="New Message from " + get_fullname(frappe.user.name),
message=frappe.get_template("templates/emails/new_message.html").render({
"from": get_fullname(frappe.user.name),
"message": arg['txt'],
"link": get_url()
})
)
try:
frappe.sendmail(\
recipients=[frappe.db.get_value("User", arg["contact"], "email") or arg["contact"]],
sender= frappe.db.get_value("User", frappe.session.user, "email"),
subject="New Message from " + get_fullname(frappe.user.name),
message=frappe.get_template("templates/emails/new_message.html").render({
"from": get_fullname(frappe.user.name),
"message": arg['txt'],
"link": get_url()
})
)
except frappe.OutgoingEmailError, e:
pass

View file

@ -42,9 +42,9 @@ has_permission:ToDo = frappe.core.doctype.todo.todo.has_permission
# bean
bean_event:User Vote:after_insert = frappe.templates.generators.website_group.clear_cache_on_bean_event
bean_event:Website Route Permission:on_update = frappe.templates.generators.website_group.clear_cache_on_bean_event
doc_event:User Vote:after_insert = frappe.templates.generators.website_group.clear_cache_on_doc_event
doc_event:Website Route Permission:on_update = frappe.templates.generators.website_group.clear_cache_on_doc_event
bean_event:*:on_update = frappe.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event:*:on_cancel = frappe.core.doctype.notification_count.notification_count.clear_doctype_notifications
bean_event:*:on_trash = frappe.core.doctype.notification_count.notification_count.clear_doctype_notifications
doc_event:*:on_update = frappe.core.doctype.notification_count.notification_count.clear_doctype_notifications
doc_event:*:on_cancel = frappe.core.doctype.notification_count.notification_count.clear_doctype_notifications
doc_event:*:on_trash = frappe.core.doctype.notification_count.notification_count.clear_doctype_notifications

View file

@ -396,8 +396,8 @@ class Document(BaseDocument):
def composer(self, *args, **kwargs):
hooks = []
method = f.__name__
for handler in frappe.get_hooks("bean_event:" + self.doctype + ":" + method) \
+ frappe.get_hooks("bean_event:*:" + method):
for handler in frappe.get_hooks("doc_event:" + self.doctype + ":" + method) \
+ frappe.get_hooks("doc_event:*:" + method):
hooks.append(frappe.getattr(handler))
composed = compose(f, *hooks)

View file

@ -138,7 +138,7 @@ def clear_event_cache():
for group in frappe.db.sql_list("""select name from `tabWebsite Group` where group_type='Event'"""):
clear_unit_views(website_group=group)
def clear_cache_on_bean_event(bean, method, *args, **kwargs):
def clear_cache_on_doc_event(bean, method, *args, **kwargs):
clear_cache(path=bean.website_route, website_group=bean.website_group)
def get_pathname(group):

View file

@ -63,16 +63,7 @@ def add(args=None):
# notify
if not args.get("no_notification"):
notify_assignment(d.assigned_by, d.owner, d.reference_type, d.reference_name, action='ASSIGN', description=args.get("description"), notify=args.get('notify'))
# update feeed
try:
from erpnext.home import make_feed
from frappe.utils import get_fullname
make_feed('Assignment', d.reference_type, d.reference_name, frappe.session['user'],
'[%s] Assigned to %s' % (d.priority, get_fullname(d.owner)), '#C78F58')
except ImportError, e:
pass
return get(args)
@frappe.whitelist()