Пример #1
0
	def test_global_block_list(self):
		webnotes.session.user = "******"
		self._clear_roles()

		from webnotes.profile import add_role
		add_role("*****@*****.**", "Employee")
		add_role("*****@*****.**", "Leave Approver")
				
		application = self.get_application(test_records[3])
		application.doc.leave_approver = "*****@*****.**"
		
		webnotes.conn.set_value("Leave Block List", "_Test Leave Block List", 
			"applies_to_all_departments", 1)
		webnotes.conn.set_value("Employee", "_T-Employee-0002", "department", 
			"_Test Department")
		
		webnotes.session.user = "******"
		application.insert()
		
		webnotes.session.user = "******"
		application.doc.status = "Approved"
		self.assertRaises(LeaveDayBlockedError, application.submit)
		
		webnotes.conn.set_value("Leave Block List", "_Test Leave Block List", 
			"applies_to_all_departments", 0)
    def test_global_block_list(self):
        webnotes.session.user = "******"
        self._clear_roles()

        from webnotes.profile import add_role
        add_role("*****@*****.**", "Employee")
        add_role("*****@*****.**", "Leave Approver")

        application = self.get_application(test_records[3])
        application.doc.leave_approver = "*****@*****.**"

        webnotes.conn.set_value("Leave Block List", "_Test Leave Block List",
                                "applies_to_all_departments", 1)
        webnotes.conn.set_value("Employee", "_T-Employee-0002", "department",
                                "_Test Department")

        webnotes.session.user = "******"
        application.insert()

        webnotes.session.user = "******"
        application.doc.status = "Approved"
        self.assertRaises(LeaveDayBlockedError, application.submit)

        webnotes.conn.set_value("Leave Block List", "_Test Leave Block List",
                                "applies_to_all_departments", 0)
Пример #3
0
	def test_overlap(self):
		self._clear_roles()
		self._clear_applications()
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "Employee")
		add_role("*****@*****.**", "Leave Approver")
		
		webnotes.set_user("*****@*****.**")
		application = self.get_application(test_records[1])
		application.doc.leave_approver = "*****@*****.**"
		application.insert()
		
		application = self.get_application(test_records[1])
		application.doc.leave_approver = "*****@*****.**"
		self.assertRaises(OverlapError, application.insert)
Пример #4
0
	def test_block_list(self):
		import webnotes
		webnotes.conn.set_value("Department", "_Test Department", "leave_block_list", "_Test Leave Block List")
		
		application = self.get_application(test_records[1])
		application.insert()
		application.doc.status = "Approved"
		self.assertRaises(LeaveDayBlockedError, application.submit)
		
		webnotes.session.user = "******"
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "HR User")
		
		application = self.get_application(test_records[1])
		self.assertTrue(application.insert())
Пример #5
0
	def test_overlap(self):
		self._clear_roles()
		self._clear_applications()
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "Employee")
		add_role("*****@*****.**", "Leave Approver")
		
		webnotes.session.user = "******"
		application = self.get_application(test_records[1])
		application.doc.leave_approver = "*****@*****.**"
		application.insert()
		
		application = self.get_application(test_records[1])
		application.doc.leave_approver = "*****@*****.**"
		self.assertRaises(OverlapError, application.insert)
Пример #6
0
    def update_profile(self):
        # add employee role if missing
        if not "Employee" in webnotes.conn.sql_list(
            """select role from tabUserRole
				where parent=%s""",
            self.doc.user_id,
        ):
            from webnotes.profile import add_role

            add_role(self.doc.user_id, "HR User")

        profile_wrapper = webnotes.model_wrapper("Profile", self.doc.user_id)

        # copy details like Fullname, DOB and Image to Profile
        if self.doc.employee_name:
            employee_name = self.doc.employee_name.split(" ")
            if len(employee_name) >= 3:
                profile_wrapper.doc.last_name = " ".join(employee_name[2:])
                profile_wrapper.doc.middle_name = employee_name[1]
            elif len(employee_name) == 2:
                profile_wrapper.doc.last_name = employee_name[1]

            profile_wrapper.doc.first_name = employee_name[0]

        if self.doc.date_of_birth:
            profile_wrapper.doc.birth_date = self.doc.date_of_birth

        if self.doc.gender:
            profile_wrapper.doc.gender = self.doc.gender

        if self.doc.image and self.doc.file_list:
            # add to file list and user_image
            for file_args in self.doc.file_list.split("\n"):
                fname, fid = file_args.split(",")
                if self.doc.image == fname:
                    new_file_args = fname + "," + fid
                    file_list = profile_wrapper.doc.file_list.split("\n")
                    if new_file_args not in file_list:
                        file_list += [new_file_args]
                    profile_wrapper.doc.file_list = "\n".join(file_list)
                    profile_wrapper.doc.user_image = fname
                    break

        profile_wrapper.save()
Пример #7
0
	def test_block_list(self):
		self._clear_roles()
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "HR User")
			
		webnotes.conn.set_value("Department", "_Test Department", 
			"leave_block_list", "_Test Leave Block List")
		
		application = self.get_application(test_records[1])
		application.insert()
		application.doc.status = "Approved"
		self.assertRaises(LeaveDayBlockedError, application.submit)
		
		webnotes.set_user("*****@*****.**")

		# clear other applications
		webnotes.conn.sql("delete from `tabLeave Application`")
		
		application = self.get_application(test_records[1])
		self.assertTrue(application.insert())
