00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 from PyQt4.QtCore import *
00029 from PyQt4.QtGui import *
00030 from PyQt4.uic import *
00031 from ServerConfigurationDialog import *
00032 from Koo.Common.Settings import *
00033 from Koo import Rpc
00034
00035 (AdministratorPasswordDialogUi, AdministratorPasswordDialogBase) = loadUiType( Common.uiPath('admin_passwd.ui') )
00036
00037 class AdministratorPasswordDialog( QDialog, AdministratorPasswordDialogUi ):
00038 def __init__(self, parent=None):
00039 QDialog.__init__(self, parent)
00040 AdministratorPasswordDialogUi.__init__(self)
00041 self.setupUi( self )
00042
00043 self.connect( self.pushChange, SIGNAL('clicked()'), self.slotChange )
00044 self.connect( self.pushAccept, SIGNAL('clicked()'), self.slotAccept )
00045 self.connect( self.pushCancel, SIGNAL('clicked()'), self.reject )
00046
00047 url = QUrl( Settings.value( 'login.url' ) )
00048 url.setUserName( '' )
00049 self.uiServer.setText( url.toString() )
00050
00051 def slotChange(self):
00052 dialog = ServerConfigurationDialog( self )
00053 dialog.setDefault( str( self.uiServer.text() ) )
00054 dialog.exec_()
00055 self.uiServer.setText( dialog.url )
00056
00057 def slotAccept(self):
00058 if self.uiNewPassword.text() != self.uiConfirmationPassword.text():
00059 QMessageBox.warning(self, _('Validation Error'), _('Confirmation password does not match new password.') )
00060 return
00061 try:
00062 url = str(self.uiServer.text())
00063 old = str(self.uiOldPassword.text())
00064 new = str(self.uiNewPassword.text())
00065 Rpc.database.call(url, 'change_admin_password', old, new)
00066 QMessageBox.information(self, _('Information'), _('Password changed successfully') )
00067 self.accept()
00068 except Exception,e:
00069 QMessageBox.warning(self,_('Error'), _('Could not change administrator password. Please, check the server and password are correct.'))
00070