def applyChanges(self): proxy = cm.get_proxy_handle() permissions = proxy.list_my_permissions() allow_groupadd = permissions.count("membership.create") allow_groupdel = permissions.count("membership.remove") if self.change_info.has_key("users_by_name"): users_before = self.group_info.pop("users_by_name") users_now = self.change_info.pop("users_by_name") for uid in users_now: if not users_before.count(uid) and allow_groupadd: proxy.groupadd(uid, self.groupname) for uid in users_before: if not users_now.count(uid) and allow_groupdel: proxy.groupdel(uid, self.groupname) description = None if self.change_info.has_key("description"): description = self.change_info["description"] res = 0 if description != None: res = proxy.changegroup(self.groupname, description) if res >= 0: mainwin.get_mainwindow().emitGroupChanged(self.groupname) if self.tbl_serviceoptions.isDirty(): self.tbl_serviceoptions.applyChanges() self.loadGroupData() self.btn_apply.setEnabled(False)
def __init__(self, groupname, parent): QtGui.QWidget.__init__(self, parent) self.change_info = {} self.groupname = groupname self.setupUi(self) self.setupServiceCombo() self.connect(self.btn_apply, QtCore.SIGNAL("clicked()"), self.applyChanges) self.connect(self.tbl_serviceoptions.itemDelegate(), QtCore.SIGNAL("dataChanged"), self.serviceOptionChanged) self.force_close_without_save = False self.permissions = cm.get_proxy_handle().list_my_permissions() # Setup group model self.usermodel = umod.UserModel(self.trv_users) self.modelhelper = pmh.PluggableModelHelper(self.usermodel) self.modelhelper.setView(self.trv_users) for colidx in xrange(self.usermodel.columnCount()): self.modelhelper.setColumnReadOnly(colidx) self.loadGroupData() self.usermodel.setAcceptedMimeTypes(["application/x-skolesysusers-pyobj"]) self.connect(self.btn_add_service, QtCore.SIGNAL("clicked()"), self.addService) self.connect(self.ted_description, QtCore.SIGNAL("textChanged()"), self.descriptionChanged) # User list connections self.trv_users.connectEvent("dropEvent", self.hook_dropOnUserView) self.trv_users.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.connect(self.trv_users, QtCore.SIGNAL("customContextMenuRequested(const QPoint&)"), self.usersContextMenu) # Connect change signals self.connect(mainwin.get_mainwindow(), QtCore.SIGNAL("groupMembershipsChanged"), self.updateUsersView) self.connect(mainwin.get_mainwindow(), QtCore.SIGNAL("permissionsChanged"), self.setupPermissions) self.setupPermissions(self.permissions)
def applyChanges(self): proxy = cm.get_proxy_handle() # Groups permissions = proxy.list_my_permissions() allow_groupadd = permissions.count('membership.create') allow_groupdel = permissions.count('membership.remove') if self.change_info.has_key('groups_by_name'): groups_before = self.user_info.pop('groups_by_name') groups_now = self.change_info.pop('groups_by_name') for groupname in groups_now: if not groups_before.count(groupname) and allow_groupadd: proxy.groupadd(self.username,groupname) for groupname in groups_before: if not groups_now.count(groupname) and allow_groupdel: proxy.groupdel(self.username,groupname) # Standard info givenname,familyname,primarygroup,firstyear = None,None,None,None if self.change_info.has_key('givenName'): givenname = self.change_info['givenName'] if self.change_info.has_key('sn'): familyname = self.change_info['sn'] if self.change_info.has_key('gidNumber'): primarygroup = self.change_info['gidNumber'] if self.change_info.has_key('firstSchoolYear'): firstyear = self.change_info['firstSchoolYear'] res = proxy.changeuser(self.username,givenname,familyname,None,primarygroup,firstyear) print res if res >= 0: mainwin.get_mainwindow().emitUserChanged(self.username) self.loadUserData() self.btn_apply.setEnabled(False)
def __init__(self,username,parent): QtGui.QWidget.__init__(self,parent) ar.ActionRequester.__init__(self) self.change_info = {} self.user_info = {} self.gid_add_list = [] self.gid_rm_list = [] self.force_close_without_save = False self.permissions = cm.get_proxy_handle().list_my_permissions() self.username = username self.setupUi(self) self.groupmodel = gmod.GroupModel(self.trv_groups) self.modelhelper = pmh.PluggableModelHelper(self.groupmodel) self.modelhelper.setView(self.trv_groups) for colidx in xrange(self.groupmodel.columnCount()): self.modelhelper.setColumnReadOnly(colidx) self.loadUserData() self.groupmodel.setAcceptedMimeTypes(['application/x-skolesysgroups-pyobj']) # Connect buttons self.connect(self.btn_apply,QtCore.SIGNAL('clicked()'),self.applyChanges) # Primary group Combobox connections self.connect(self.cmb_primary_group,QtCore.SIGNAL('activated(int)'),self.primaryGroupChanged) # Connect first name , last name line edits self.connect(self.led_firstname,QtCore.SIGNAL('textChanged(const QString&)'),self.firstNameChanged) self.connect(self.led_lastname,QtCore.SIGNAL('textChanged(const QString&)'),self.lastNameChanged) # group list connections self.trv_groups.connectEvent("dropEvent",self.hook_dropOnGroupView) self.trv_groups.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.connect(self.trv_groups,QtCore.SIGNAL("customContextMenuRequested(const QPoint&)"),self.groupsContextMenu) # Connect change signals self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL('userMembershipsChanged'),self.updateGroupsView) # Change password self.connect(self.btn_passwd,QtCore.SIGNAL('clicked()'),self.changePassword) self.tr("teacher","singular") self.tr("student","singular") self.tr("parent","singular") self.tr("other","singular") self.setupPermissions(cm.get_proxy_handle().list_my_permissions()) self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL('permissionsChanged'),self.setupPermissions)
def accept(self): answer = QtGui.QMessageBox.question(self, self.tr('Remove group(s)'), self.tr('Are you sure you want to perform this remove operation?'), QtGui.QMessageBox.Yes,QtGui.QMessageBox.No) if answer==QtGui.QMessageBox.No: return proxy = cm.get_proxy_handle() for group in self.groups: proxy.removegroup(group['groupname'],self.chk_backup_home.isChecked(),self.chk_remove_home.isChecked()) # Signal group deletion mainwin.get_mainwindow().emitGroupDeleted('dummy') QtGui.QDialog.accept(self)
def accept(self): answer = QtGui.QMessageBox.question(self, self.tr('Remove user(s)'), self.tr('Are you sure you want to perform this remove operation?'), QtGui.QMessageBox.Yes,QtGui.QMessageBox.No) if answer==QtGui.QMessageBox.No: return proxy = cm.get_proxy_handle() for user in self.users: proxy.removeuser(user['uid'],self.chk_backup_home.isChecked(),self.chk_remove_home.isChecked()) # Signal user deletion mainwin.get_mainwindow().emitUserDeleted('dummy') QtGui.QDialog.accept(self)
def __init__(self,parent): QtGui.QWidget.__init__(self,parent) self.proxy = cm.get_proxy_handle() self.setupUi(self) self.setupModel() self.setupGroupTypeCombo() self.setupGroupView() self.updateGroupView() self.trv_grouplist.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.connect(self.trv_grouplist,QtCore.SIGNAL("customContextMenuRequested(const QPoint&)"),self.grouplistContextMenu) self.connect(self.trv_grouplist,QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem *,int)"),self.doubleClickEdit) # Recieve notice on altered, deleted or changed groups self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL("groupChanged"),self.updateGroupView) self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL("groupDeleted"),self.updateGroupView) self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL("groupCreated"),self.updateGroupView)
def finish(self): uid = str(self.led_login.text().toUtf8()) givenname = str(self.led_given_name.text().toUtf8()) familyname = str(self.led_family_name.text().toUtf8()) usertype_id,ok = self.cmb_usertype.itemData(self.cmb_usertype.currentIndex()).toInt() firstyear = None if usertype_id == userdef.usertype_as_id('student'): firstyear = self.sbx_first_school_year.value() primarygroup,ok = self.cmb_primary_group.itemData(self.cmb_primary_group.currentIndex()).toInt() passwd = str(self.led_passwd.text().toUtf8()) proxy = cm.get_proxy_handle() res = proxy.createuser(uid,givenname,familyname,passwd,usertype_id,primarygroup,firstyear) if res>=0: import ss_mainwindow as mainwin mainwin.get_mainwindow().emitUserCreated(uid) for groupname in self.groupmodel.groupNames(): proxy.groupadd(uid,groupname) self.accept()
def finish(self): description = str(self.ted_description.toPlainText().toUtf8()) proxy = cm.get_proxy_handle() displayed_name = str(self.led_groupname.text().toUtf8()) grouptype_id,ok = self.cmb_grouptype.itemData(self.cmb_grouptype.currentIndex()).toInt() org_groupname = self.groupname groupname = self.groupname num = 1 while proxy.group_exists(groupname): groupname = '%s%d' % (org_groupname,num) print groupname num += 1 res = proxy.creategroup(groupname,displayed_name,grouptype_id,description) if res>=0: import ss_mainwindow as mainwin mainwin.get_mainwindow().emitGroupCreated(groupname) self.accept()
def __init__(self,parent): QtGui.QWidget.__init__(self,parent) ar.ActionRequester.__init__(self) self.setupUi(self) self.btn_new_user.setIcon(QtGui.QIcon(qt4tools.svg2pixmap(paths.path_to('art/new_user.svg'),72,72))) self.connect(self.btn_new_user,QtCore.SIGNAL("clicked()"),self.execCreateUserWizard) self.connect(self.btn_new_group,QtCore.SIGNAL("clicked()"),self.execCreateGroupWizard) self.connect(self.btn_open_fileman,QtCore.SIGNAL("clicked()"),self.openFileManager) self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL("permissionsChanged"),self.setupPermissions) self.btn_new_group.setIcon(QtGui.QIcon(qt4tools.svg2pixmap(paths.path_to('art/new_group.svg'),72,72))) self.btn_open_fileman.setIcon(QtGui.QIcon(qt4tools.svg2pixmap(paths.path_to('art/stats.svg'),72,72))) self.setupPermissions(cm.get_proxy_handle().list_my_permissions())
def accept(self): progress = QtGui.QProgressDialog(self.tr("Applying membership changes..."),self.tr("Cancel"),0,100) progress.setWindowModality(QtCore.Qt.WindowModal) progress.show() groups = self.groupmodel.groupNames() add_users = self.add_usermodel.userNames() del_users = self.remove_usermodel.userNames() touched_groups = {} touched_users = {} proxy = cm.get_proxy_handle() steps = len(del_users)*len(groups) + len(add_users)*len(groups) step_factor = 100.0/steps step = 0 if accesstools.check_permission('membership.create',False): for uid in add_users: for grp in groups: proxy.groupadd(uid,grp) touched_users[uid] = 1 touched_groups[grp] = 1 progress.setValue(int(step*step_factor)) step+=1 if accesstools.check_permission('membership.remove',False): for uid in del_users: for grp in groups: proxy.groupdel(uid,grp) touched_users[uid] = 1 touched_groups[grp] = 1 progress.setValue(int(step*step_factor)) step+=1 for uid in touched_users.keys(): mainwin.get_mainwindow().emitUserMembershipsChanged(uid) for grp in touched_groups.keys(): mainwin.get_mainwindow().emitGroupMembershipsChanged(grp) progress.setValue(100) QtGui.QDialog.accept(self)
def __init__(self,parent): QtGui.QWidget.__init__(self,parent) self.proxy = cm.get_proxy_handle() self.setupUi(self) self.setupModel() self.setupUserTypeCombo() self.setupUserView() self.setupGroupFilterCombo() self.updateUserView() self.trv_userlist.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.connect(self.trv_userlist,QtCore.SIGNAL("customContextMenuRequested(const QPoint&)"),self.userlistContextMenu) self.connect(self.trv_userlist,QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem *,int)"),self.doubleClickEdit) self.connect(self.sbx_firstschoolyear_min,QtCore.SIGNAL("valueChanged(int)"),self.updateUserView) self.connect(self.sbx_firstschoolyear_max,QtCore.SIGNAL("valueChanged(int)"),self.updateUserView) # Recieve notice on altered, deleted or changed users self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL("userChanged"),self.updateUserView) self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL("userDeleted"),self.updateUserView) self.connect(mainwin.get_mainwindow(),QtCore.SIGNAL("userCreated"),self.updateUserView)
def editGroups(self): import ss_mainwindow as ss_mainwin mimedata = self.groupmodel.generateMimeData(self.trv_grouplist.selectedIndexes()) for g in pickle.loads(mimedata['application/x-skolesysgroups-pyobj']): ss_mainwin.get_mainwindow().editGroup(g['groupname'],g['displayed_name'])
def doubleClickEdit(self,item): import ss_mainwindow as ss_mainwin idx = self.trv_grouplist.currentIndex() mimedata = self.groupmodel.generateMimeData([idx]) for g in pickle.loads(mimedata['application/x-skolesysgroups-pyobj']): ss_mainwin.get_mainwindow().editGroup(g['groupname'],g['displayed_name'])
def doubleClickEdit(self,item): import ss_mainwindow as ss_mainwin idx = self.trv_userlist.currentIndex() mimedata = self.usermodel.generateMimeData([idx]) for u in pickle.loads(mimedata['application/x-skolesysusers-pyobj']): ss_mainwin.get_mainwindow().editUser(u['uid'])
def editUsers(self): import ss_mainwindow as ss_mainwin mimedata = self.usermodel.generateMimeData(self.trv_userlist.selectedIndexes()) for u in pickle.loads(mimedata['application/x-skolesysusers-pyobj']): ss_mainwin.get_mainwindow().editUser(u['uid'])
def openFileManager(self): import ss_mainwindow as mainwin mainwin.get_mainwindow().openFileManager()
options.lang = 'en' if os.environ.has_key('LANG'): options.lang = os.environ['LANG'][:2] app = QtGui.QApplication(sys.argv) if options.lang: trans = QtCore.QTranslator() #print __file__ #appdir = os.path.split(__file__)[0] lang_file = paths.path_to('skolesys-qt4_%s.qm') % (options.lang) print lang_file loadres = trans.load(lang_file) if not loadres: print "Failed to load language file: %s" % lang_file else: app.installTranslator(trans) servermsg.init_server_messages(options.lang) cm.setup_connection('https://10.1.0.1',10033) ui = ss_mainwin.get_mainwindow() if ui: ui.setupViews() ui.show() sys.exit(app.exec_())
def execCreateGroupWizard(self): import ss_mainwindow as mainwin mainwin.get_mainwindow().execCreateGroupWizard()