Пример #1
0
 def __init__(self, app, parent, *args):
     BaseManagerWidget.__init__(self, app, parent, TroubleView, 'TroubleManager')
     self.setCaption('TroubleManager')
     self.manager = TroubleManager(self.app)
     self.refreshlistView()
     self.dialogs = {}
     print 'trouble app', app, self.app
     self.resize(400, 600)
Пример #2
0
class TroubleActionView(ViewBrowser):
    def __init__(self, app, parent, troubleid):
        ViewBrowser.__init__(self, app, parent, TroubleInfoDoc)
        self.dialogs = {}
        self.manager = TroubleManager(self.app)

    def setSource(self, url):
        action, context, id = str(url).split('.')
        print action, context, id
        if context == 'action':
            if action == 'new':
                status = self.manager.getTroubleStatus(self.doc.current)
                if status != 'done':
                    dlg = ActionDialog(self, 'ActionDialog')
                    dlg.connect(dlg, SIGNAL('okClicked()'), self.insertAction)
                    dlg.troubleid = self.doc.current
                    statustypes = [r.status for r in self.manager.db.select(table='trouble_status')]
                    for idx in range(len(statustypes)):
                        dlg.statusEdit.setCurrentItem(statustypes[idx], True, idx)
                    dlg.statusEdit.setCurrentItem(status)
                    if id == 'none':
                        dlg.actionid = None
                    else:
                        dlg.actionid = int(id)
                    self.dialogs['new-action'] = dlg
        elif context == 'page':
            if action == 'refresh':
                self.setID(self.current)
                print 'fresh page'
                
    def setID(self, troubleid):
        self.current = troubleid
        self.doc.setID(troubleid)
        self.setText(self.doc.toxml())

    def insertAction(self):
        dlg = self.dialogs['new-action']
        action = str(dlg.actionEdit.text())
        status = str(dlg.statusEdit.currentText())
        workdone = str(dlg.workdoneEdit.text())
        troubleid = dlg.troubleid
        self.manager.updateTrouble(troubleid, action, workdone, status)
        self.setID(troubleid)
Пример #3
0
class TroubleInfoDoc(BaseDocument):
    def __init__(self, app):
        BaseDocument.__init__(self, app)
        self.manager = TroubleManager(self. app)

    def set_clause(self, clause):
        self.clear_body()
        rows = self.db.select(fields=['title'], table='tickets')

    def setID(self, troubleid):
        #row = self.manager.get_ticket(troubleid, data=True)
        info = self.manager.getTroubleInfo(troubleid)
        self.current = troubleid
        self.clear_body()
        #make header
        self.body.appendChild(TitleTable(info['problem']))
        self.header = TroubleHeader(troubleid, info)
        self.body.appendChild(self.header)
        hr = BaseElement('hr')
        self.body.appendChild(hr)
        #append ticket data
        tdata = TroubleData(info['worktodo'])
        self.body.appendChild(tdata)
        hr = BaseElement('hr')
        self.body.appendChild(hr)
        #append ticket footer
        self.tfooter = TroubleFooter(troubleid)
        self.body.appendChild(self.tfooter)
        #actions, rows, trows, crows = self.manager.get_actions(troubleid, True)
        #athreads = ActionThreads(self.body, actions, trows, crows)
        #self.body.appendChild(athreads)
        #self.threads = athreads
        actionrows = info['actions']
        print actionrows
        self.body.appendChild(ActionTable(actionrows))
                                                                   
    def showActionData(self, actionid):
        data = self.manager.get_actiondata(self.current, actionid)
        self.threads.show_data(actionid, data)

    def hideActionData(self, actionid):
        self.threads.hide_data(actionid)
Пример #4
0
 def __init__(self, app, parent, clientid, name='TroubleDialog'):
     VboxDialog.__init__(self, parent, name)
     self.app = app
     self.manager = TroubleManager(self.app)
     self.clientid = clientid
     self.problemEdit = KLineEdit('', self.page)
     self.magnetBox = MyCombo(self.page)
     self.magnetBox.fill(self.manager.getAvailableMagnets())
     self.worktodoEdit = KTextEdit(self.page)
     self.vbox.addWidget(self.problemEdit)
     self.vbox.addWidget(self.magnetBox)
     self.vbox.addWidget(self.worktodoEdit)
     self.showButtonApply(False)
     self.setButtonOKText('insert', 'insert')
     self.show()
Пример #5
0
class TroubleDocument(BaseDocument):
    def __init__(self, app):
        BaseDocument.__init__(self, app)
        self.manager = TroubleManager(self.app)

    def setID(self, clause=None, ids=None):
        self.clear_body()
        rows = self.manager.getTroubles(clause=clause)
        for row in rows:
            info = dict(row)
            crow = self.db.select_row(table='clients', clause=Eq('clientid', row.clientid))
            info['client'] = crow.client
            element = TroubleInfoElement(info)
            self.body.appendChild(element)
            self.body.appendChild(HR())

    def setStatusReport(self):
        counts = self.manager.getStatusCounts()
        hd = TextElement('h1', 'Status Report')
        self.body.appendChild(hd)
        for status, count in counts.items():
            st = TextElement('p', 'Status:  %s\t\t\tNumber: %d' % (status, count))
            self.body.appendChild(st)
            self.body.appendChild(BR())