Пример #8
0
	def test_block_list(self):
		self._clear_roles()
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "HR User")
			
		webnotes.conn.set_value("Department", "_Test Department", 
			"leave_block_list", "_Test Leave Block List")
		
		application = self.get_application(test_records[1])
		application.insert()
		application.doc.status = "Approved"
		self.assertRaises(LeaveDayBlockedError, application.submit)
		
		webnotes.session.user = "******"

		# clear other applications
		webnotes.conn.sql("delete from `tabLeave Application`")
		
		application = self.get_application(test_records[1])
		self.assertTrue(application.insert())
Пример #9
0
    def update_profile(self):
        # add employee role if missing
        if not "Employee" in webnotes.conn.sql_list(
                """select role from tabUserRole
				where parent=%s""", self.doc.user_id):
            from webnotes.profile import add_role
            add_role(self.doc.user_id, "Employee")

        profile_wrapper = webnotes.bean("Profile", self.doc.user_id)

        # copy details like Fullname, DOB and Image to Profile
        if self.doc.employee_name:
            employee_name = self.doc.employee_name.split(" ")
            if len(employee_name) >= 3:
                profile_wrapper.doc.last_name = " ".join(employee_name[2:])
                profile_wrapper.doc.middle_name = employee_name[1]
            elif len(employee_name) == 2:
                profile_wrapper.doc.last_name = employee_name[1]

            profile_wrapper.doc.first_name = employee_name[0]

        if self.doc.date_of_birth:
            profile_wrapper.doc.birth_date = self.doc.date_of_birth

        if self.doc.gender:
            profile_wrapper.doc.gender = self.doc.gender

        if self.doc.image:
            if not profile_wrapper.doc.user_image == self.doc.image:
                profile_wrapper.doc.user_image = self.doc.image
                try:
                    webnotes.doc({
                        "doctype": "File Data",
                        "file_name": self.doc.image,
                        "attached_to_doctype": "Profile",
                        "attached_to_name": self.doc.user_id
                    }).insert()
                except webnotes.DuplicateEntryError, e:
                    # already exists
                    pass
Пример #10
0
	def update_profile(self):
		# add employee role if missing
		if not "Employee" in webnotes.conn.sql_list("""select role from tabUserRole
				where parent=%s""", self.doc.user_id):
			from webnotes.profile import add_role
			add_role(self.doc.user_id, "HR User")
			
		profile_wrapper = webnotes.bean("Profile", self.doc.user_id)
		
		# copy details like Fullname, DOB and Image to Profile
		if self.doc.employee_name:
			employee_name = self.doc.employee_name.split(" ")
			if len(employee_name) >= 3:
				profile_wrapper.doc.last_name = " ".join(employee_name[2:])
				profile_wrapper.doc.middle_name = employee_name[1]
			elif len(employee_name) == 2:
				profile_wrapper.doc.last_name = employee_name[1]
			
			profile_wrapper.doc.first_name = employee_name[0]
				
		if self.doc.date_of_birth:
			profile_wrapper.doc.birth_date = self.doc.date_of_birth
		
		if self.doc.gender:
			profile_wrapper.doc.gender = self.doc.gender
			
		if self.doc.image:
			if not profile_wrapper.doc.user_image == self.doc.image:
				profile_wrapper.doc.user_image = self.doc.image
				try:
					webnotes.doc({
						"doctype": "File Data",
						"file_name": self.doc.image,
						"attached_to_doctype": "Profile",
						"attached_to_name": self.doc.user_id
					}).insert()
				except webnotes.DuplicateEntryError, e:
					# already exists
					pass
Пример #11
0
	def test_leave_approval(self):
		self._clear_roles()
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "Employee")
		add_role("*****@*****.**", "Leave Approver")
		add_role("*****@*****.**", "Leave Approver")
		
		self._test_leave_approval_basic_case()
		self._test_leave_approval_invalid_leave_approver_insert()
		self._test_leave_approval_invalid_leave_approver_submit()
		self._test_leave_approval_valid_leave_approver_insert()
Пример #12
0
	def test_leave_approval(self):
		self._clear_roles()
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "Employee")
		add_role("*****@*****.**", "Leave Approver")
		add_role("*****@*****.**", "Leave Approver")
		
		self._test_leave_approval_basic_case()
		self._test_leave_approval_invalid_leave_approver_insert()
		self._test_leave_approval_invalid_leave_approver_submit()
		self._test_leave_approval_valid_leave_approver_insert()
Пример #13
0
	def test_leave_approval(self):
		webnotes.session.user = "******"
		self._clear_roles()
		
		from webnotes.profile import add_role
		add_role("*****@*****.**", "Employee")
		add_role("*****@*****.**", "Leave Approver")
		add_role("*****@*****.**", "Leave Approver")
		
		self._test_leave_approval_basic_case_1()
		self._test_leave_approval_basic_case_2()
		self._test_leave_approval_invalid_leave_approver_insert()
		self._test_leave_approval_invalid_leave_approver_submit()
		self._test_leave_approval_valid_leave_approver_insert()
    def test_leave_approval(self):
        webnotes.session.user = "******"
        self._clear_roles()

        from webnotes.profile import add_role
        add_role("*****@*****.**", "Employee")
        add_role("*****@*****.**", "Leave Approver")
        add_role("*****@*****.**", "Leave Approver")

        self._test_leave_approval_basic_case_1()
        self._test_leave_approval_basic_case_2()
        self._test_leave_approval_invalid_leave_approver_insert()
        self._test_leave_approval_invalid_leave_approver_submit()
        self._test_leave_approval_valid_leave_approver_insert()