Beispiel #1
0
    def get_customer_address(self, args):
        args = load_json(args)
        ret = {"customer_address": args["address"], "address_display": get_address_display(args["address"])}
        if args.get("contact"):
            ret.update(map_party_contact_details(args["contact"]))

        return ret
Beispiel #2
0
def delete(arg):
	"""
		delete a question or answer (called from kb toolbar)
	"""
	args = load_json(arg)
	from webnotes.model import delete_doc
	delete_doc(args['dt'], args['dn'])
Beispiel #3
0
 def get_default_supplier_address(self, args):
     args = load_json(args)
     address_text, address_name = self.get_address_text(supplier=args["supplier"])
     ret = {"supplier_address": address_name, "address_display": address_text}
     ret.update(self.get_contact_text(supplier=args["supplier"]))
     ret.update(self.get_supplier_details(args["supplier"]))
     return ret
def post_comment(arg):
	arg = load_json(arg)
	
	from webnotes.model.doc import Document
	d = Document('Comment Widget Record')
	d.comment_doctype = 'My Company'
	d.comment_docname = arg['uid'] # to
	d.owner = webnotes.user.name
	d.comment = arg['comment']
	d.save(1)
	
	if cint(arg['notify']):
		fn = webnotes.conn.sql('select first_name, last_name from tabProfile where name=%s', webnotes.user.name)[0]
		if fn[0] or f[1]:
			fn = cstr(fn[0]) + (fn[0] and ' ' or '') + cstr(fn[1])
		else:
			fn = webnotes.user.name

		from webnotes.utils.email_lib import sendmail
		from setup.doctype.notification_control.notification_control import get_formatted_message
		
		message = '''A new comment has been posted on your page by %s:
		
		<b>Comment:</b> %s
		
		To answer, please login to your erpnext account!
		''' % (fn, arg['comment'])
		
		sendmail([arg['uid']], webnotes.user.name, get_formatted_message('New Comment', message), fn + ' has posted a new comment')
Beispiel #5
0
def change_password(arg):
    """
		Change password
	"""
    arg = load_json(arg)

    if not webnotes.conn.sql(
        "select name from tabProfile where name=%s and password=password(%s)",
        (webnotes.session["user"], arg["old_password"]),
    ):
        webnotes.msgprint("Old password is not correct", raise_exception=1)

    if cint(webnotes.conn.get_value("Control Panel", None, "sync_with_gateway")):
        import server_tools.gateway_utils

        webnotes.msgprint(
            server_tools.gateway_utils.change_password(arg["old_password"], arg["new_password"])["message"]
        )

    from webnotes.utils import nowdate

    webnotes.conn.sql(
        "update tabProfile set password=password(%s), modified=%s where name=%s",
        (arg["new_password"], nowdate(), webnotes.session["user"]),
    )
    webnotes.msgprint("Password Updated")
	def get_supplier_address(self, args):
		args = load_json(args)
		ret = {
			'supplier_address' : args['address'],
			'address_display' : get_address_display(args["address"]),
		}
		ret.update(map_party_contact_details(contact_name=args['contact']))
		return ret
Beispiel #7
0
    def get_customer_address(self, args):
        args = load_json(args)
        address_text, address_name = self.get_address_text(address_name=args["address"])
        ret = {"customer_address": address_name, "address_display": address_text}

        ret.update(self.get_contact_text(contact_name=args["contact"]))

        return ret
def set_user_details(arg=None):
	"updates user details given in argument"
	from webnotes.model.doc import Document
	
	p = Document('Profile', webnotes.user.name)
	p.fields.update(load_json(arg))
	p.save()
	webnotes.msgprint('Updated')
Beispiel #9
0
 def get_contact_number(self, arg):
     "returns mobile number of the contact"
     args = load_json(arg)
     number = sql(
         "select mobile_no, phone from tabContact where name=%s and %s=%s" % ("%s", args["key"], "%s"),
         (args["contact_name"], args["value"]),
     )
     return number and (number[0][0] or number[0][1]) or ""