Пример #6
0
class TroubleDialog(VboxDialog):
    def __init__(self, app, parent, clientid, name='TroubleDialog'):
        VboxDialog.__init__(self, parent, name)
        self.app = app
        self.manager = TroubleManager(self.app)
        self.clientid = clientid
        self.problemEdit = KLineEdit('', self.page)
        self.magnetBox = MyCombo(self.page)
        self.magnetBox.fill(self.manager.getAvailableMagnets())
        self.worktodoEdit = KTextEdit(self.page)
        self.vbox.addWidget(self.problemEdit)
        self.vbox.addWidget(self.magnetBox)
        self.vbox.addWidget(self.worktodoEdit)
        self.showButtonApply(False)
        self.setButtonOKText('insert', 'insert')
        self.show()

    def getRecordData(self):
        problem = str(self.problemEdit.text())
        worktodo = str(self.worktodoEdit.text())
        magnet = str(self.magnetBox.currentText())
        return dict(problem=problem, magnet=magnet,
                    worktodo=worktodo, clientid=self.clientid)
Пример #7
0
 def __init__(self, app, parent, troubleid):
     ViewBrowser.__init__(self, app, parent, TroubleInfoDoc)
     self.dialogs = {}
     self.manager = TroubleManager(self.app)
Пример #8
0
class TroubleManagerWidget(BaseManagerWidget):
    def __init__(self, app, parent, *args):
        BaseManagerWidget.__init__(self, app, parent, TroubleView, 'TroubleManager')
        self.setCaption('TroubleManager')
        self.manager = TroubleManager(self.app)
        self.refreshlistView()
        self.dialogs = {}
        print 'trouble app', app, self.app
        self.resize(400, 600)
        
    def initActions(self):
        collection = self.actionCollection()
        self.newAction = KStdAction.openNew(self.slotNew, collection)
        self.quitAction = KStdAction.quit(self.close, collection)
        
    def initMenus(self):
        menu = KPopupMenu(self)
        self.newAction.plug(menu)
        self.quitAction.plug(menu)
        self.menuBar().insertItem('&Main', menu)
        self.menuBar().insertItem('&Help', self.helpMenu(''))

    def initlistView(self):
        self.listView.setRootIsDecorated(True)
        self.listView.addColumn('trouble group')


    def initToolbar(self):
        toolbar = self.toolBar()
        actions = [self.newAction, self.quitAction]
        for action in actions:
            action.plug(toolbar)
            
    def refreshlistView(self):
        self.listView.clear()
        all = KListViewItem(self.listView, 'all')
        status = KListViewItem(self.listView, 'status')
        rows = self.db.select(table='trouble_status')
        for row in rows:
            s = KListViewItem(status, row.status)
            s.status = row.status
        client = KListViewItem(self.listView, 'client')
        sel = self.db.stmt.select(fields=['clientid'], table='troubles',
                             clause=Neq('status', 'done'))
        clause = In('clientid', sel)
        rows = self.db.select(fields=['clientid', 'client'], table='clients',
                              clause=clause)
        for row in rows:
            c = KListViewItem(client, row.client)
            c.clientid = row.clientid
        magnet = KListViewItem(self.listView, 'magnet')
        for m in self.manager.getUsedMagnets():
            item = KListViewItem(magnet, m)
            item.magnet = m
        untouched = KListViewItem(self.listView, 'untouched')
        statreport = KListViewItem(self.listView, 'status report')
        
    def slotNew(self, title='', data=''):
        dlg = TroubleDialog(self)
        dlg.titleEdit.setText(title)
        dlg.dataEdit.setText(data)
        self.connect(dlg, SIGNAL('okClicked()'), self.create_ticket)
        self.dialogs['new-trouble'] = dlg

    def create_trouble(self):
        dlg = self.dialogs['new-trouble']
        title = str(dlg.titleEdit.text())
        data = str(dlg.dataEdit.text())
        if data and title:
            self.manager.create_ticket(title, data)
            self.refreshlistView()
        elif title:
            KMessageBox.error(self, "just a title won't do.")
            self.slotNew(title=title)
        elif data:
            KMessageBox.error(self, "You also need a title.")
            self.slotNew(data=data)
        else:
            KMessageBox.information(self, 'Nothing Done.')
        
            
    def selectionChanged(self):
        current = self.listView.currentItem()
        print current
        if hasattr(current, 'troubleid'):
            self.view.setID(current.troubleid)
        elif hasattr(current, 'clientid'):
            clientid = current.clientid
            self.view.setID(clause=Eq('clientid', clientid))
        elif hasattr(current, 'status'):
            self.view.setID(clause=Eq('status', current.status))
        elif hasattr(current, 'magnet'):
            troubleid = self.manager.getTroubleIdByMagnet(current.magnet)
            self.view.setID(clause=Eq('troubleid', troubleid))
        elif str(current.text(0)) == 'all':
            self.view.setID(None)
        elif str(current.text(0)) == 'untouched':
            print 'hey hey hey, untouched'
            self.view.setID(clause=Eq('status', 'untouched'))
        elif str(current.text(0)) == 'status report':
            self.view.showStatusReport()
Пример #9
0
 def __init__(self, app):
     BaseDocument.__init__(self, app)
     self.manager = TroubleManager(self. app)