예제 #1
0
def notify_assignment(assigned_by,
                      owner,
                      doc_type,
                      doc_name,
                      action='CLOSE',
                      description=None,
                      notify=0):
    """
		Notify assignee that there is a change in assignment
	"""
    if not (assigned_by and owner and doc_type and doc_name): return

    # self assignment / closing - no message
    if assigned_by == owner:
        return

    from frappe.boot import get_fullnames
    user_info = get_fullnames()

    # Search for email address in description -- i.e. assignee
    from frappe.utils import get_url_to_form
    assignment = get_url_to_form(doc_type,
                                 doc_name,
                                 label="%s: %s" % (doc_type, doc_name))

    if action == 'CLOSE':
        if owner == frappe.session.get('user'):
            arg = {
                'contact':
                assigned_by,
                'txt':
                _("The task %s, that you assigned to %s, has been closed.") %
                (assignment, user_info.get(owner, {}).get('fullname'))
            }
        else:
            arg = {
                'contact':
                assigned_by,
                'txt':
                _("The task %s, that you assigned to %s, has been closed by %s."
                  ) %
                (assignment, user_info.get(owner, {}).get('fullname'),
                 user_info.get(frappe.session.get('user'), {}).get('fullname'))
            }
    else:
        arg = {
            'contact':
            owner,
            'txt':
            _("A new task, %s, has been assigned to you by %s. %s") %
            (assignment, user_info.get(frappe.session.get('user'),
                                       {}).get('fullname'), description and
             ("<p>" + _("Description") + ": " + description + "</p>") or ""),
            'notify':
            notify
        }

    arg["parenttype"] = "Assignment"
    from frappe.desk.page.messages import messages
    messages.post(**arg)
예제 #2
0
def notify_assignment(assigned_by,
                      owner,
                      doc_type,
                      doc_name,
                      action='CLOSE',
                      description=None,
                      notify=0):
    """
		Notify assignee that there is a change in assignment
	"""
    if not (assigned_by and owner and doc_type and doc_name): return

    # self assignment / closing - no message
    if assigned_by == owner:
        return

    from frappe.boot import get_fullnames
    user_info = get_fullnames()

    # Search for email address in description -- i.e. assignee
    from frappe.utils import get_link_to_form
    assignment = get_link_to_form(doc_type,
                                  doc_name,
                                  label="%s: %s" % (doc_type, doc_name))
    owner_name = user_info.get(owner, {}).get('fullname')
    user_name = user_info.get(frappe.session.get('user'), {}).get('fullname')
    if action == 'CLOSE':
        if owner == frappe.session.get('user'):
            arg = {
                'contact':
                assigned_by,
                'txt':
                _("The task {0}, that you assigned to {1}, has been closed.").
                format(assignment, owner_name)
            }
        else:
            arg = {
                'contact':
                assigned_by,
                'txt':
                _("The task {0}, that you assigned to {1}, has been closed by {2}."
                  ).format(assignment, owner_name, user_name)
            }
    else:
        description_html = "<p>{0}</p>".format(description)
        arg = {
            'contact':
            owner,
            'txt':
            _("A new task, {0}, has been assigned to you by {1}. {2}").format(
                assignment, user_name, description_html),
            'notify':
            notify
        }

    arg["parenttype"] = "Assignment"

    from frappe.desk.page.chat import chat
    chat.post(**arg)
예제 #3
0
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE',
	description=None, notify=0):
	"""
		Notify assignee that there is a change in assignment
	"""
	if not (assigned_by and owner and doc_type and doc_name): return

	# self assignment / closing - no message
	if assigned_by==owner:
		return

	from frappe.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	from frappe.utils import get_url_to_form
	assignment = get_url_to_form(doc_type, doc_name, label="%s: %s" % (doc_type, doc_name))

	if action=='CLOSE':
		if owner == frappe.session.get('user'):
			arg = {
				'contact': assigned_by,
				'txt': "The task %s, that you assigned to %s, has been \
					closed." % (assignment,
						user_info.get(owner, {}).get('fullname'))
			}
		else:
			arg = {
				'contact': assigned_by,
				'txt': "The task %s, that you assigned to %s, \
					has been closed	by %s." % (assignment,
					user_info.get(owner, {}).get('fullname'),
					user_info.get(frappe.session.get('user'),
						{}).get('fullname'))
			}
	else:
		arg = {
			'contact': owner,
			'txt': "A new task, %s, has been assigned to you by %s. %s" \
				% (assignment,
				user_info.get(frappe.session.get('user'), {}).get('fullname'),
				description and ("<p>Description: " + description + "</p>") or ""),
			'notify': notify
		}

	arg["parenttype"] = "Assignment"
	from frappe.core.page.messages import messages
	import json
	messages.post(json.dumps(arg))
예제 #4
0
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE',
	description=None, notify=0):
	"""
		Notify assignee that there is a change in assignment
	"""
	if not (assigned_by and owner and doc_type and doc_name): return

	# self assignment / closing - no message
	if assigned_by==owner:
		return

	from frappe.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	from frappe.utils import get_link_to_form
	assignment = get_link_to_form(doc_type, doc_name, label="%s: %s" % (doc_type, doc_name))
	owner_name = user_info.get(owner, {}).get('fullname')
	user_name = user_info.get(frappe.session.get('user'), {}).get('fullname')
	if action=='CLOSE':
		if owner == frappe.session.get('user'):
			arg = {
				'contact': assigned_by,
				'txt': _("The task {0}, that you assigned to {1}, has been closed.").format(assignment,
						owner_name)
			}
		else:
			arg = {
				'contact': assigned_by,
				'txt': _("The task {0}, that you assigned to {1}, has been closed by {2}.").format(assignment,
					owner_name, user_name)
			}
	else:
		description_html = "<p>{0}</p>".format(description)
		arg = {
			'contact': owner,
			'txt': _("A new task, {0}, has been assigned to you by {1}. {2}").format(assignment,
				user_name, description_html),
			'notify': notify
		}

	arg["parenttype"] = "Assignment"

	from frappe.desk.page.chat import chat
	chat.post(**arg)
예제 #5
0
def get_boot_user_info():
    # used for listing the people in Comment mentions
    from frappe.boot import get_fullnames
    return get_fullnames()