Beispiel #10
0
 def get_supplier_address(self, args):
     args = load_json(args)
     ret = {
         'supplier_address': args['address'],
         'address_display': get_address_display(args["address"]),
     }
     ret.update(map_party_contact_details(contact_name=args['contact']))
     return ret
Beispiel #11
0
    def get_default_supplier_address(self, args):
        if isinstance(args, basestring):
            args = load_json(args)

        address_name = get_default_address("supplier", args["supplier"])
        ret = {"supplier_address": address_name, "address_display": get_address_display(address_name)}
        ret.update(map_party_contact_details(None, "supplier", args["supplier"]))
        ret.update(self.get_supplier_details(args["supplier"]))
        return ret
Beispiel #12
0
	def get_supplier_address(self, args):
		args = load_json(args)
		address_text, address_name = self.get_address_text(address_name=args['address'])
		ret = {
			'supplier_address' : address_name,
			'address_display' : address_text,
		}
		ret.update(self.get_contact_text(contact_name=args['contact']))
		return ret
Beispiel #13
0
	def get_supplier_address(self, args):
		args = load_json(args)
		address_text, address_name = self.get_address_text(address_name=args['address'])
		ret = {
			'supplier_address' : address_name,
			'address_display' : address_text,
		}
		ret.update(self.get_contact_text(contact_name=args['contact']))
		return ret
Beispiel #14
0
	def get_default_supplier_address(self, args):
		args = load_json(args)
		address_text, address_name = self.get_address_text(supplier=args['supplier'])
		ret = {
			'supplier_address' : address_name,
			'address_display' : address_text,
		}
		ret.update(self.get_contact_text(supplier=args['supplier']))
		ret.update(self.get_supplier_details(args['supplier']))
		return ret
Beispiel #15
0
	def get_default_supplier_address(self, args):
		args = load_json(args)
		address_text, address_name = self.get_address_text(supplier=args['supplier'])
		ret = {
			'supplier_address' : address_name,
			'address_display' : address_text,
		}
		ret.update(self.get_contact_text(supplier=args['supplier']))
		ret.update(self.get_supplier_details(args['supplier']))
		return ret
Beispiel #16
0
	def get_customer_address(self, args):
		args = load_json(args)		
		ret = {
			'customer_address' : args["address"],
			'address_display' : get_address_display(args["address"]),
		}
		if args.get('contact'):
			ret.update(map_party_contact_details(args['contact']))
		
		return ret
    def get_customer_address(self, args):
        args = load_json(args)
        ret = {
            'customer_address': args["address"],
            'address_display': get_address_display(args["address"]),
        }
        if args.get('contact'):
            ret.update(map_party_contact_details(args['contact']))

        return ret
Beispiel #18
0
def add_answer(arg):
    arg = load_json(arg)

    from webnotes.model.doc import Document
    a = Document('Answer')
    a.answer = arg['answer']
    a.question = arg['qid']
    a.points = 1
    a.save(1)

    webnotes.conn.set_value('Question', arg['qid'], 'modified', now())
Beispiel #19
0
def add_answer(arg):
	arg = load_json(arg)
	
	from webnotes.model.doc import Document
	a = Document('Answer')
	a.answer = arg['answer']
	a.question = arg['qid']
	a.points = 1
	a.save(1)
	
	webnotes.conn.set_value('Question', arg['qid'], 'modified', now())
Beispiel #20
0
def vote(arg):
	args = load_json(arg)
	
	res = webnotes.conn.sql("select points, _users_voted from `tab%s` where name=%s" % (args['dt'], '%s'), args['dn'])[0]
	p = cint(res[0])
	p = args['vote']=='up' and p+1 or p-1
	
	# update
	webnotes.conn.sql("update `tab%s` set points=%s, _users_voted=%s where name=%s" % (args['dt'], '%s', '%s', '%s'), \
		(p, cstr(res[1]) + ',' + webnotes.user.name, args['dn']))
	
	return p
