def writeToDB(self, arg): ''' user has entered a good sequence, so write it to the DB now ''' if self.buttonBox.buttonRole(arg) == ( QtGui.QDialogButtonBox.RejectRole): self.dialog.reject() return sdate = self.start_dateEdit.date() fdate = self.end_dateEdit.date() total = sdate.daysTo(fdate) start = localsettings.humanTimetoWystime( self.start_timeEdit.time().toString("h:mm")) end = localsettings.minutesPastMidnighttoWystime( localsettings.minutesPastMidnight(start) + self.spinBox.value()) self.progressBar.show() for clinician in self.clinicianDict.keys(): if self.clinicianDict[clinician].isChecked(): self.progress_label.setText("%s %s" % ( _("applying changes for"), clinician)) dt = sdate while dt <= fdate: progress = int(100 * (total - dt.daysTo(fdate)) / total) if self.progressBar.value() != progress: self.progressBar.setValue(progress) if self.dayDict[dt.dayOfWeek() - 1].isChecked(): appointments.make_appt(dt.toPyDate(), localsettings.apptix[clinician], start, end, self.lineEdit.text( ).toAscii(), 0, "", "", "", "", -128, 0, 0, 0) dt = dt.addDays(1) self.dialog.accept()
def apply(self): """ user has entered a good sequence, so write it to the DB now """ sdate = self.start_dateedit.date() fdate = self.end_dateedit.date() n_days = sdate.daysTo(fdate) start = localsettings.humanTimetoWystime(self.time_edit.time().toString("h:mm")) end = localsettings.minutesPastMidnighttoWystime( localsettings.minutesPastMidnight(start) + self.duration_spinbox.value() ) # print sdate, fdate, n_days, start, end p_dl = QtGui.QProgressDialog(self) p_dl.show() days = list(self.chosen_days) n_attempts, n_inserted = 0, 0 for clinician in self.chosen_clinicians: p_dl.setLabelText("%s %s" % (_("applying changes for"), clinician)) dt = sdate while dt <= fdate: progress = int(100 * (n_days - dt.daysTo(fdate)) / n_days) p_dl.setValue(progress) if dt.dayOfWeek() in days: n_attempts += 1 n_inserted += appointments.make_appt( dt.toPyDate(), localsettings.apptix[clinician], start, end, self.block_text, 0, "", "", "", "", -128, 0, 0, 0, ) dt = dt.addDays(1) message = "%d/%d %s" % (n_inserted, n_attempts, _("Appointment(s) inserted")) if n_inserted != n_attempts: message += "<hr />%s" % _( "Some were rejected by the database as they clashed" " with existing appointments or blocks" ) QtGui.QMessageBox.information(self, _("Information"), message)
def apply(self): ''' user has entered a good sequence, so write it to the DB now ''' sdate = self.start_dateedit.date() fdate = self.end_dateedit.date() n_days = sdate.daysTo(fdate) start = localsettings.humanTimetoWystime( self.time_edit.time().toString("h:mm")) end = localsettings.minutesPastMidnighttoWystime( localsettings.minutesPastMidnight(start) + self.duration_spinbox.value()) p_dl = QtGui.QProgressDialog(self) p_dl.show() days = list(self.chosen_days) n_attempts, n_inserted = 0, 0 for clinician in self.chosen_clinicians: p_dl.raise_() p_dl.setLabelText("%s %s" % (_("applying changes for"), clinician)) dt = sdate while dt <= fdate: progress = int(100 * (n_days - dt.daysTo(fdate)) / n_days) p_dl.setValue(progress) if dt.dayOfWeek() in days: n_attempts += 1 n_inserted += appointments.make_appt( dt.toPyDate(), localsettings.apptix[clinician], start, end, self.block_text, 0, "", "", "", "", -128, 0, 0, 0) dt = dt.addDays(1) QtGui.QApplication.instance().processEvents() message = "%d/%d %s" % (n_inserted, n_attempts, _("Appointment(s) inserted")) if n_inserted != n_attempts: message += \ "<hr /><b>%s</b>" % _( "Some were rejected by the database as they clashed" " with existing appointments or blocks") QtGui.QMessageBox.information(self, _("Information"), message)