Exemple #1
0
Fichier : app.py Projet : robol/lum
    def group_properties(self, menu_item = None):
        """View selected group properties, such as members and
        gidNumber"""

        if not self.__check_connection():
            return None

        group, t_iter = self.__get_selected_group()
        if t_iter is None:
            show_info_dialog(_("Select a group to view its properties"))

        # Get group_members, that are the only interesting property
        # we can get from ldap
        group_members = self.__connection.get_members(group)

        # Get gid
        gid = self.__group_store.get_gid(t_iter)

        # Show info dialog
        dialog_text =  _("<b>Name:</b> %s\n") % group
        dialog_text += "<b>Gid</b>: %s\n" % gid
        if len(group_members) > 0:
            dialog_text += _("<b>Members</b>: ")
            dialog_text += ", ".join(group_members)
        else:
            dialog_text += _("This group is empty.")

        # Show info dialog.
        show_info_dialog(dialog_text)
Exemple #2
0
Fichier : app.py Projet : robol/lum
    def delete_group(self, menu_item = None):
        """Delete the group selected in the group_treeview"""
        if not self.__check_connection():
            return None

        group, t_iter = self.__get_selected_group()

        # If nothing is selected we can return and do nothing.
        # We should only notify the user that what he would like
        # to do can not be done now.
        if t_iter is None:
            show_info_dialog(_("Select a group before asking for its deletion."))
            return

        # Users tend to delete many things they do not want to delete
        if len(self.__connection.get_members(group)) == 0:
            question = _("Really delete group <b>%s</b>?") % group
        else:
            question = _("Really delete the non empty group <b>%s</b>?" +
                         " This will lead to integrity problems.") % group
        if not ask_question(question):
            return

        # Finally we delete the group
        try:
            self.__connection.delete_group(group)
        except LumInsufficientPermissionsError:
            show_error_dialog(_("Insufficient permissions to delete group"))
            return None

        # and delete the group from the treeview
        self.__group_store.remove(t_iter)

        # Finally show the successful operation in the statusbar
        self.statusbar_update(_("Group %s successfully deleted.") % group)
Exemple #3
0
Fichier : app.py Projet : robol/lum
    def edit_user(self, menu_item = None):
        """Edit selected user"""
        usermodel, t_iter = self.__get_selected_user()
        if t_iter is None: 
            show_info_dialog(_("Select a user to modify"))
            return

        # Create the dialog making a copy of the old usermodel
        # so we can check the difference after modification
        old_user = UserModel(usermodel)

        dialog = lumEditUserDialog(self.__datapath, usermodel, self.__group_store)
        
        new_usermodel = dialog.run()
        if (new_usermodel is not None):

            try:
                self.__connection.modify_user(old_user, new_usermodel)
            except LumInsufficientPermissionsError:
                show_error_dialog(_("Insufficient permissions to edit user"))
                return None

            self.statusbar_update(_("User %s successfully modified") % new_usermodel.get_username())
            
            # TODO: Reload only selected user
            self.reload_user_list()
Exemple #4
0
Fichier : app.py Projet : robol/lum
    def missing_ou_cb(self, widget, missing_ou):
        """Callback to ask user if he/she wants to add
        missing ous before continue"""

        text = "\n".join(map(lambda x : "- <b>" + x + "</b>", missing_ou))
        if ask_question(_("The following organizational units are missing in the database, add them?\n%s" % text)):
            for ou in missing_ou:
                self.__connection.add_ou(ou, True)
        else:
            show_info_dialog(_("You will not be able to perform any operation without these OUs"))
            self.disconnect()
Exemple #5
0
    def edit_book_facts(self):
        starting_text = ''
        for (key, arg) in self.book_facts.items():
            starting_text += '{} : {}\n'.format(key, arg)
        response = utilities.show_info_dialog(
            _TR(
                "Edit View Book Facts Dialog Title",
                '''Enter facts about the book such as Title or Author.\n
Each line must have a key such as Title, a colon, then a value.'''),
            self.editv, starting_text)
        if response:  # is not None, there is some text
            self.book_facts = dict()
            for line in response.split('\n'):
                if line.strip():  # is not empty,
                    try:
                        (key, arg) = line.split(
                            ':')  # exception if not exactly 1 colon
                        self.book_facts[key.strip()] = arg.strip()
                    except:
                        utilities.warning_msg(
                            _TR(
                                "Edit book-facts dialog warning message",
                                "Each line must have a key, a colon, and a value. Ignoring:"
                            ), "'{}'".format(line))
                # else skip empty line
            self.metadata_modified(True, C.MD_MOD_FLAG)
Exemple #6
0
Fichier : app.py Projet : robol/lum
    def change_password(self, menu_item = None):
        """Change password of selected user"""
        usermodel, t_iter = self.__get_selected_user()
        if t_iter is None:
            show_info_dialog(_("You need to select a user to change its password"))
            return


        password_dialog = lumChangeUserPasswordDialog(self.__datapath, usermodel.get_username())
        new_password = password_dialog.run()

        if new_password is None:
            return False
        else:
            try:
                self.__connection.change_password(usermodel.get_username(), new_password)
            except LumInsufficientPermissionsError:
                show_error_dialog(_("Insufficient permissions to change user password"))
                return False
            else:
                self.statusbar_update(_("Password of user %s changed succesfully") % usermodel.get_username())
            return True
Exemple #7
0
Fichier : app.py Projet : robol/lum
    def delete_user(self, menu_item = None):
        """Delete the selected user"""
        usermodel, t_iter = self.__get_selected_user()

        if t_iter is None:
            show_info_dialog(_("Select a user to delete!"))
            return

        # Users tend to delete many things they do not want
        # to delete
        if not ask_question(_("Really delete user <b>%s</b>?") % usermodel.get_username()):
            return

        # Delete user from ldap first
        try:
            self.__connection.delete_user(usermodel.get_dn())
        except LumInsufficientPermissionsError:
            show_error_dialog(_("Insufficient permissions to delete user"))
            return None

        # Delete user from internal dictionary
        self.__user_store.remove(t_iter)

        self.statusbar_update(_("User %s deleted.") % usermodel.get_username())