Beispiel #21
0
	def get_default_supplier_address(self, args):
		if isinstance(args, basestring):
			args = load_json(args)
			
		address_name = get_default_address("supplier", args["supplier"])
		ret = {
			'supplier_address' : address_name,
			'address_display' : get_address_display(address_name),
		}
		ret.update(map_party_contact_details(None, "supplier", args["supplier"]))
		ret.update(self.get_supplier_details(args['supplier']))
		return ret
Beispiel #22
0
def expand(docs):
	"""
   Expand a doclist sent from the client side. (Internally used by the request handler)
	"""
	from webnotes.utils import load_json

	docs = load_json(docs)
	clist = []
	for d in docs['_vl']:
		doc = xzip(docs['_kl'][d[0]], d);
		clist.append(doc)
	return clist
Beispiel #23
0
def set_user_details(arg=None):
    """
		updates user details given in argument
	"""
    from webnotes.model.doc import Document

    p = Document('Profile', webnotes.user.name)
    arg_dict = load_json(arg)
    if not 'bio' in arg_dict: arg_dict['bio'] = None
    if not 'last_name' in arg_dict: arg_dict['last_name'] = None
    p.fields.update(arg_dict)
    p.save()
    webnotes.msgprint('Updated')
def set_user_details(arg=None):
	"""
		updates user details given in argument
	"""
	from webnotes.model.doc import Document
	
	p = Document('Profile', webnotes.user.name)
	arg_dict = load_json(arg)
	if not 'bio' in arg_dict: arg_dict['bio'] = None
	if not 'last_name' in arg_dict: arg_dict['last_name'] = None
	p.fields.update(arg_dict)
	p.save()
	webnotes.msgprint('Updated')
