Home | Trees | Indices | Help |
|
---|
|
1 """GNUmed staff management widgets. 2 3 This source code is protected by the GPL licensing scheme. 4 Details regarding the GPL are available at http://www.gnu.org 5 You may use and share it as long as you don't deny this right 6 to anybody else. 7 """ 8 #========================================================================= 9 # $Source: /home/ncq/Projekte/cvs2git/vcs-mirror/gnumed/gnumed/client/wxpython/gmStaffWidgets.py,v $ 10 # $Id: gmStaffWidgets.py,v 1.27 2010-01-31 18:20:03 ncq Exp $ 11 __version__ = "$Revision: 1.27 $" 12 __author__ = "K. Hilbert <Karsten.Hilbert@gmx.net>" 13 __license__ = "GPL (details at http://www.gnu.org)" 14 15 import logging 16 17 import wx 18 19 from Gnumed.pycommon import gmPG2, gmTools, gmI18N 20 from Gnumed.business import gmPerson 21 from Gnumed.wxpython import gmGuiHelpers, gmAuthWidgets 22 from Gnumed.wxGladeWidgets import wxgAddPatientAsStaffDlg, wxgEditStaffListDlg 23 24 _log = logging.getLogger('gm.ui') 25 _log.info(__version__) 26 #==========================================================================28182 #==========================================================================30 wxgEditStaffListDlg.wxgEditStaffListDlg.__init__(self, *args, **kwds) 31 32 self._LCTRL_staff.InsertColumn(0, _('Alias')) 33 self._LCTRL_staff.InsertColumn(1, _('DB account')) 34 self._LCTRL_staff.InsertColumn(2, _('Role')) 35 self._LCTRL_staff.InsertColumn(3, _('Name')) 36 self._LCTRL_staff.InsertColumn(4, _('Comment')) 37 self._LCTRL_staff.InsertColumn(5, _('Status')) 38 39 self.__init_ui_data()40 #-------------------------------------------------------- 41 # internal API 42 #--------------------------------------------------------44 lbl_active = {True: _('active'), False: _('inactive')} 45 lbl_login = {True: _('can login'), False: _('can not login')} 46 47 self._LCTRL_staff.DeleteAllItems() 48 staff_list = gmPerson.get_staff_list() 49 pos = len(staff_list) + 1 50 for staff in staff_list: 51 row_num = self._LCTRL_staff.InsertStringItem(pos, label=staff['short_alias']) 52 self._LCTRL_staff.SetStringItem(index = row_num, col = 1, label = staff['db_user']) 53 self._LCTRL_staff.SetStringItem(index = row_num, col = 2, label = staff['role']) 54 title = gmTools.coalesce(staff['title'], '') 55 self._LCTRL_staff.SetStringItem(index = row_num, col = 3, label = '%s %s, %s' % (title, staff['lastnames'], staff['firstnames'])) 56 self._LCTRL_staff.SetStringItem(index = row_num, col = 4, label = gmTools.coalesce(staff['comment'], '')) 57 self._LCTRL_staff.SetStringItem(index = row_num, col = 5, label = '%s / %s' % (lbl_active[bool(staff['is_active'])], lbl_login[bool(staff['can_login'])])) 58 # color 59 if staff['is_active'] and staff['can_login']: 60 #self._LCTRL_staff.SetItemTextColour(row_num, col=wx.NamedColour('BLUE')) 61 pass 62 elif not staff['is_active'] and not staff['can_login']: 63 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.LIGHT_GREY) 64 else: 65 self._LCTRL_staff.SetItemTextColour(row_num, col=wx.NamedColour('RED')) 66 # data 67 self._LCTRL_staff.SetItemData(item = row_num, data = staff['pk_staff']) 68 69 if len(staff_list) > 0: 70 self._LCTRL_staff.SetColumnWidth(col=0, width=wx.LIST_AUTOSIZE) 71 self._LCTRL_staff.SetColumnWidth(col=1, width=wx.LIST_AUTOSIZE_USEHEADER) 72 self._LCTRL_staff.SetColumnWidth(col=2, width=wx.LIST_AUTOSIZE) 73 self._LCTRL_staff.SetColumnWidth(col=3, width=wx.LIST_AUTOSIZE) 74 self._LCTRL_staff.SetColumnWidth(col=4, width=wx.LIST_AUTOSIZE) 75 self._LCTRL_staff.SetColumnWidth(col=5, width=wx.LIST_AUTOSIZE) 76 77 # disable buttons 78 self._btn_save.Enable(False) 79 self._btn_delete.Enable(False) 80 self._btn_deactivate.Enable(False) 81 self._btn_activate.Enable(False) 82 # clear editor 83 self._TCTRL_name.SetValue('') 84 self._TCTRL_alias.SetValue('') 85 self._TCTRL_account.SetValue('') 86 self._TCTRL_comment.SetValue('')87 #-------------------------------------------------------- 88 # event handlers 89 #--------------------------------------------------------91 self._btn_save.Enable(True) 92 self._btn_delete.Enable(True) 93 self._btn_deactivate.Enable(True) 94 self._btn_activate.Enable(True) 95 # fill editor 96 pk_staff = self._LCTRL_staff.GetItemData(self._LCTRL_staff.GetFirstSelected()) 97 staff = gmPerson.cStaff(aPK_obj=pk_staff) 98 self._TCTRL_name.SetValue('%s.%s %s' % (staff['title'], staff['firstnames'], staff['lastnames'])) 99 self._TCTRL_alias.SetValue(staff['short_alias']) 100 self._TCTRL_account.SetValue(staff['db_user']) 101 self._TCTRL_comment.SetValue(gmTools.coalesce(staff['comment'], ''))102 #--------------------------------------------------------104 self._btn_save.Enable(False) 105 self._btn_delete.Enable(False) 106 self._btn_deactivate.Enable(False) 107 self._btn_activate.Enable(False) 108 # clear editor 109 self._TCTRL_name.SetValue('') 110 self._TCTRL_alias.SetValue('') 111 self._TCTRL_account.SetValue('') 112 self._TCTRL_comment.SetValue('')113 #-------------------------------------------------------- 135 #-------------------------------------------------------- 157 #-------------------------------------------------------- 158 # def _on_delete_button_pressed(self, event): 159 #--------------------------------------------------------184272 #========================================================================== 273 # $Log: gmStaffWidgets.py,v $ 274 # Revision 1.27 2010-01-31 18:20:03 ncq 275 # - protect against empty passwords 276 # 277 # Revision 1.26 2009/07/23 16:42:38 ncq 278 # - staff -> user 279 # 280 # Revision 1.25 2009/06/04 16:33:51 ncq 281 # - adjust to dob-less persons 282 # 283 # Revision 1.24 2008/12/01 12:17:17 ncq 284 # - again 285 # 286 # Revision 1.23 2008/12/01 12:15:36 ncq 287 # - gm_*_user now live in gm. 288 # 289 # Revision 1.22 2008/10/22 12:21:58 ncq 290 # - use %x in strftime where appropriate 291 # 292 # Revision 1.21 2008/08/20 14:55:33 ncq 293 # - explicitely signal error condition of database 294 # account already being in use for a staff member 295 # 296 # Revision 1.20 2008/03/05 22:30:15 ncq 297 # - new style logging 298 # 299 # Revision 1.19 2008/01/11 16:15:33 ncq 300 # - first/last -> first-/lastnames 301 # 302 # Revision 1.18 2008/01/05 16:41:27 ncq 303 # - remove logging from gm_show_*() 304 # 305 # Revision 1.17 2007/12/04 16:16:27 ncq 306 # - use gmAuthWidgets 307 # 308 # Revision 1.16 2007/04/23 01:11:51 ncq 309 # - handle gm-dbo password field 310 # 311 # Revision 1.15 2007/03/01 16:35:01 ncq 312 # - no more idents 313 # 314 # Revision 1.14 2007/02/22 17:41:13 ncq 315 # - adjust to gmPerson changes 316 # 317 # Revision 1.13 2006/12/31 16:25:43 ncq 318 # - strftime() does not take unicode 319 # 320 # Revision 1.12 2006/11/24 14:23:41 ncq 321 # - EndModal() needs wx.ID_* 322 # 323 # Revision 1.11 2006/10/31 13:30:27 ncq 324 # - use gmPG2 325 # 326 # Revision 1.10 2006/10/25 07:46:44 ncq 327 # - Format() -> strftime() since datetime.datetime does not have .Format() 328 # 329 # Revision 1.9 2006/10/25 07:21:57 ncq 330 # - no more gmPG 331 # 332 # Revision 1.8 2006/09/03 11:32:10 ncq 333 # - clean up wx import 334 # - use gmTools.coalesce() 335 # - use gmGuiHelpers.get_dbowner_connection instead of local crap copy 336 # 337 # Revision 1.7 2006/06/17 16:45:19 ncq 338 # - only insert column labels once 339 # - use get_dbowner_connection() in gmGuiHelpers 340 # - implement activate()/save() on staff details 341 # 342 # Revision 1.6 2006/06/15 20:57:49 ncq 343 # - actually do something with the improved staff list editor 344 # 345 # Revision 1.5 2006/06/10 05:13:06 ncq 346 # - improved "edit staff list" 347 # 348 # Revision 1.4 2006/06/09 14:43:02 ncq 349 # - improve staff member handling 350 # 351 # Revision 1.3 2006/06/06 20:54:36 ncq 352 # - add staff member delisting dialog 353 # 354 # Revision 1.2 2006/03/14 21:31:15 ncq 355 # - add event handlers for buttons 356 # - actually implement adding a new provider 357 # 358 # Revision 1.1 2006/03/09 21:10:14 ncq 359 # - simple wrapper around dialog to add current patient as staff member 360 # 361186 wxgAddPatientAsStaffDlg.wxgAddPatientAsStaffDlg.__init__(self, *args, **kwds) 187 self.__init_ui_data()188 #-------------------------------------------------------- 189 # internal API 190 #--------------------------------------------------------192 pat = gmPerson.gmCurrentPatient() 193 name = pat.get_active_name() 194 txt = _(""" 195 %s "%s" %s 196 born: %s""") % (name['firstnames'], name['preferred'], name['lastnames'], pat.get_formatted_dob(format = '%x', encoding = gmI18N.get_encoding())) 197 self._TXT_person.SetValue(txt) 198 txt = name['firstnames'][:2] + name['lastnames'][:2] 199 self._TXT_short_alias.SetValue(txt) 200 self._TXT_account.SetValue(txt.lower())201 #-------------------------------------------------------- 202 # event handlers 203 #-------------------------------------------------------- 206 #--------------------------------------------------------
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Nov 29 04:05:20 2010 | http://epydoc.sourceforge.net |