def on_add_group_clicked(self, button, model): group_id = constants.get_next_group_id(self.con, self.cur) group_edit.GroupEdit(self.con, self.cur, self.current_class_id, self.get_active_text(self.combo_class), group_id, None, None, self)
def ok(self, button): # Tell the user he must provide enough information if self.entry_group.get_text() == "": dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("You need to provide at least a name for your group"), ) dialog.run() dialog.destroy() return # If the group name as changed, check it does not exists already if self.entry_group.get_text() != self.group_name: # Check the group does not exist already self.cur.execute("SELECT name FROM groups WHERE name=?", (unicode(self.entry_group.get_text()),)) if self.cur.fetchone(): dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("There is already a group with this name"), ) dialog.run() dialog.destroy() return # # Now everything is correct, create the group # group_data = ( self.group_id, unicode(self.entry_group.get_text()), self.class_id, unicode(self.entry_description.get_text()), ) if self.new_group: # Create the new group group_id = constants.get_next_group_id(self.con, self.cur) self.cur.execute( "INSERT INTO groups (group_id, name, class_id, description) " + "VALUES ( ?, ?, ?, ?)", (group_data) ) else: # Save the group changes self.cur.execute( "UPDATE groups SET name=?, description=? where group_id=?", (self.entry_group.get_text(), self.entry_description.get_text(), self.group_id), ) self.con.commit() # Close the dialog window now self.group_user.reload_group() self.destroy()
def create_class(self): # Check the login do not exist already self.cur.execute('SELECT name FROM class WHERE name=?', (unicode(self.entry_class.get_text()),)) if(self.cur.fetchone()): dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("There is already a class with this name")) dialog.run() dialog.destroy() return # Create its Whole group group_id = constants.get_next_group_id(self.con, self.cur) self.cur.execute('INSERT INTO groups (group_id, name, class_id, description) ' + 'VALUES ( ?, "All", ?, "All users")', (group_id, self.class_id)); class_data = (self.class_id, unicode(self.entry_class.get_text()), unicode(self.entry_teacher.get_text()), group_id ) self.cur.execute('INSERT OR REPLACE INTO class (class_id, name, teacher, wholegroup_id) ' + 'values (?, ?, ?, ?)', class_data) # No more need to create this class, it's done self.new_class = False
def ok(self, button): # Tell the user he must provide enough information if(self.entry_group.get_text() == ""): dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("You need to provide at least a name for your group")) dialog.run() dialog.destroy() return # If the group name as changed, check it does not exists already if(self.entry_group.get_text() != self.group_name): # Check the group does not exist already self.cur.execute('SELECT name FROM groups WHERE name=?', (self.entry_group.get_text(),)) if(self.cur.fetchone()): dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, _("There is already a group with this name")) dialog.run() dialog.destroy() return # # Now everything is correct, create the group # group_data = (self.group_id, self.entry_group.get_text(), self.class_id, self.entry_description.get_text() ) if(self.new_group): # Create the new group group_id = constants.get_next_group_id(self.con, self.cur) self.cur.execute('INSERT INTO groups (group_id, name, class_id, description) ' + 'VALUES ( ?, ?, ?, ?)', (group_data)); else: # Save the group changes self.cur.execute('UPDATE groups SET name=?, description=? where group_id=?', (self.entry_group.get_text(), self.entry_description.get_text(), self.group_id)); self.con.commit() # Close the dialog window now self.group_user.reload_group() self.destroy()