Beispiel #25
0
def change_password(arg):
	"""
		Change password
	"""
	check_demo()
	arg = load_json(arg)
	
	if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
		webnotes.msgprint('Old password is not correct', raise_exception=1)
	
	from webnotes.utils import nowdate
	webnotes.conn.sql("update tabProfile set password=password(%s), modified=%s where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
	webnotes.msgprint('Password Updated');
	def get_customer_address(self, args):
		args = load_json(args)		
		address_text, address_name = self.get_address_text(address_name=args['address'])
		contact_text, contact_name, contact_email, contact_mobile = self.get_contact_text(contact_name=args['contact'])
		ret = {
			'customer_address' : address_name,
			'contact_person' : contact_name,
			'address_display' : address_text,
			'contact_display' : contact_text,
			'contact_email' : contact_email,
			'contact_mobile' : contact_mobile
		}
		return ret	
	def get_customer_address(self, args):
		args = load_json(args)		
		address_text, address_name = self.get_address_text(address_name=args['address'])
		contact_text, contact_name, contact_email, contact_mobile = self.get_contact_text(contact_name=args['contact'])
		ret = {
			'customer_address' : address_name,
			'contact_person' : contact_name,
			'address_display' : address_text,
			'contact_display' : contact_text,
			'contact_email' : contact_email,
			'contact_mobile' : contact_mobile
		}
		return ret	
Beispiel #28
0
def vote(arg):
    args = load_json(arg)

    res = webnotes.conn.sql(
        "select points, _users_voted from `tab%s` where name=%s" %
        (args['dt'], '%s'), args['dn'])[0]
    p = cint(res[0])
    p = args['vote'] == 'up' and p + 1 or p - 1

    # update
    webnotes.conn.sql("update `tab%s` set points=%s, _users_voted=%s where name=%s" % (args['dt'], '%s', '%s', '%s'), \
     (p, cstr(res[1]) + ',' + webnotes.user.name, args['dn']))

    return p
	def get_default_supplier_address(self, args):
		args = load_json(args)
		address_text, address_name = self.get_address_text(supplier=args['supplier'])
		contact_text, contact_name, contact_email, contact_mobile = self.get_contact_text(supplier=args['supplier'])
		ret = {
			'supplier_address' : address_name,
			'address_display' : address_text,
			'contact_person' : contact_name,
			'contact_display' : contact_text,
			'contact_email' : contact_email,
			'contact_mobile' : contact_mobile						
		}
		ret.update(self.get_supplier_details(args['supplier']))
		return ret
	def get_default_supplier_address(self, args):
		args = load_json(args)
		address_text, address_name = self.get_address_text(supplier=args['supplier'])
		contact_text, contact_name, contact_email, contact_mobile = self.get_contact_text(supplier=args['supplier'])
		ret = {
			'supplier_address' : address_name,
			'address_display' : address_text,
			'contact_person' : contact_name,
			'contact_display' : contact_text,
			'contact_email' : contact_email,
			'contact_mobile' : contact_mobile						
		}
		ret.update(self.get_supplier_details(args['supplier']))
		return ret
Beispiel #31
0
def set_user_details(arg=None):
    """
		updates user details given in argument
	"""
    from webnotes.model.doc import Document

    p = Document("Profile", webnotes.user.name)
    arg_dict = load_json(arg)
    if not "bio" in arg_dict:
        arg_dict["bio"] = None
    if not "last_name" in arg_dict:
        arg_dict["last_name"] = None
    p.fields.update(arg_dict)
    p.save()
    webnotes.msgprint("Updated")
Beispiel #32
0
def change_password(arg):
	"""
		Change password
	"""
	check_demo()
	arg = load_json(arg)
	
	if not webnotes.conn.sql("""select * from `__Auth` where `user`=%s
			and password=password(%s)""",
			(webnotes.session["user"], arg["old_password"])):
		webnotes.msgprint('Old password is not correct', raise_exception=1)

	webnotes.conn.sql("""update `__Auth` set password=password(%s)
		where `user`=%s""", (arg["new_password"], webnotes.session["user"]))

	webnotes.msgprint('Password Updated');
def change_password(arg):
	"""
		Change password
	"""
	arg = load_json(arg)
	
	if cint(webnotes.conn.get_value('Control Panel',None,'sync_with_gateway')):
		import server_tools.gateway_utils
		webnotes.msgprint(server_tools.gateway_utils.change_password(arg['old_password'], arg['new_password'])['message'])
	else:
		if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
			webnotes.msgprint('Old password is not correct', raise_exception=1)
			
		from webnotes.utils import nowdate
		webnotes.conn.sql("update tabProfile set password=password(%s), password_last_updated=%s where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
		webnotes.msgprint('Password Updated');
Beispiel #34
0
def vote(arg):
    args = load_json(arg)

    res = webnotes.conn.sql("select points, _users_voted from `tab%s` where name=%s" % (args["dt"], "%s"), args["dn"])[
        0
    ]
    p = cint(res[0])
    p = args["vote"] == "up" and p + 1 or p - 1

    # update
    webnotes.conn.sql(
        "update `tab%s` set points=%s, _users_voted=%s where name=%s" % (args["dt"], "%s", "%s", "%s"),
        (p, cstr(res[1]) + "," + webnotes.user.name, args["dn"]),
    )

    return p
Beispiel #35
0
def change_password(arg):
    """
		Change password
	"""
    check_demo()
    arg = load_json(arg)

    if not webnotes.conn.sql(
            'select name from tabProfile where name=%s and password=password(%s)',
        (webnotes.session['user'], arg['old_password'])):
        webnotes.msgprint('Old password is not correct', raise_exception=1)

    from webnotes.utils import nowdate
    webnotes.conn.sql(
        "update tabProfile set password=password(%s), modified=%s where name=%s",
        (arg['new_password'], nowdate(), webnotes.session['user']))
    webnotes.msgprint('Password Updated')
Beispiel #36
0
def expand(docs):
	"""
		Expand a doclist sent from the client side. (Internally used by the request handler)
	"""
	def xzip(a,b):
		d = {}
		for i in range(len(a)):
			d[a[i]] = b[i]
		return d

	from webnotes.utils import load_json

	docs = load_json(docs)
	clist = []
	for d in docs['_vl']:
		doc = xzip(docs['_kl'][d[0]], d);
		clist.append(doc)
	return clist
Beispiel #37
0
def expand(docs):
	"""
		Expand a doclist sent from the client side. (Internally used by the request handler)
	"""
	def xzip(a,b):
		d = {}
		for i in range(len(a)):
			d[a[i]] = b[i]
		return d

	from webnotes.utils import load_json

	docs = load_json(docs)
	clist = []
	for d in docs['_vl']:
		doc = xzip(docs['_kl'][d[0]], d);
		clist.append(doc)
	return clist
Beispiel #38
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 core.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
				}))
