fixes for rec.get
[sface.git] / sface / screens / userscreen.py
index 677a2db..4eb7793 100644 (file)
@@ -5,7 +5,6 @@ import pickle
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
-from sfa.util.record import SfaRecord, SliceRecord, AuthorityRecord, UserRecord
 from sface.config import config
 from sface.sfiprocess import SfiProcess
 from sface.screens.sfascreen import SfaScreen
 from sface.config import config
 from sface.sfiprocess import SfiProcess
 from sface.screens.sfascreen import SfaScreen
@@ -68,13 +67,10 @@ class UserNameDelegate(QStyledItemDelegate):
         if option.state & QStyle.State_Selected:
             painter.fillRect(option.rect, option.palette.color(QPalette.Active, QPalette.Highlight))
 
         if option.state & QStyle.State_Selected:
             painter.fillRect(option.rect, option.palette.color(QPalette.Active, QPalette.Highlight))
 
-        color = None
         for x in user_status.keys():
             if (user_status[x] == status_data) and (x in color_status):
         for x in user_status.keys():
             if (user_status[x] == status_data) and (x in color_status):
-                color = color_status[x]
+                painter.fillPath(path, color_status[x])
 
 
-        if color != None:
-            painter.fillPath(path, color)
         painter.setPen(QColor.fromRgb(0, 0, 0))
         painter.drawText(textRect, Qt.AlignVCenter, QString(data))
 
         painter.setPen(QColor.fromRgb(0, 0, 0))
         painter.drawText(textRect, Qt.AlignVCenter, QString(data))
 
@@ -143,13 +139,13 @@ class UserModel(QStandardItemModel):
         slice_persons = []
 
         if sliceRec:
         slice_persons = []
 
         if sliceRec:
-            #for pi in sliceRec.get_field("PI", default=[]):
+            #for pi in sliceRec.get("PI", []):
             #    name = str(pi)
             #    if not name in added_persons:
             #         slice_persons.append({"name": name, "role": "PI", "member": user_status["in"]})
             #         added_persons.append(name)
 
             #    name = str(pi)
             #    if not name in added_persons:
             #         slice_persons.append({"name": name, "role": "PI", "member": user_status["in"]})
             #         added_persons.append(name)
 
-            for researcher in sliceRec.get_field("researcher", default=[]):
+            for researcher in sliceRec.get("researcher", []):
                 name = str(researcher)
                 if not name in added_persons:
                      slice_persons.append({"name": name, "role": "researcher", "member": user_status["in"]})
                 name = str(researcher)
                 if not name in added_persons:
                      slice_persons.append({"name": name, "role": "researcher", "member": user_status["in"]})
@@ -186,15 +182,15 @@ class UserModel(QStandardItemModel):
             childStatus = str(item.child(row, MEMBERSHIP_STATUS_COLUMN).data(Qt.DisplayRole).toString())
 
             if (childStatus == user_status['add']):
             childStatus = str(item.child(row, MEMBERSHIP_STATUS_COLUMN).data(Qt.DisplayRole).toString())
 
             if (childStatus == user_status['add']):
-                researcher = slicerec.get_field("researcher", [])
+                researcher = slicerec.get("researcher", [])
                 researcher.append(childName)
                 slicerec["researcher"] = researcher
                 change = True
             elif (childStatus == user_status['remove']):
                 researcher.append(childName)
                 slicerec["researcher"] = researcher
                 change = True
             elif (childStatus == user_status['remove']):
-                if childName in slicerec.get_field("PI"):
-                     slicerec.get_field("PI").remove(childName)
-                if childName in slicerec.get_field("researcher"):
-                     slicerec.get_field("researcher").remove(childName)
+                if childName in slicerec.get("PI"):
+                     slicerec.get("PI").remove(childName)
+                if childName in slicerec.get("researcher"):
+                     slicerec.get("researcher").remove(childName)
                 change = True
 
         return change
                 change = True
 
         return change