def exec_(self): if RaisePermissionsDialog.exec_(self) and self.passwords_match(): localsettings.SUPERVISOR = _hashed_input(self._new_password) db_settings.updateData("supervisor_pword", localsettings.SUPERVISOR, localsettings.operator) message = _("password changed successfully") else: message = _("Password unchanged") QtGui.QMessageBox.information(self, _("information"), message)
def initiate(changedServer=False, debug=False): # print "initiating settings" global message, dentDict, ops, SUPERVISOR, \ ops_reverse, activedents, activehygs, activedent_ixs, activehyg_ixs, \ apptix, apptix_reverse, bookEnd, clinicianNo, clinicianInits, WIKIURL from openmolar import connect from openmolar.dbtools import db_settings if changedServer and connect.mainconnection: print "closing connection" connect.mainconnection.close() reload(connect) data = db_settings.getData("bookend") if data: bookEndVals = data[-1][0].split(",") bookEnd = datetime.date(int(bookEndVals[0]), int(bookEndVals[1]), int(bookEndVals[2])) data = db_settings.getData("supervisor_pword") if data: SUPERVISOR = data[0][0] else: LOGGER.warning("#" * 30) LOGGER.warning( "WARNING - no supervisor password is set, restting to default") LOGGER.warning("#" * 30) db_settings.updateData("supervisor_pword", SUPERVISOR, "not found reset") db = connect.connect() cursor = db.cursor() # set up four lists with key/value pairs reversedto make for easy # referencing # first"ops" which is all practitioners ops = {} ops_reverse = {} apptix_reverse = {} cursor.execute("select id, inits, apptix from practitioners") practitioners = cursor.fetchall() for practitioner in practitioners: if practitioner[1] is not None: ops[practitioner[0]] = practitioner[1] ops_reverse[practitioner[1]] = practitioner[0] if practitioner[2] != 0: apptix_reverse[practitioner[2]] = practitioner[1] else: ops[0] = "NONE" ops_reverse["NONE"] = 0 try: # correspondence details for NHS forms query = ("select id,inits,name,formalname,fpcno,quals " "from practitioners where flag0=1") cursor.execute(query) practitioners = cursor.fetchall() dentDict = {} for practitioner in practitioners: dentDict[practitioner[0]] = practitioner[1:] # now get only practitioners who have an active daybook query = "select apptix,inits from practitioners where flag3=1" cursor.execute(query) practitioners = cursor.fetchall() apptix = {} for practitioner in practitioners: if practitioner[0] != 0 and practitioner[0] is not None: # apptix apptix[practitioner[1]] = practitioner[0] cursor.execute( "select apptix, inits from practitioners where flag3=1 and flag0=1" ) # dentists where appts active ixs, activedents = [], [] practitioners = cursor.fetchall() for ix, inits in practitioners: ixs.append(ix) activedents.append(inits) activedent_ixs = tuple(ixs) cursor.execute( "select apptix, inits from practitioners where flag3=1 and flag0=0" ) # hygenists where appts active practitioners = cursor.fetchall() ixs, activehygs = [], [] for ix, inits in practitioners: ixs.append(ix) activehygs.append(inits) activehyg_ixs = tuple(ixs) except Exception as exc: LOGGER.exception("error loading practitioners") #-- set the clinician if possible u1 = operator.split("/")[0].strip(" ") if u1 in activedents + activehygs: clinicianNo = ops_reverse.get(u1) clinicianInits = u1 else: LOGGER.debug("no clinician set!") getLocalSettings() WIKIURL = db_settings.getWikiUrl() message = ( '''<html><head> <link rel="stylesheet" href="%s" type="text/css"> </head><body><div align="center"> <img src="%s" width="150", height="100", align="left" /> <img src="%s" width="150", height="100", align="right" /> <h1>''' % (stylesheet, LOGOPATH, LOGOPATH) + _("Welcome to OpenMolar!") + '''</h1> <ul><li class="about">''' + _("Version") + ''' %s</li> <li class="about">''' % VERSION + '''</li></ul><br clear="all" /><p>''' + _("Your Data is Accessible, and the server reports no issues.") + '''</p><p>''' + _("Have a great day!") + '''</p></div></body></html>''') if debug: print "LOCALSETTINGS CALLED WITH DEBUG = TRUE" print "ops = ", ops print "ops_reverse = ", ops_reverse print "apptix = ", apptix print "apptix_reverse = ", apptix_reverse print "activedents =", activedents print "activehygs =", activehygs print "allowed logins =", allowed_logins print "stylesheet =", stylesheet print "referralfile = ", referralfile
def initiate(changedServer= False, debug = False): #print "initiating settings" global message, dentDict, ops, SUPERVISOR, \ ops_reverse, activedents, activehygs, activedent_ixs, activehyg_ixs, \ apptix, apptix_reverse, bookEnd, clinicianNo, clinicianInits, WIKIURL from openmolar import connect from openmolar.dbtools import db_settings if changedServer and connect.mainconnection: print "closing connection" connect.mainconnection.close() reload(connect) data = db_settings.getData("bookend") if data: bookEndVals = data[-1][0].split(",") bookEnd = datetime.date(int(bookEndVals[0]), int(bookEndVals[1]), int(bookEndVals[2])) data = db_settings.getData("supervisor_pword") if data: SUPERVISOR = data[0][0] else: LOGGER.warning("#"*30) LOGGER.warning( "WARNING - no supervisor password is set, restting to default") LOGGER.warning("#"*30) db_settings.updateData("supervisor_pword", SUPERVISOR, "not found reset") db = connect.connect() cursor = db.cursor() #set up four lists with key/value pairs reversedto make for easy referencing #first"ops" which is all practitioners ops = {} ops_reverse = {} apptix_reverse = {} cursor.execute("select id, inits, apptix from practitioners") practitioners = cursor.fetchall() for practitioner in practitioners: if practitioner[1] != None: ops[practitioner[0]] = practitioner[1] ops_reverse[practitioner[1]] = practitioner[0] if practitioner[2] != 0: apptix_reverse[practitioner[2]] = practitioner[1] else: ops[0] = "NONE" ops_reverse["NONE"] = 0 try: ##correspondence details for NHS forms query = ("select id,inits,name,formalname,fpcno,quals " "from practitioners where flag0=1") cursor.execute(query) practitioners = cursor.fetchall() dentDict = {} for practitioner in practitioners: dentDict[practitioner[0]] = practitioner[1:] #now get only practitioners who have an active daybook query = "select apptix,inits from practitioners where flag3=1" cursor.execute(query) practitioners = cursor.fetchall() apptix = {} for practitioner in practitioners: if practitioner[0] != 0 and practitioner[0] != None: #apptix apptix[practitioner[1]] = practitioner[0] cursor.execute( "select apptix, inits from practitioners where flag3=1 and flag0=1") #dentists where appts active ixs, activedents = [], [] practitioners = cursor.fetchall() for ix, inits in practitioners: ixs.append(ix) activedents.append(inits) activedent_ixs = tuple(ixs) cursor.execute( "select apptix, inits from practitioners where flag3=1 and flag0=0") #hygenists where appts active practitioners = cursor.fetchall() ixs, activehygs = [], [] for ix, inits in practitioners: ixs.append(ix) activehygs.append(inits) activehyg_ixs = tuple(ixs) except Exception as exc: LOGGER.exception("error loading practitioners") #-- set the clinician if possible u1 = operator.split("/")[0].strip(" ") if u1 in activedents + activehygs: clinicianNo = ops_reverse.get(u1) clinicianInits = u1 else: LOGGER.debug("no clinician set!") getLocalSettings() WIKIURL = db_settings.getWikiUrl() message = ('''<html><head> <link rel="stylesheet" href="%s" type="text/css"> </head><body><div align="center"> <img src="%s" width="150", height="100", align="left" /> <img src="%s" width="150", height="100", align="right" /> <h1>'''% (stylesheet, LOGOPATH, LOGOPATH) + _("Welcome to OpenMolar!")+ '''</h1> <ul><li class="about">''' + _("Version") + ''' %s</li> <li class="about">'''% VERSION + '''</li></ul><br clear="all" /><p>''' + _("Your Data is Accessible, and the server reports no issues.") + '''</p><p>''' + _("Have a great day!") + '''</p></div></body></html>''') if debug: print "LOCALSETTINGS CALLED WITH DEBUG = TRUE" print "ops = ", ops print "ops_reverse = ", ops_reverse print "apptix = ", apptix print "apptix_reverse = ", apptix_reverse print "activedents =", activedents print "activehygs =", activehygs print "allowed logins =", allowed_logins print "stylesheet =",stylesheet print "referralfile = ",referralfile