class ClientView(ViewBrowser): def __init__(self, db, parent): doc = ClientInfoDoc(db) ViewBrowser.__init__(self, db, parent, ClientInfoDoc) self.dialogs = {} self.manager = ClientManager(self.db) def setSource(self, url): action, context, id = str(url).split('.') if context == 'contact': if action == 'new': dlg = ContactDialog(self, self.db) dlg.connect(dlg, SIGNAL('okClicked()'), self.insertContact) dlg.clientid = self.doc.current self.dialogs['new-contact'] = dlg elif context == 'location': if action == 'new': dlg = LocationDialog(self, self.db) dlg.connect(dlg, SIGNAL('okClicked()'), self.insertLocation) dlg.clientid = self.doc.current self.dialogs['new-location'] = dlg else: KMessageBox.error(self, 'bad call %s' % url) def set_client(self, clientid): clause = Eq('clientid', clientid) self.doc.setID(clientid) self.setText(self.doc.toxml()) def insertContact(self): dlg = self.dialogs['new-contact'] data = dict([(k,v.text()) for k,v in dlg.grid.entries.items()]) contactid = self.manager.insertContact(dlg.clientid, dlg.addressid, data) self.set_client(dlg.clientid) def insertLocation(self): dlg = self.dialogs['new-location'] data = dict([(k,v.text()) for k,v in dlg.grid.entries.items()]) locationid = self.manager.insertLocation(dlg.clientid, dlg.addressid, data) self.set_client(dlg.clientid)
def __init__(self, db, parent): doc = ClientInfoDoc(db) ViewBrowser.__init__(self, db, parent, ClientInfoDoc) self.dialogs = {} self.manager = ClientManager(self.db)