Example #1
0
	def add_user(self,arg):
		arg = eval(arg)
	
		if(sql("select name from tabProfile where name=%s", arg['email_id'])):
			msgprint('User with this email id already exist.')
			raise Exception
		else:
			p = Document('Profile')
			p.first_name = arg['first_name']
			p.last_name = arg['last_name']
			p.email = arg['email_id']
			p.name = arg['email_id']
			p.user_type = arg['user_type']
			p.enabled = 0	
			p.save(1)
			
			p_obj = get_obj('Profile', p.name)
			p_obj.on_update()
			
			
		# get account id
		cp = Document('Control Panel','Control Panel')
		
		if cint(cp.sync_with_gateway):
			
			arg['account_id'] = cp.account_id
			# add user to gateway
			from webnotes.utils.webservice import FrameworkServer
			fw = FrameworkServer('www.erpnext.com','/','*****@*****.**','password',https=1)
	
			# call remove profile
			ret = fw.runserverobj('Profile Control','Profile Control','add_user',str(arg))
Example #2
0
	def delete_apps(self, app_list=[]):
		from webnotes.utils.webservice import FrameworkServer
		fw = FrameworkServer('www.iwebnotes.com','/','*****@*****.**','password')
		apps = fw.runserverobj('App Control','App Control','delete_apps',app_list)
		if apps['exc']:
			print apps['exc']
		apps = apps['message']
		print apps
		self.delete_app_list(apps)
Example #3
0
	def delete_accounts(self, accounts=[]):
		if not accounts:
			from webnotes.utils.webservice import FrameworkServer
			fw = FrameworkServer('www.iwebnotes.com','/','*****@*****.**','password')
			accounts = fw.runserverobj('App Control','App Control','delete_apps',app_list)
			if accounts['exc']:
				print accounts['exc']
			accounts = accounts['message']
		self.delete_account_list(accounts)
		msg = "Following accounts has been deleted: "+ NEWLINE + cstr(accounts)
		self.send_email(['*****@*****.**', '*****@*****.**'], 'Expired Accounts Deletion', msg)
  def sync_with_gateway(self,pid):
    p = Document('Profile',pid)

    # login to gateway
    from webnotes.utils.webservice import FrameworkServer
    fw = FrameworkServer('www.erpnext.com','/','*****@*****.**','password',https=1)

    account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]
    
    # call add profile
    ret = fw.runserverobj('Profile Control','Profile Control','add_profile_gateway',str([p.first_name, p.middle_name, p.last_name, p.email, p.name, account_id]))
    
    if ret.get('exc'):
      msgprint(ret['exc'])
      raise Exception
Example #5
0
	def update_gateway_picture(self):
		# get file list
		p = Document('Profile',session['user'])
		
		arg = {}
		arg['file_list'] = p.file_list
		arg['name'] = session['user']
		
		# login to gateway
		from webnotes.utils.webservice import FrameworkServer
		fw = FrameworkServer('www.erpnext.com','/','*****@*****.**','password',https=1)

		# call add profile
		ret = fw.runserverobj('Profile Control','Profile Control','update_gateway_picture',str(arg))

		if ret.get('exc'):
			msgprint(ret['exc'])
			raise Exception
Example #6
0
 def connect_gateway(self):
     "login to gateway"
     from webnotes.utils.webservice import FrameworkServer
     fw = FrameworkServer('www.erpnext.com',
                          '/',
                          '*****@*****.**',
                          'password',
                          https=1)
     return fw
Example #7
0
	def update_password(self,pwd):
		sql("update tabProfile set password=password(%s), password_last_updated=%s where name=%s",(pwd,nowdate(),session['user']))
		pwd = sql("select password from tabProfile where name=%s", session['user'])
		pwd = pwd and pwd[0][0] or ''
		
		if pwd:
			# login to gateway
			from webnotes.utils.webservice import FrameworkServer
			fw = FrameworkServer('www.erpnext.com','/','*****@*****.**','password',https=1)

			arg = {}
			arg['password'] = pwd
			arg['name'] = session['user']
			
			# call add profile
			ret = fw.runserverobj('Profile Control','Profile Control','update_gateway_password',str(arg))

			if ret.get('exc'):
				msgprint(ret['exc'])
				raise Exception
  def remove_profile(self, user):
    # delete profile
    webnotes.model.delete_doc('Profile',user)
    
    # Update WN ERP Client Control
    sql("update tabSingles set value = value - 1 where field = 'total_users' and doctype = 'WN ERP Client Control'")

    # login to gateway
    from webnotes.utils.webservice import FrameworkServer
    fw = FrameworkServer('www.erpnext.com','/','*****@*****.**','password',https=1)

    account_id = sql("select value from tabSingles where doctype='Control Panel' and field='account_id'")[0][0]

    # call remove profile
    ret = fw.runserverobj('Profile Control','Profile Control','remove_app_sub',str([user, account_id, session['user']]))
    
    if ret.get('exc'):
      msgprint(ret['exc'])
      raise Exception

    return "User Removed Successfully"
Example #9
0
	def invite_contact(self,arg):
		arg = eval(arg)
		
		cont_det = sql("select * from tabContact where name=%s",(arg['contact']),as_dict=1)
			
		if sql("select name from tabProfile where name=%s",cont_det[0]['email_id']):
			msgprint('You have already invited this contact.')
			raise Exception
		else:
			p = Document('Profile')
			p.name = cont_det[0]['email_id']
			p.first_name = cont_det[0]['first_name']
			p.last_name = cont_det[0]['last_name']
			p.email = cont_det[0]['email_id']
			p.cell_no = cont_det[0]['contact_no']
			p.password = '******'
			p.enabled = 1
			p.user_type = 'Partner';
			p.save(1)
			
			get_obj(doc=p).on_update()
			
			role = []
			if cont_det[0]['contact_type'] == 'Individual':
				role = ['Customer']
			else:
				if cont_det[0]['is_customer']:	role.append('Customer')
				if cont_det[0]['is_supplier']:	role.append('Supplier')
				if cont_det[0]['is_sales_partner']:	role.append('Partner')

			if role:
				prof_nm = p.name
				for i in role:
					r = Document('UserRole')
					r.parent = p.name
					r.role = i
					r.parenttype = 'Profile'
					r.parentfield = 'userroles'
					r.save(1)
				
					if i == 'Customer':
						def_keys = ['from_company','customer_name','customer']
						def_val = cont_det[0]['customer_name']
						self.set_default_val(def_keys,def_val,prof_nm)

					if i == 'Supplier':
						def_keys = ['supplier_name','supplier']
						def_val = cont_det[0]['supplier_name']
						self.set_default_val(def_keys,def_val,prof_nm)

			sql("update tabContact set has_login = '******' where name=%s",cont_det[0]['name'])
			sql("update tabContact set disable_login = '******' where name=%s",cont_det[0]['name'])
			msgprint('User login is created.')
			
			arg = {'name':p.name, 'email_id':p.email, 'first_name':p.first_name, 'last_name':p.last_name, 'user_type':p.user_type}
			
			# get account id
			arg['account_id'] = Document('Control Panel','Control Panel').account_id
			
			# add user to gateway
			from webnotes.utils.webservice import FrameworkServer
			fw = FrameworkServer('www.erpnext.com','/','*****@*****.**','password',https=1)

			# call add_user
			ret = fw.runserverobj('Profile Control','Profile Control','add_user',str(arg))