Browse Source

Modification de la recherche du nom de classe dans fields

Roland Haroutiounian 10 years ago
parent
commit
edcfd5b8cd
1 changed files with 8 additions and 11 deletions
  1. 8
    11
      EditorialModel/fields.py

+ 8
- 11
EditorialModel/fields.py View File

@@ -72,7 +72,7 @@ class EmField(EmComponent):
72 72
             createdField = super(EmField,c).create(**values)
73 73
             if createdField:
74 74
                 # The field was created, we then add its column in the corresponding class' table
75
-                is_field_column_added = EmField.addFieldColumnToClassTable(createdField)
75
+                is_field_column_added = createdField.addFieldColumnToClassTable()
76 76
                 if is_field_column_added:
77 77
                     return createdField
78 78
 
@@ -85,16 +85,13 @@ class EmField(EmComponent):
85 85
     #
86 86
     # Adds a column representing the field in its class' table
87 87
     #
88
-    # @static
89
-    #
90 88
     # @param emField EmField: the object representing the field
91 89
     # @return True in case of success, False if not
92
-    @classmethod
93
-    def addFieldColumnToClassTable(c, emField):
94
-        field_type = "%s%s" % (EditorialModel.fieldtypes.get_field_type(emField.fieldtype).sql_column(), " DEFAULT 0" if emField.fieldtype=='integer' else '')
95
-        field_uid = emField.uid
96
-        field_class_table = emField.get_class_table()
97
-        return SqlWrapper().addColumn(tname=field_class_table, colname=emField.name, coltype=field_type)
90
+    def addFieldColumnToClassTable(self):
91
+        field_type = "%s%s" % (EditorialModel.fieldtypes.get_field_type(self.fieldtype).sql_column(), " DEFAULT 0" if self.fieldtype=='integer' else '')
92
+        field_uid = self.uid
93
+        field_class_table = self.get_class_table()
94
+        return SqlWrapper().addColumn(tname=field_class_table, colname=self.name, coltype=field_type)
98 95
 
99 96
     ## get_class_table (Function)
100 97
     #
@@ -112,9 +109,9 @@ class EmField(EmComponent):
112 109
     def _get_class_tableDb(self):
113 110
         dbe = self.getDbE()
114 111
         conn = dbe.connect()
115
-        typetable = sql.Table(EmType.table, sqlutils.meta(dbe))
116 112
         fieldtable = sql.Table(EmField.table, sqlutils.meta(dbe))
117
-        reqGetClassId = typetable.select().where(typetable.c.uid==fieldtable.c.rel_to_type_id)
113
+        fieldgrouptable = sql.Table(EmFieldGroup.table, sqlutils.meta(dbe))
114
+        reqGetClassId = fieldgrouptable.select().where(fieldgrouptable.c.uid == self.fieldgroup_id)
118 115
         resGetClassId = conn.execute(reqGetClassId).fetchall()
119 116
         class_id = dict(zip(resGetClassId[0].keys(), resGetClassId[0]))['class_id']
120 117
 

Loading…
Cancel
Save