Пример #1
0
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', 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 webnotes.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	try:
		from startup import get_url
		url = get_url()
	except ImportError:
		from webnotes.utils import get_request_site_address
		url = get_request_site_address()

	assignment = """<a href="%s/app.html#!Form/%s/%s">%s: %s</a>""" % (url, 
		doc_type, doc_name,	doc_type, doc_name)
		
	if action=='CLOSE':
		if owner == webnotes.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(webnotes.session.get('user'),
						{}).get('fullname'))
			}
	else:
		arg = {
			'contact': owner,
			'txt': "A new task, %s, has been assigned to you by %s." \
				% (assignment,
				user_info.get(webnotes.session.get('user'), {}).get('fullname')),
			'notify': notify
		}
		
	arg["parenttype"] = "Assignment"
	from utilities.page.messages import messages
	import json
	messages.post(json.dumps(arg))
Пример #2
0
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', 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 webnotes.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	from webnotes.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 == webnotes.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(webnotes.session.get('user'),
						{}).get('fullname'))
			}
	else:
		arg = {
			'contact': owner,
			'txt': "A new task, %s, has been assigned to you by %s." \
				% (assignment,
				user_info.get(webnotes.session.get('user'), {}).get('fullname')),
			'notify': notify
		}
		
	arg["parenttype"] = "Assignment"
	from utilities.page.messages import messages
	import json
	messages.post(json.dumps(arg))
Пример #3
0
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', 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 webnotes.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	assignment = """<a href="#!Form/%s/%s">%s: %s</a>""" % (doc_type, doc_name,
			doc_type, doc_name)
	if action=='CLOSE':
		if owner == webnotes.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(webnotes.session.get('user'),
						{}).get('fullname'))
			}
	else:
		arg = {
			'contact': owner,
			'txt': "A new task, %s, has been assigned to you by %s." \
				% (assignment,
				user_info.get(webnotes.session.get('user'), {}).get('fullname')),
			'notify': notify
		}
		
	arg["parenttype"] = "Assignment"
	from utilities.page.messages import messages
	import json
	messages.post(json.dumps(arg))
Пример #4
0
def add_question(arg):
	args = load_json(arg)
	
	from webnotes.model.doc import Document
	d = Document('Question')
	d.question = args['question']
	d.points = 1
	d.save(1)
	
	if args['suggest']:
		from utilities.page.messages import messages
		for s in args['suggest']:
			if s:
				messages.post(json.dumps({
					'contact': s,
					'txt': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question,
					'notify': 1
				}))
Пример #5
0
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', notify=0):
	"""
		Notify assignee that there is a change in assignment
	"""
	if not (assigned_by and owner and doc_type and doc_name): return

	from webnotes.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	assignment = """<a href="#!Form/%s/%s">%s: %s</a>""" % (doc_type, doc_name,
			doc_type, doc_name)
	if action=='CLOSE':
		if owner == webnotes.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(webnotes.session.get('user'),
						{}).get('fullname'))
			}
	else:
		arg = {
			'contact': owner,
			'txt': "A new task, %s, has been assigned to you by %s." \
				% (assignment,
				user_info.get(webnotes.session.get('user'), {}).get('fullname')),
			'notify': notify
		}
	from utilities.page.messages import messages
	import json
	messages.post(json.dumps(arg))
Пример #6
0
def add_question(arg):
    args = load_json(arg)

    from webnotes.model.doc import Document
    d = Document('Question')
    d.question = args['question']
    d.points = 1
    d.save(1)

    if args['suggest']:
        from utilities.page.messages import messages
        for s in args['suggest']:
            if s:
                messages.post(
                    json.dumps({
                        'contact':
                        s,
                        'txt':
                        'Please help me and answer the question "%s" in the Knowledge Base'
                        % d.question,
                        'notify':
                        1
                    }))
Пример #7
0
	def notify(self, args):
		args = webnotes._dict(args)
		from utilities.page.messages.messages import post
		post({"txt": args.message, "contact": args.message_to, "subject": args.subject,
			"notify": cint(self.doc.follow_via_email)})