Exemple #1
0
 def submit(self):
     # read current item in database
     afId = self.submitRecord['id']
     self.cur = nafdb.connection.cursor()
     cmd = "select * from %s where id=?" % (self.tableName, )
     self.cur.execute(cmd, (afId, ))
     currentData = self.cur.fetchone()
     # compare current item to submitted item, write changes to a dictionary
     changeRecord = []
     for column, data in zip(self.columns, currentData):
         if self.submitRecord.has_key(column) and data != self.submitRecord[column]:
             if column == 'image':
                 # TODO: is this nice to handle image this way
                 changeRecord.append({'table':self.tableName, 'column': column, 'old': 'not shown', 'new': 'not shown'})
             else:
                 changeRecord.append({'table':self.tableName, 'column': column, 'old': data, 'new': self.submitRecord[column]})
     # update submitted item in database
     clause = ','.join(['%s=?' % columnName for columnName in self.submitRecord.iterkeys()])
     cmd = 'update %s set %s where id==?;' % (self.tableName, clause)
     values = self.submitRecord.values() + [afId, ]
     self.cur.execute(cmd, values)
     # save identified changes in database
     (user, timestamp) = nafdb.getUserAndDate()
     title = self._fmtChangeTitle(afId, currentData)
     (changeId, parentId, typeid, title) = nafdb.newItem('changes', title, None, makeChangeEntry=False)
     cmd = 'update changes set description=?, afid=?, changetype=?, date=?, user=? where id=?'
     self.cur.execute(cmd, (json.dumps(changeRecord), afId, nafdb.CHANGETYPE_EDITED, timestamp, user, changeId))        
     nafdb.connection.commit()
     self.submitRecord = {}
     logging.info(cmd)
     return True
Exemple #2
0
 def submit(self):
     # read current item in database
     afId = self.submitRecord["id"]
     self.cur = nafdb.connection.cursor()
     cmd = "select * from %s where id=?" % (self.tableName,)
     self.cur.execute(cmd, (afId,))
     currentData = self.cur.fetchone()
     # compare current item to submitted item, write changes to a dictionary
     changeRecord = []
     for column, data in zip(self.columns, currentData):
         if self.submitRecord.has_key(column) and data != self.submitRecord[column]:
             if column == "image":
                 # TODO: is this nice to handle image this way
                 changeRecord.append(
                     {"table": self.tableName, "column": column, "old": "not shown", "new": "not shown"}
                 )
             else:
                 changeRecord.append(
                     {"table": self.tableName, "column": column, "old": data, "new": self.submitRecord[column]}
                 )
     # update submitted item in database
     clause = ",".join(["%s=?" % columnName for columnName in self.submitRecord.iterkeys()])
     cmd = "update %s set %s where id==?;" % (self.tableName, clause)
     values = self.submitRecord.values() + [afId]
     self.cur.execute(cmd, values)
     # save identified changes in database
     (user, timestamp) = nafdb.getUserAndDate()
     title = self._fmtChangeTitle(afId, currentData)
     (changeId, parentId, typeid, title) = nafdb.newItem("changes", title, None, makeChangeEntry=False)
     cmd = "update changes set description=?, afid=?, changetype=?, date=?, user=? where id=?"
     self.cur.execute(cmd, (json.dumps(changeRecord), afId, nafdb.CHANGETYPE_EDITED, timestamp, user, changeId))
     nafdb.connection.commit()
     self.submitRecord = {}
     logging.info(cmd)
     return True
Exemple #3
0
 def execTestcase(self):
     tableViewIndex = self.tableView.currentIndex()
     row = self.tableView.currentIndex().row()
     index = self.tableView.model().index(row, 0)
     testrunId = self.tableView.model().data(index).toInt()[0]
     query = QtSql.QSqlQuery("SELECT status FROM testruns WHERE id==%d" % testrunId)
     query.next()
     testrunStatus , valid = query.value(0).toInt()
     if not valid:
         raise ValueError
             
     dlg = _oatr_testrun.cTestrunDialog(self.testrunModel)
     dlg.testrunEditor.mapper.setCurrentIndex(index.row())
     if testrunStatus == _oatr_database.STATUS_PENDING:
         (user, timestamp) = getUserAndDate()
         dlg.testrunEditor.setTester(user)
         dlg.testrunEditor.setDate(timestamp)
     if QtGui.QDialog.Accepted == dlg.exec_():
         dlg.updateRow(row)
         self.updateStatusBar()
     self.tableView.setCurrentIndex(tableViewIndex)
Exemple #4
0
    def execTestcase(self):
        tableViewIndex = self.tableView.currentIndex()
        row = self.tableView.currentIndex().row()
        index = self.tableView.model().index(row, 0)
        testrunId = self.tableView.model().data(index).toInt()[0]
        query = QtSql.QSqlQuery("SELECT status FROM testruns WHERE id==%d" %
                                testrunId)
        query.next()
        testrunStatus, valid = query.value(0).toInt()
        if not valid:
            raise ValueError

        dlg = _oatr_testrun.cTestrunDialog(self.testrunModel)
        dlg.testrunEditor.mapper.setCurrentIndex(index.row())
        if testrunStatus == _oatr_database.STATUS_PENDING:
            (user, timestamp) = getUserAndDate()
            dlg.testrunEditor.setTester(user)
            dlg.testrunEditor.setDate(timestamp)
        if QtGui.QDialog.Accepted == dlg.exec_():
            dlg.updateRow(row)
            self.updateStatusBar()
        self.tableView.setCurrentIndex(tableViewIndex)