[gevice] add mantainer for levels, locations and campus.
- From: Alejandro Valdes Jimenez <avaldes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gevice] add mantainer for levels, locations and campus.
- Date: Thu, 8 Jul 2010 16:33:23 +0000 (UTC)
commit 13c5f9767f18ff787cb2ad35ac103b727c9e706f
Author: Alejandro Valdes Jimenez <avaldes gnome org>
Date: Thu Jul 8 12:33:10 2010 -0400
add mantainer for levels, locations and campus.
ChangeLog | 7 +++
data/glade/gevice.glade | 131 +++++++++++++++++++++++++++++++++++++++++++++++
src/gevice.py | 55 +++++++++++++++++++-
src/gevicedatabase.py | 25 +--------
src/gevicemaintainer.py | 108 +++++++++++++++++++++++++++++++++++++--
5 files changed, 298 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 64229e6..086788e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-08 Alejandro Valdes Jimenez <avaldes gnome org>
+
+ * data/glade/gevice.glade: New mantainer for locations.
+ * src/gevice.py:add mantainer for levels, locations and campus.
+ * src/gevicedatabase.py: add mantainer for levels, locations and campus.
+ * src/gevicemaintainer.py: add mantainer for levels, locations and campus.
+
2010-07-07 Alejandro Valdes Jimenez <avaldes gnome org>
* modelo_gevice.png: Add image of model of database
diff --git a/data/glade/gevice.glade b/data/glade/gevice.glade
index b79d721..3075fda 100644
--- a/data/glade/gevice.glade
+++ b/data/glade/gevice.glade
@@ -1745,4 +1745,135 @@ svg</property>
</widget>
</child>
</widget>
+ <widget class="GtkWindow" id="window_location">
+ <property name="title" translatable="yes" context="yes">New Location</property>
+ <property name="modal">True</property>
+ <property name="window_position">center</property>
+ <child>
+ <widget class="GtkVBox" id="vbox10">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">5</property>
+ <child>
+ <widget class="GtkTable" id="table5">
+ <property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">5</property>
+ <property name="row_spacing">2</property>
+ <child>
+ <widget class="GtkComboBox" id="combobox_edifice">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox_level">
+ <property name="visible">True</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="entry_location">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options"></property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label21">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">Edifice</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">Level</property>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label17">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes" context="yes">Location</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox13">
+ <property name="visible">True</property>
+ <child>
+ <widget class="GtkButton" id="button_cancel">
+ <property name="label" context="yes">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button_ok">
+ <property name="label" context="yes">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
diff --git a/src/gevice.py b/src/gevice.py
index b5c598b..5729a87 100755
--- a/src/gevice.py
+++ b/src/gevice.py
@@ -77,6 +77,9 @@ UI = '''<ui>
<menuitem action="TypeOfLink"/>
<menuitem action="TypeOfDev"/>
<menuitem action="Model"/>
+ <menuitem action="Level"/>
+ <menuitem action="Campus"/>
+ <menuitem action="Location"/>
</menu>
<menu action="ActionsMenu">
<menuitem action="AddDevice"/>
@@ -197,6 +200,9 @@ class Gevice:
('TypeOfLink', gtk.STOCK_EDIT, _('Type of link'),None, _('Type of link'), self.on_action_typeoflink),
('TypeOfDev', gtk.STOCK_EDIT, _('Type of device'),None, _('Type of device'), self.on_action_typeofdev),
('Model', gtk.STOCK_EDIT, _('Model of device'),None, _('Model of device'), self.on_action_model),
+ ('Level', gtk.STOCK_EDIT, _('Levels of locations'),None, _('Levels of locations'), self.on_action_level),
+ ('Campus', gtk.STOCK_EDIT, _('Campus of organization'),None, _('Campus of organization'), self.on_action_campus),
+ ('Location', gtk.STOCK_EDIT, _('Locations of devices'),None, _('Locations of devices'), self.on_action_location),
])
self.actiongroup_window.add_toggle_actions([
@@ -412,11 +418,58 @@ class Gevice:
"update2":" where id_modelo=",
"delete":"delete from modelo where id_modelo=",
"max_id":"select max(id_modelo) + 1 from modelo;",
- "insert":"insert into modelo values "}
+ "insert":"insert into modelo values ",
+ "sql_mark":"select nom_marca,id_marca from marca;",
+ "sql_tipo_disp":"select nom_tipo_disp,id_tipo_disp from tipo_disp"}
+
dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
dialogmaintainer.load_interface1 (gevice,_("Model of device"),sql)
dialogmaintainer.load_data1 (gevice,sql)
dialogmaintainer.show_interface ()
+
+ def on_action_location (gevice,action):
+ sql_select = "select rack.id_rack,'[' || campus.nom_campus || '][' || edificio.nom_edif || '][' || nivel.nom_nivel || ']',rack.detalle "
+ sql_select = sql_select + "from rack inner join nivel on rack.id_nivel = nivel.id_nivel "
+ sql_select = sql_select + "inner join edificio on rack.id_edif = edificio.id_edif "
+ sql_select = sql_select + "inner join campus on edificio.id_campus = campus.id_campus order by 2;"
+
+ sql = {"select":sql_select,
+ "update1":"update rack set detalle=",
+ "update2":" where id_rack=",
+ "delete":"delete from rack where id_rack=",
+ "max_id":"select max(id_rack) + 1 from rack;",
+ "insert":"insert into rack values ",
+ "sql_level":"select nom_nivel,id_nivel from nivel;",
+ "sql_edifice":"select '[' || campus.nom_campus || '][' || edificio.nom_edif || ']', edificio.id_edif from edificio inner join campus on edificio.id_campus = campus.id_campus order by campus.nom_campus,edificio.nom_edif "}
+
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface2 (gevice,_("Locations of devices"),sql)
+ dialogmaintainer.load_data1 (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_level (gevice,action):
+ sql = {"select":"select * from nivel order by 1",
+ "insert":"insert into nivel values ",
+ "delete":"delete from nivel where id_nivel=",
+ "update1":"update nivel set nom_nivel=",
+ "update2":" where id_nivel=",
+ "max_id":"select max(id_nivel)+1 from nivel;"}
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface (gevice,_("Level"),sql)
+ dialogmaintainer.load_data (gevice,sql)
+ dialogmaintainer.show_interface ()
+
+ def on_action_campus (gevice,action):
+ sql = {"select":"select * from campus order by 1",
+ "insert":"insert into campus values ",
+ "delete":"delete from campus where id_campus=",
+ "update1":"update campus set nom_campus=",
+ "update2":" where id_campus=",
+ "max_id":"select max(id_campus)+1 from campus;"}
+ dialogmaintainer = gevicemaintainer.GeviceMaintainer ()
+ dialogmaintainer.load_interface (gevice,_("Campus"),sql)
+ dialogmaintainer.load_data (gevice,sql)
+ dialogmaintainer.show_interface ()
def on_action_mark (gevice,action):
diff --git a/src/gevicedatabase.py b/src/gevicedatabase.py
index a6f9a0a..5c1fb1b 100644
--- a/src/gevicedatabase.py
+++ b/src/gevicedatabase.py
@@ -301,29 +301,10 @@ class GeviceDatabase:
else:
return False
- def get_list_of_type (self,gevice):
- liststore = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_INT)
-
- sql = "select nom_tipo_disp,id_tipo_disp from tipo_disp"
-
- rows = self.execute_sql_select(gevice,sql)
-
- if rows:
- for row in rows:
- iter = liststore.append ()
- liststore.set (
- iter,
- 0,row[0],
- 1,row[1])
-
- return liststore
- else:
- return False
def get_list_of_location (self,gevice):
liststore = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_INT)
- #sql = "select '[' || rack.detalle || '][' || nivel.nom_nivel || '][' || edificio.nom_edif || '][' || campus.nom_campus || ']' as location, rack.id_rack "
sql = "select '[' || campus.nom_campus || '][' || edificio.nom_edif || '][' || nivel.nom_nivel || '][' || rack.detalle || ']' as location, rack.id_rack "
sql = sql + "from rack "
sql = sql + "join edificio on rack.id_edif = edificio.id_edif "
@@ -342,11 +323,9 @@ class GeviceDatabase:
else:
return False
- def get_list_of_mark (self,gevice):
+ def get_list_of_data (self,gevice,sql):
liststore = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_INT)
-
- sql = "select nom_marca,id_marca from marca"
-
+
rows = self.execute_sql_select(gevice,sql)
if rows:
diff --git a/src/gevicemaintainer.py b/src/gevicemaintainer.py
index 32bba73..63098eb 100644
--- a/src/gevicemaintainer.py
+++ b/src/gevicemaintainer.py
@@ -16,6 +16,8 @@ class GeviceMaintainer:
def __ini__ (self):
self.list_mark = None
self.list_type = None
+ self.list_level = None
+ self.list_edifice = None
def load_interface (self,gevice,title,sql):
@@ -92,6 +94,48 @@ class GeviceMaintainer:
self.button_close.connect ("clicked",self.on_button_close_clicked,)
self.button_rem.connect ("clicked",self.on_button_rem_model_clicked,gevice,sql)
self.button_add.connect ("clicked",self.on_button_add_model_clicked,gevice,sql)
+
+ def load_interface2 (self,gevice,title,sql):
+ glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR, "gevice.glade"),"window_maintainer1",None)
+ self.window_maintainer = glade_file.get_widget ("window_maintainer1")
+ self.button_add = glade_file.get_widget ("button_add1")
+ self.button_rem = glade_file.get_widget ("button_rem1")
+ self.button_close = glade_file.get_widget ("button_close1")
+ self.treeview = glade_file.get_widget ("treeview1")
+
+ self.window_maintainer.set_title (title)
+
+ self.modelcell = gtk.ListStore(int, gobject.TYPE_STRING)
+
+ # create columns
+ col = gtk.TreeViewColumn (_("ID"))
+ col.set_resizable (True)
+ self.treeview.append_column (col)
+ cell = gtk.CellRendererText()
+ cell.set_property('editable',False)
+ col.pack_start (cell,True)
+ col.add_attribute (cell,"text",0)
+
+ col = gtk.TreeViewColumn (_("Edifice"))
+ col.set_resizable (True)
+ self.treeview.append_column (col)
+ cell = gtk.CellRendererText()
+ cell.set_property('editable',False)
+ col.pack_start (cell,True)
+ col.add_attribute (cell,"text",1)
+
+ col = gtk.TreeViewColumn (_("Location"))
+ col.set_resizable (True)
+ self.treeview.append_column (col)
+ cell = gtk.CellRendererText()
+ cell.set_property('editable',True)
+ cell.connect('edited', self.on_model_edited,gevice,sql)
+ col.pack_start (cell,True)
+ col.add_attribute (cell,"text",2)
+
+ self.button_close.connect ("clicked",self.on_button_close_clicked,)
+ self.button_rem.connect ("clicked",self.on_button_rem_model_clicked,gevice,sql)
+ self.button_add.connect ("clicked",self.on_button_add_location_clicked,gevice,sql)
def load_interface_model (self,gevice,sql):
@@ -104,16 +148,15 @@ class GeviceMaintainer:
self.entry_model = glade_file.get_widget ("entry_model")
self.button_cancel.connect ("clicked",self.on_button_model_cancel_clicked)
- self.button_ok.connect ("clicked",self.on_button_model_ok_clicked,gevice,sql)
+ self.button_ok.connect ("clicked",self.on_button_location_ok_clicked,gevice,sql)
-
- self.list_type = gevice.gdbase.get_list_of_type(gevice)
+ self.list_type = gevice.gdbase.get_list_of_data(gevice,sql["sql_tipo_disp"])
self.combobox_type.set_model(self.list_type)
cell = gtk.CellRendererText()
self.combobox_type.pack_start(cell, True)
self.combobox_type.add_attribute(cell, 'text', 0)
- self.list_mark = gevice.gdbase.get_list_of_mark(gevice)
+ self.list_mark = gevice.gdbase.get_list_of_data(gevice,sql["sql_mark"])
self.combobox_mark.set_model (self.list_mark)
cell = gtk.CellRendererText()
self.combobox_mark.pack_start(cell, True)
@@ -125,10 +168,43 @@ class GeviceMaintainer:
self.window_model.show_all()
+ def load_interface_location (self,gevice,sql):
+ glade_file = gtk.glade.XML (os.path.join (config.GLADEDIR, "gevice.glade"),"window_location",None)
+ self.window_location = glade_file.get_widget ("window_location")
+ self.button_ok = glade_file.get_widget ("button_ok")
+ self.button_cancel = glade_file.get_widget ("button_cancel")
+ self.combobox_level = glade_file.get_widget ("combobox_level")
+ self.combobox_edifice = glade_file.get_widget ("combobox_edifice")
+ self.entry_location = glade_file.get_widget ("entry_location")
+
+ self.button_cancel.connect ("clicked",self.on_button_location_cancel_clicked)
+ self.button_ok.connect ("clicked",self.on_button_location_ok_clicked,gevice,sql)
+
+ self.list_level = gevice.gdbase.get_list_of_data(gevice,sql["sql_level"])
+ self.combobox_level.set_model(self.list_level)
+ cell = gtk.CellRendererText()
+ self.combobox_level.pack_start(cell, True)
+ self.combobox_level.add_attribute(cell, 'text', 0)
+
+ self.list_edifice = gevice.gdbase.get_list_of_data(gevice,sql["sql_edifice"])
+ self.combobox_edifice.set_model (self.list_edifice)
+ cell = gtk.CellRendererText()
+ self.combobox_edifice.pack_start(cell, True)
+ self.combobox_edifice.add_attribute(cell, 'text', 0)
+
+ self.entry_location.set_text("")
+ self.combobox_level.set_active(0)
+ self.combobox_edifice.set_active(0)
+
+ self.window_location.show_all()
+
def on_button_model_cancel_clicked (self,button):
self.close_window (self.window_model)
+ def on_button_location_cancel_clicked (self,button):
+ self.close_window (self.window_location)
+
def show_interface (self):
self.window_maintainer.show_all()
@@ -253,6 +329,9 @@ class GeviceMaintainer:
def on_button_add_model_clicked(self,button,gevice,sql):
self.load_interface_model(gevice,sql)
+
+ def on_button_add_location_clicked(self,button,gevice,sql):
+ self.load_interface_location(gevice,sql)
def on_button_rem_clicked(self,button,gevice,sql):
@@ -283,6 +362,7 @@ class GeviceMaintainer:
delete = sql["delete"] + str(id)
+
result = gevice.show_message (_("Do you want to remove: ") + name,gtk.MESSAGE_QUESTION,gtk.BUTTONS_YES_NO)
if result == gtk.RESPONSE_YES:
@@ -311,3 +391,23 @@ class GeviceMaintainer:
self.load_data1(gevice,sql)
self.on_button_model_cancel_clicked(None)
+
+ def on_button_location_ok_clicked (self,button,gevice,sql):
+ nlocation = self.entry_location.get_text()
+
+ iter_level = self.combobox_level.get_active_iter()
+ id_level = self.list_level.get_value(iter_level,1)
+
+ iter_edifice = self.combobox_edifice.get_active_iter()
+ id_edifice = self.list_edifice.get_value(iter_edifice,1)
+
+
+ row = gevice.gdbase.execute_sql_select (gevice,sql["max_id"])
+
+ insert = sql["insert"] + " (" + str(row[0][0]) + "," + str(id_level) + "," + str(id_edifice) + ",'" + nlocation + "')"
+
+ if (gevice.gdbase.execute_sql_insert (gevice,insert)):
+ gevice.gdbase.conn.commit()
+
+ self.load_data1(gevice,sql)
+ self.on_button_location_cancel_clicked(None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]