Beispiel #39
0
def add_question(arg):
	args = load_json(arg)
	
	from webnotes.model.doc import Document
	d = Document('Question')
	d.question = args['question'].title()
	d.points = 1
	d.save(1)
	
	if args['suggest']:
		from my_company.page.my_company.my_company import post_comment
		for s in args['suggest']:
			if s:
				post_comment({
					'uid': s,
					'comment': 'Please help me and answer the question "%s" in the Knowledge Base' % d.question,
					'notify': 1
				})
Beispiel #40
0
def post_comment(arg):
    arg = load_json(arg)

    from webnotes.model.doc import Document
    d = Document('Comment Widget Record')
    d.comment_doctype = 'My Company'
    d.comment_docname = arg['uid']  # to
    d.owner = webnotes.user.name
    d.comment = arg['comment']
    d.save(1)

    if cint(arg.get('notify')):
        fn = webnotes.conn.sql(
            'select first_name, last_name from tabProfile where name=%s',
            webnotes.user.name)[0]
        if fn[0] or f[1]:
            fn = cstr(fn[0]) + (fn[0] and ' ' or '') + cstr(fn[1])
        else:
            fn = webnotes.user.name

        message = '''A new comment has been posted on your page by %s:
		
		<b>Comment:</b> %s
		
		To answer, please login to your erpnext account!

		<a href='https://signin.erpnext.com'>https://signin.erpnext.com</a>
		''' % (fn, arg['comment'])

        from webnotes.model.code import get_obj
        note = get_obj('Notification Control')
        email_msg = note.prepare_message({
            'type': 'New Comment',
            'message': message
        })

        sender = webnotes.user.name != 'Administrator' and webnotes.user.name or '*****@*****.**'

        from webnotes.utils.email_lib import sendmail
        sendmail([arg['uid']], sender, email_msg,
                 fn + ' has posted a new comment')
Beispiel #41
0
def post_comment(arg):
    arg = load_json(arg)

    from webnotes.model.doc import Document

    d = Document("Comment Widget Record")
    d.comment_doctype = "My Company"
    d.comment_docname = arg["uid"]  # to
    d.owner = webnotes.user.name
    d.comment = arg["comment"]
    d.save(1)

    if cint(arg.get("notify")):
        fn = webnotes.conn.sql("select first_name, last_name from tabProfile where name=%s", webnotes.user.name)[0]
        if fn[0] or f[1]:
            fn = cstr(fn[0]) + (fn[0] and " " or "") + cstr(fn[1])
        else:
            fn = webnotes.user.name

        message = """A new comment has been posted on your page by %s:
		
		<b>Comment:</b> %s
		
		To answer, please login to your erpnext account!

		<a href='https://signin.erpnext.com'>https://signin.erpnext.com</a>
		""" % (
            fn,
            arg["comment"],
        )

        from webnotes.model.code import get_obj

        note = get_obj("Notification Control")
        email_msg = note.prepare_message({"type": "New Comment", "message": message})

        sender = webnotes.user.name != "Administrator" and webnotes.user.name or "*****@*****.**"

        from webnotes.utils.email_lib import sendmail

        sendmail([arg["uid"]], sender, email_msg, fn + " has posted a new comment")
Beispiel #42
0
def add_question(arg):
    args = load_json(arg)

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

    if args['suggest']:
        from home.page.my_company.my_company import post_comment
        for s in args['suggest']:
            if s:
                post_comment({
                    'uid':
                    s,
                    'comment':
                    'Please help me and answer the question "%s" in the Knowledge Base'
                    % d.question,
                    'notify':
                    1
                })
Beispiel #43
0
def add_question(arg):
    args = load_json(arg)

    from webnotes.model.doc import Document

    d = Document("Question")
    d.question = args["question"].title()
    d.points = 1
    d.save(1)

    if args["suggest"]:
        from home.page.my_company.my_company import post_comment

        for s in args["suggest"]:
            if s:
                post_comment(
                    {
                        "uid": s,
                        "comment": 'Please help me and answer the question "%s" in the Knowledge Base' % d.question,
                        "notify": 1,
                    }
                )
Beispiel #44
0
def post_comment(arg):
	arg = load_json(arg)
	
	from webnotes.model.doc import Document
	d = Document('Comment Widget Record')
	d.comment_doctype = 'My Company'
	d.comment_docname = arg['uid'] # to
	d.owner = webnotes.user.name
	d.comment = arg['comment']
	d.save(1)
	
	if cint(arg['notify']):
		fn = webnotes.conn.sql('select first_name, last_name from tabProfile where name=%s', webnotes.user.name)[0]
		if fn[0] or f[1]:
			fn = cstr(fn[0]) + (fn[0] and ' ' or '') + cstr(fn[1])
		else:
			fn = webnotes.user.name

		message = '''A new comment has been posted on your page by %s:
		
		<b>Comment:</b> %s
		
		To answer, please login to your erpnext account!

		<a href='https://signin.erpnext.com'>https://signin.erpnext.com</a>
		''' % (fn, arg['comment'])
		
		from webnotes.model.code import get_obj
		note = get_obj('Notification Control')
		email_msg = note.prepare_message({
			'type': 'New Comment',
			'message': message
		})

		sender = webnotes.user.name!='Administrator' and webnotes.user.name or '*****@*****.**'
		
		from webnotes.utils.email_lib import sendmail
		sendmail([arg['uid']], sender, email_msg, fn + ' has posted a new comment')
Beispiel #45
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
                    }))
Beispiel #46
0
def change_password(arg):
    """
		Change password
	"""
    arg = load_json(arg)

    if not webnotes.conn.sql(
            'select name from tabProfile where name=%s and password=password(%s)',
        (webnotes.session['user'], arg['old_password'])):
        webnotes.msgprint('Old password is not correct', raise_exception=1)

    if cint(webnotes.conn.get_value('Control Panel', None,
                                    'sync_with_gateway')):
        import server_tools.gateway_utils
        webnotes.msgprint(
            server_tools.gateway_utils.change_password(
                arg['old_password'], arg['new_password'])['message'])

    from webnotes.utils import nowdate
    webnotes.conn.sql(
        "update tabProfile set password=password(%s), modified=%s where name=%s",
        (arg['new_password'], nowdate(), webnotes.session['user']))
    webnotes.msgprint('Password Updated')
Beispiel #47
0
def update_item(args):
    args = load_json(args)

    webnotes.conn.sql("update `tab%s` set `%s`=%s, modified=%s where name=%s" \
     % (args['dt'], args['fn'], '%s', '%s', '%s'), (args['text'], now(), args['dn']))
Beispiel #48
0
	def get_contact_number(self, arg):
		"returns mobile number of the contact"
		args = load_json(arg)
		number = webnotes.conn.sql("""select mobile_no, phone from tabContact where name=%s and %s=%s""" % 
			('%s', args['key'], '%s'), (args['contact_name'], args['value']))
		return number and (number[0][0] or number[0][1]) or ''
Beispiel #49
0
	def send_form_sms(self, arg):
		"called from client side"
		args = load_json(arg)
		self.send_sms([str(args['number'])], str(args['message']))