Esempio n. 1
0
	def loadUsers(self,usertype_id=None,groupname=None,min_grade=None,max_grade=None):
		self.clear()
		self.initialSetup()
		self.users = {}
		if groupname:
			groupmembers = self.proxy.list_members(groupname)
		users = self.proxy.list_users(usertype_id)
		for u,v in users.items():
			
			if groupname and type(groupmembers)==list and not groupmembers.count(v['uid']):
				continue

			# Filter by classyear (aargang)
			if min_grade != None and max_grade != None:
				if v.has_key('firstSchoolYear'):
					classyear = stime.firstyear_to_classyear(int(v['firstSchoolYear']))
					if classyear < min_grade or classyear > max_grade:
						continue

			usertype_id = 2
			if v.has_key('usertype_id'):
				usertype_id = v['usertype_id']
			self._addUser(
				v['uidNumber'],v['uid'],
				v['cn'],usertype_id)
	def update_list(self,usertype=None):
		userlist = self.soapproxy.list_users(usertype)
		self.m_lv_userlist.clear()
		self.userlist = []
		
		for user in userlist.keys():
			name = QString.fromUtf8(userlist[user]['cn'])
			usertype = qApp.translate("UserTypes",userlist[user]['title'])

			# Filter by classyear (aargang)
			min_classyear = self.sbx_firstschoolyear_min.value()
			max_classyear = self.sbx_firstschoolyear_max.value()
			if self.classyear_filter_enabled and userlist[user].has_key('firstSchoolYear'):
				classyear = stime.firstyear_to_classyear(int(userlist[user]['firstSchoolYear']))
				if classyear < min_classyear or classyear > max_classyear:
					continue
					
			# filter by group
			if self.group_filter_enabled and not self.group_members.count(user):
				continue
			
			self.userlist+=[UserListViewItem(self.m_lv_userlist,name,usertype,user)]