Commit 273dcd11 authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

Improved contextuality in user module

	Added a default class and it's all group for Unassigned users
	When user are removed from a class, there are moved there automatically.
parent 432f7f7d
2005-07-23 Bruno coudoin <bruno.coudoin@free.fr>
Improved contextuality in user module
Added a default class and it's all group for Unassigned users
When user are removed from a class, there are moved there automatically.
* src/boards/python/admin/class_edit.py:
* src/boards/python/admin/class_list.py:
* src/boards/python/admin/group_edit.py:
* src/boards/python/admin/group_list.py:
* src/boards/python/admin/profile_list.py:
* src/boards/python/admin/user_list.py:
* src/gcompris/gcompris_db.c: (gcompris_db_init):
2005-07-23 Yves Combe <yves@ycombe.net>
add gcompris_get_conf(profile, board) to get confs in conguration mode.
......
......@@ -266,8 +266,8 @@ class ClassEdit(gtk.Window):
# Add in the the left view
self.add_user_in_model(self.model_left, (user_id, user_firstname, user_lastname))
# Save the change in the base (set an impossible class_id)
self.cur.execute('update users set class_id=? where user_id=?', (-1, user_id))
# Save the change in the base (1 Is the 'Unselected user' class)
self.cur.execute('update users set class_id=? where user_id=?', (1, user_id))
self.con.commit()
......
......@@ -111,15 +111,19 @@ class Class_list:
right_box.pack_start(button, False, False, 0)
button.show()
button = gtk.Button(stock='gtk-edit')
button.connect("clicked", self.on_edit_class_clicked, treeview_class)
right_box.pack_start(button, False, False, 0)
button.show()
button = gtk.Button(stock='gtk-remove')
button.connect("clicked", self.on_remove_class_clicked, treeview_class)
right_box.pack_start(button, False, False, 0)
button.show()
self.button_edit = gtk.Button(stock='gtk-edit')
self.button_edit.connect("clicked", self.on_edit_class_clicked, treeview_class)
right_box.pack_start(self.button_edit, False, False, 0)
self.button_edit.show()
# Not editable until one class is selected
self.button_edit.set_sensitive(False)
self.button_remove = gtk.Button(stock='gtk-remove')
self.button_remove.connect("clicked", self.on_remove_class_clicked, treeview_class)
right_box.pack_start(self.button_remove, False, False, 0)
self.button_remove.show()
# Not removable until one class is selected
self.button_remove.set_sensitive(False)
# User list for the group
user_hbox = gtk.HBox(False, 8)
......@@ -286,15 +290,6 @@ class Class_list:
class_id, class_name,
self.list_user)
else:
# Tell the user to select a class first
dialog = gtk.MessageDialog(None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
_("You must first select a class in the list"))
dialog.run()
dialog.destroy()
def class_changed_cb(self, selection, user_list):
print "class_changed_cb"
......@@ -307,3 +302,10 @@ class Class_list:
user_list.reload(class_id)
print "current class_id = " + str(class_id)
# The Unaffected class is not editable.
if class_id == 1:
self.button_edit.set_sensitive(False)
self.button_remove.set_sensitive(False)
else:
self.button_edit.set_sensitive(True)
self.button_remove.set_sensitive(True)
......@@ -52,7 +52,8 @@ class GroupEdit(gtk.Window):
self.group_id = group_id
self.class_id = class_id
print "Editing group_id = " + str(self.group_id) + " In class " + str(self.class_id)
# A pointer to the group_user_list class
# Will be called to refresh the list when edit is done
self.group_user = group_user
......
......@@ -93,7 +93,7 @@ class Group_list:
class_label.show()
label_box.pack_start(class_label, False, False, 0)
self.cur.execute('select * from class')
self.cur.execute('select * from class where class_id>1')
class_list = self.cur.fetchall()
self.combo_class = gtk.combo_box_new_text()
......@@ -182,6 +182,7 @@ class Group_list:
size_pixels=False)
# Load lists
self.class_changed_cb(self.combo_class)
self.reload_group()
# -------------------
......
......@@ -333,13 +333,9 @@ class Profile_list:
path = model.get_path(iter)[0]
profile_id = model.get_value(iter, COLUMN_PROFILEID)
# Get the old data (informations is a one line table)
self.cur.execute('select * from informations')
info_data = self.cur.fetchall()[0]
# Save the changes in the base
self.cur.execute('insert or replace into informations (gcompris_version, init_date, profile_id) values (?, ?, ?)',
(info_data[0], info_data[1], profile_id))
self.cur.execute('UPDATE informations SET profile_id=?',
(profile_id,))
self.con.commit()
self.set_default_in_description(iter)
......
......@@ -59,7 +59,7 @@ class User_list:
# ---------------
# The class to work on
self.class_id = 0
self.class_id = 1
self.user_data = []
......
/* gcompris - gcompris_db.c
*
<<<<<<< gcompris_db.c
* Time-stamp: <2005/07/23 01:39:25 bruno>
=======
* Time-stamp: <2005/07/22 21:10:04 yves>
>>>>>>> 1.24
*
* Copyright (C) 2000 Bruno Coudoin
*
......@@ -65,6 +69,9 @@ extern GnomeCanvas *canvas;
#define ACTIVATE_DEFAULT_PROFILE \
"UPDATE informations SET profile_id=1;"
#define SET_DEFAULT_GROUP \
"INSERT INTO groups (group_id, name, class_id, description) VALUES ( 1, \'All\', 1, \'All users\');"
int gcompris_db_init()
{
#ifdef USE_SQLITE
......@@ -163,6 +170,21 @@ int gcompris_db_init()
}
request = g_strdup_printf("INSERT INTO class (class_id, name, teacher, wholegroup_id) VALUES ( 1, \'%s\', \'(%s)\', 1);",
_("Unaffected"),
_("Users without class"));
rc = sqlite3_exec(gcompris_db, request, NULL, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
g_error("SQL error: %s\n", zErrMsg);
}
rc = sqlite3_exec(gcompris_db,SET_DEFAULT_GROUP, NULL, 0, &zErrMsg);
if( rc!=SQLITE_OK ){
g_error("SQL error: %s\n", zErrMsg);
}
sqlite3_free_table(result);
g_free(request);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment