def setCita(self): boolean = self.checkCita.checkState() if boolean: if self.__actuacion: guardar = True else: guardar = False nueva = NuevaCita(actuacion=self.__actuacion, cita=None, fecha=self.dteFechaProxima.dateTime(), parent=self, isGuardar=guardar) if nueva.exec_(): self.__cita = nueva.getCita() else: self.checkCita.setChecked(False) nueva.setParent(None) else: message = QtGui.QMessageBox() message.setIcon(QtGui.QMessageBox.Question) message.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) message.setDefaultButton(QtGui.QMessageBox.No) message.setText(u'¿Desea eliminar la cita?') if message.exec_() == QtGui.QMessageBox.Yes: if self.__actuacion: p = Persistence() p.borrarCitaCalendario(self.__cita) gestor = GestorCitas() gestor.actualizarCitas() self.__cita = None else: self.checkCita.setChecked(True) self.setActionCita()
def imprimirPersonas(self,tipo,personas=None): html = self.imprimirLogo() if tipo == 1: html += "<HEAD><TITLE>LISTA DE CLIENTES</TITLE></HEAD><BODY><FONT SIZE= '+2'><B>Lista de Clientes:</B></FONT><BR><BR>" if personas is None: p = Persistence() personas = p.consultarDemandantes() elif tipo == 2: html += "<HEAD><TITLE>LISTA DE CONTRAPARTES</TITLE></HEAD><BODY><FONT SIZE= '+2'><B>Lista de Contrapartes:</B></FONT><BR><BR>" if personas is None: p = Persistence() personas = p.consultarDemandados() else: raise Exception('el tipo de persona no existe') html += ("<TABLE BORDER =1 CELLSPACING = 0 WIDTH ='98%' ><TR><TH><B>Nombre</B></TH><TH><B>Cedula</B></TH><TH><B>Telefono</B></TH><TH><B>Direccion</B></TH><TH><B>Correo</B></TH><TH><B>Notas</B></TH></TR>") for persona in personas: if persona.getId_persona() != "1": html +=("<TR>") html = html + "<TD>"+ persona.getNombre() + "</TD>" html = html + "<TD>"+ persona.getId() + "</TD>" html = html + "<TD>"+ persona.getTelefono() + "</TD>" html = html + "<TD>"+ persona.getDireccion() + "</TD>" html = html + "<TD>"+ persona.getCorreo() + "</TD>" html = html + "<TD>"+ persona.getNotas() + "</TD>" html +=("</TR>") html +=("</TABLE></BODY>") return html
def __guardar(self): del(self.__dialogo) fecha = self.dteFecha.dateTime().toPython() fechaProxima = self.dteFechaProxima.dateTime().toPython() descripcion = self.txtDescripcion.text() if self.checkCita.isChecked(): cita = self.__cita else: cita = None if not self.__actuacion: self.__actuacion = Actuacion(juzgado=self.__juzgado, fecha=fecha, fechaProxima=fechaProxima, descripcion=descripcion, campos=self.__gestor.getCampos()) else: if self.__actuacion.getId_actuacion() is not None: camposNuevos = self.__gestor.getCamposNuevos() camposEliminados = self.__gestor.getCamposEliminados() try: p = Persistence() for campo in camposEliminados: p.borrarCampoActuacion(campo) for campo in camposNuevos: p.guardarCampoActuacion(campo, self.__actuacion.getId_actuacion()) except Exception, e: print "guardar actuación -> " % e.args self.__actuacion.setDescripcion(descripcion) self.__actuacion.setFecha(fecha) self.__actuacion.setFechaProxima(fechaProxima) self.__actuacion.setCampos(self.__gestor.getCampos()) self.__actuacion.setJuzgado(self.__juzgado)
def __cargarCitas(self): try: p = Persistence() citas = sorted(p.consultarCitasCalendario(), self.__compararCitas) self.__calendar.setCitas(citas) return citas except Exception as e: print e
def __guardar(self): if hasattr(self, '__dialogo'): del(self.__dialogo) guardar = True self.organizarActuaciones() p = Persistence() demandante = self.__demandante demandado = self.__demandado fecha = self.dteFecha.dateTime().toPython() juzgado = self.__juzgado radicado = self.txtRadicado.text() radicadoUnico = self.txtRadicadoUnico.text() actuaciones = self.__actuaciones estado = self.txtEstado.text() categoria = self.__categoria tipo = self.txtTipo.text() notas = self.txtNotas.toPlainText() prioridad = self.sbPrioridad.value() campos = self.__gestor.getCampos() if self.__proceso is None: proceso = Proceso(demandante=demandante, demandado=demandado, fecha=fecha, juzgado=juzgado, radicado=radicado, radicadoUnico=radicadoUnico, actuaciones=actuaciones, estado=estado, categoria=categoria, tipo=tipo, notas=notas, prioridad=prioridad, campos=campos) else: camposNuevos = self.__gestor.getCamposNuevos() camposEliminados = self.__gestor.getCamposEliminados() for campo in camposEliminados: p.borrarCampoPersonalizado(campo) for campo in camposNuevos: p.guardarCampoPersonalizado(campo, self.__proceso.getId_proceso()) self.__proceso.setDemandante(demandante) self.__proceso.setDemandado(demandado) self.__proceso.setFecha(fecha) self.__proceso.setJuzgado(juzgado) self.__proceso.setRadicado(radicado) self.__proceso.setRadicadoUnico(radicadoUnico) self.__proceso.setActuaciones(actuaciones) self.__proceso.setEstado(estado) self.__proceso.setCategoria(categoria) self.__proceso.setTipo(tipo) self.__proceso.setNotas(notas) self.__proceso.setPrioridad(prioridad) self.__proceso.setCampos(campos) guardar = False try: p = Persistence() if guardar: p.guardarProceso(proceso) self.__proceso = proceso else: p.actualizarProceso(self.__proceso) self.guardarCitas(actuaciones) except sqlite3.IntegrityError: QtGui.QMessageBox.information(self, 'Error', 'El elemento ya existe') else: return QtGui.QDialog.accept(self)
def borrarPreferencias(self): p = Persistence() p.borrarPreferencias() self.__correo = "" self.__correoNotificacion = "" self.__cantidadEventos = 10 self.__tipoAlarma = 1 self.__llave = 0 self.__version = 1 self.__ultimaSinc = 0
def exportarActuacionesCSV(archivo, proceso, tab=False): if tab: writer = csv.writer(open(archivo,'wb'), dialect='excel-tab') else: writer = csv.writer(open(archivo,'wb'), dialect='excel') if not isinstance(proceso, Proceso): proceso = Persistence().consultarProceso(proceso) actuaciones = proceso.getActuaciones() writer.writerow(Actuacion.getHeaders()) csvActuaciones = [actuacion.toCSV() for actuacion in actuaciones] writer.writerows(csvActuaciones)
def __guardar(self): if hasattr(self, '__dialogo'): del(self.__dialogo) guardar = True p = Persistence() nombre = self.txtNombre.text() demandante = self.__demandante demandado = self.__demandado juzgado = self.__juzgado radicado = self.txtRadicado.text() radicadoUnico = self.txtRadicadoUnico.text() estado = self.txtEstado.text() categoria = self.__categoria tipo = self.txtTipo.text() notas = self.txtNotas.toPlainText() prioridad = self.sbPrioridad.value() campos = self.__gestor.getCampos() if not self.__plantilla: plantilla = Plantilla(nombre = nombre, demandante = demandante, demandado = demandado, juzgado = juzgado, radicado = radicado, radicadoUnico = radicadoUnico, estado = estado, categoria = categoria, tipo = tipo, notas = notas, campos = campos, prioridad = prioridad) else: camposNuevos = self.__gestor.getCamposNuevos() camposEliminados = self.__gestor.getCamposEliminados() for campo in camposEliminados: p.borrarCampoPersonalizado(campo) for campo in camposNuevos: p.guardarCampoPersonalizado(campo, self.__plantilla.getId_proceso()) self.__plantilla.setNombre(nombre) self.__plantilla.setDemandante(demandante) self.__plantilla.setDemandado(demandado) self.__plantilla.setJuzgado(juzgado) self.__plantilla.setRadicado(radicado) self.__plantilla.setRadicadoUnico(radicadoUnico) self.__plantilla.setEstado(estado) self.__plantilla.setCategoria(categoria) self.__plantilla.setTipo(tipo) self.__plantilla.setNotas(notas) self.__plantilla.setPrioridad(prioridad) self.__plantilla.setCampos(campos) guardar = False try: if guardar: Persistence().guardarPlantilla(plantilla) self.__plantilla = plantilla else: Persistence().actualizarPlantilla(self.__plantilla) except sqlite3.IntegrityError: QtGui.QMessageBox.information(self, 'Error', 'El elemento ya existe') else: return QtGui.QDialog.accept(self)
def guardarEnBD(self): try: p = Persistence() if self.cita.getId_cita() == None: p.guardarCitaCalendario(self.cita) else: p.actualizarCitaCalendario(self.cita) return QtGui.QDialog.accept(self) gestor = GestorCitas() gestor.actualizarCitas() except Exception, e: print e return QtGui.QDialog.reject(self)
def guardarCitas(self, actuaciones): p = Persistence() gestor = GestorCitas() for actuacion in actuaciones: if hasattr(actuacion, 'cita'): if actuacion.cita: cita = actuacion.cita cita.setId_actuacion(actuacion.getId_actuacion()) if not cita.getId_cita(): p.guardarCitaCalendario(cita) else: p.actualizarCitaCalendario(cita) gestor.actualizarCitas()
def organizarActuaciones(self): if self.__proceso is not None: actuacionesOriginales = self.__proceso.getActuaciones() actuaciones = self.__actuaciones try: p = Persistence() for nuevaActuacion in actuaciones: if nuevaActuacion not in actuacionesOriginales: p.guardarActuacion(nuevaActuacion, self.__proceso.getId_proceso()) for viejaActuacion in actuacionesOriginales: if viejaActuacion not in actuaciones: p.borrarActuacion(viejaActuacion) except Exception, e: print "organizarActuaciones -> %s" % e
def imprimirEventosProximos(self): cantidad = QInputDialog.getInt(None,'Ingrese un valor','Ingrese la cantidad de eventos proximos a imprimir') if cantidad[1] == True: html = self.imprimirLogo() html +=("<HEAD><TITLE>EVENTOS PROXIMOS </TITLE></HEAD><BODY><FONT SIZE='+2'><B>Eventos Proximos: </B></FONT><BR><BR>") html += ("<TABLE BORDER =1 CELLSPACING = 0 WIDTH ='95%' ><TR><TH><B>Descripcion</B></TH><TH><B>Juzgado</B></TH><TH><B>Fecha Proxima</B></TH><TH><B>Fecha de creacion</B></TH></TR>") p = Persistence() actuaciones = p.consultarActuacionesCriticas(cantidad[0]) for actuacion in actuaciones: html +=("<TR>") html = html + "<TD>"+ actuacion.getDescripcion() + "</TD>" html = html + "<TD>"+ actuacion.getJuzgado().getNombre() + "</TD>" html = html + "<TD>"+ '{:%d-%m-%Y}'.format(actuacion.getFechaProxima()) + "</TD>" html = html + "<TD>"+ '{:%d-%m-%Y}'.format(actuacion.getFecha()) + "</TD>" html +=("</TR>") html +=("</TABLE></BODY>") return html
def imprimirJuzgados(self, juzgados=None): html = self.imprimirLogo() html +=("<HEAD><TITLE>LISTA JUZGADOS </TITLE></HEAD><BODY><FONT SIZE='+2'><B>Lista de Juzgados: </B></FONT><BR><BR>") html += ("<TABLE BORDER =1 CELLSPACING = 0 WIDTH ='98%' ><TR><TH><B>Nombre</B></TH><TH><B>Telefono</B></TH><TH><B>Direccion</B></TH><TH><B>Ciudad</B></TH><TH><B>Tipo</B></TH></TR>") if juzgados is None: p = Persistence() juzgados = p.consultarJuzgados() for juzgado in juzgados: if juzgado.getId_juzgado() != "1": html +=("<TR>") html = html + "<TD>"+ juzgado.getNombre() + "</TD>" html = html + "<TD>"+ juzgado.getTelefono() + "</TD>" html = html + "<TD>"+ juzgado.getDireccion() + "</TD>" html = html + "<TD>"+ juzgado.getCiudad() + "</TD>" html = html + "<TD>"+ juzgado.getTipo() + "</TD>" html +=("</TR>") html +=("</TABLE></BODY>") return html
def __cargarCitas(self): try: p = Persistence() citas = p.consultarCitasCalendario() citas = sorted(citas, self.__compararCitas) for cita in citas: if cita.isAlarma() and cita.getFecha() - timedelta(0, cita.getAnticipacion()) > datetime.today(): timer = QtCore.QTimer(self.parent) timer.setSingleShot(True) timer.timeout.connect(self.__seCumpleCita) delta = cita.getFecha() - datetime.today() tiempo = (delta.total_seconds() - cita.getAnticipacion()) * 1000 #print 'Cita: '+ cita.getDescripcion() + '\n Anticipación: ' + unicode(tiempo) self.citas.append(cita) timer.start(tiempo) self.timer.append(timer) except Exception as e: print e
def __guardar(self): guardar = True p = Persistence() if self.__categoria is None: categoria = Categoria() categoria.setDescripcion(self.txtCategoria.text()) self.__categoria = categoria else: self.__categoria.setDescripcion(self.txtCategoria.text()) guardar = False try: if guardar: p.guardarCategoria(categoria) else: p.actualizarCategoria(self.__categoria) except sqlite3.IntegrityError: if guardar: self.__categoria = None QMessageBox.information(self, 'Error', 'El elemento ya existe') else: return QDialog.accept(self)
def imprimirActuaciones(self,proceso= None ,actuaciones=None): if actuaciones is None: html = self.imprimirLogo() p = Persistence() actuaciones = p.consultarActuaciones(proceso) html +=("<HEAD><TITLE>LISTA DE ACTUACIONES </TITLE></HEAD><BODY><FONT SIZE='+2'><B>Lista de Actuaciones: </B></FONT><BR><BR>") else: html =("<HEAD><TITLE>LISTA DE ACTUACIONES </TITLE></HEAD><BODY><FONT SIZE='+2'><B>Lista de Actuaciones: </B></FONT><BR><BR>") html += ("<TABLE BORDER =1 CELLSPACING = 0 WIDTH ='98%' ><TR><TH><B>Descripcion</B></TH><TH><B>Juzgado</B></TH><TH><B>Fecha Proxima</B></TH><TH><B>Fecha de creacion</B></TH></TR>") for actuacion in actuaciones: html +=("<TR>") html = html + "<TD>"+ actuacion.getDescripcion() + "</TD>" html = html + "<TD>"+ actuacion.getJuzgado().getNombre() + "</TD>" html = html + "<TD>"+ '{:%d-%m-%Y}'.format(actuacion.getFechaProxima()) + "</TD>" html = html + "<TD>"+ '{:%d-%m-%Y}'.format(actuacion.getFecha()) + "</TD>" html +=("</TR>") html +=("</TABLE></BODY>") return html
def __eliminar(self): message = QtGui.QMessageBox() message.setIcon(QtGui.QMessageBox.Question) message.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) message.setDefaultButton(QtGui.QMessageBox.No) message.setText(u"¿Desea eliminar la cita?") ret = message.exec_() if ret == QtGui.QMessageBox.Yes: if self.tabWidget.currentIndex() == 0: cita = self.lista.currentItem().getObjeto() elif self.tabWidget.currentIndex() == 1: cita = self.lista2.currentItem().getObjeto() else: cita = self.lista3.currentItem().getObjeto() try: p = Persistence() p.borrarCitaCalendario(cita) self.__citas.remove(cita) self.__redibujar() except Exception as e: print e
def __clickEliminar(self): items = self.lista3.selectedItems() if len(items) != 0: message = QtGui.QMessageBox() message.setIcon(QtGui.QMessageBox.Question) message.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) message.setDefaultButton(QtGui.QMessageBox.No) message.setText(u'¿Desea eliminar las citas seleccionadas?') ret = message.exec_() if ret == QtGui.QMessageBox.Yes: p = Persistence() for item in items: p.borrarCitaCalendario(item.getObjeto()) self.__citas.remove(item.getObjeto()) self.__redibujar() else: message = QtGui.QMessageBox() message.setIcon(QtGui.QMessageBox.Question) message.setStandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) message.setDefaultButton(QtGui.QMessageBox.No) message.setText(u"¿Desea eliminar todas las citas vencidas?") ret = message.exec_() if ret == QtGui.QMessageBox.Yes: p = Persistence() while self.lista3.count() > 0: item = self.lista3.takeItem(0) p.borrarCitaCalendario(item.getObjeto()) self.__citas.remove(item.getObjeto()) self.__redibujar()
class DesactivarApp(object): def __init__(self, carpeta, parent = None): self.__persistence = Persistence(carpeta) self.parent = parent def desactivarAplicacion(self): confirmar = QtGui.QMessageBox.question(self.parent, u"Confirmar desactivación", u"Si procede no podrá utilizar la aplicación. ¿Seguro que desea desactivar la aplicación?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if confirmar == QtGui.QMessageBox.Yes: self.dialogo = DialogoEspera() try: correo = self.__persistence.consultarPreferencia(10402) except: QtGui.QMessageBox.warning(self.parent, "Error", u"Ha ocurrido un problema desactivando la aplicación. Por favor vuelva a intentar.\nSi el problema persiste contacte a [email protected]") self.hilo = HiloActivacion() self.hilo.correo = correo self.hilo.pet = 'desactivar' self.hilo.finished.connect(self.hiloTerminado) self.dialogo = DialogoEspera() try: self.hilo.start() self.dialogo.exec_() except: QtGui.QMessageBox.warning(self.parent, "Error", u"Ha ocurrido un problema verificando la activación de la aplicación, esta se cerrará. Por favor vuelva a iniciarla.\nSi el problema persiste contacte a [email protected]") sys.exit(0) if self.flag: try: self.__persistence.actualizarPreferencia(998, 0) except Exception as e: QtGui.QMessageBox.warning(self.parent, "Error", u"Ha ocurrido un problema desactivando la aplicación. Por favor vuelva a intentar.\nSi el problema persiste contacte a [email protected]") print e sys.exit(0) def hiloTerminado(self): try: QtGui.QMessageBox.warning(self.parent,"Info", self.hilo.respuesta) except: QtGui.QMessageBox.warning(self.parent, "Error", "Ha ocurrido un error de red indeterminado Por favor verifique su conexión a internet e intente de nuevo. Si el problema persiste por favor comuníquese con nuestro personal de soporte técnico: [email protected]") self.flag = self.hilo.flag self.dialogo.hide()
def imprimirProcesos(self,procesos=None): html = self.imprimirLogo() html +=("<HEAD><TITLE>LISTA DE PROCESOS </TITLE></HEAD><BODY><FONT SIZE='+2'><B>Lista de Procesos: </B></FONT><BR><BR>") html += ("<TABLE BORDER =1 CELLSPACING = 0 WIDTH ='98%'><TR><TH>Radicado</TH><TH>Radicado Unico</TH><TH>Cliente</TH><TH>Contraparte</TH><TH>Juzgado</TH><TH>Fecha</TH><TH>Estado</TH><TH>Categoria</TH><TH>Tipo</TH><TH>Notas</TH>") if procesos is None: p = Persistence() procesos = p.consultarProcesos() for proceso in procesos: html +=("<TR>") html = html + "<TD>"+ proceso.getRadicado() + "</TD>" html = html + "<TD>"+ proceso.getRadicadoUnico() + "</TD>" html = html + "<TD>"+ proceso.getDemandante().getNombre() + "</TD>" html = html + "<TD>"+ proceso.getDemandado().getNombre() + "</TD>" html = html + "<TD>"+ proceso.getJuzgado().getNombre() + "</TD>" html = html + "<TD>"+ '{:%d-%m-%Y}'.format(proceso.getFecha()) + "</TD>" html = html + "<TD>"+ proceso.getEstado() + "</TD>" html = html + "<TD>"+ proceso.getCategoria().getDescripcion() + "</TD>" html = html + "<TD>"+ proceso.getTipo() + "</TD>" html = html + "<TD>"+ proceso.getNotas() + "</TD>" html +=("</TR>") html +=("</TABLE></BODY>") return html
def __guardar(self): guardar = True p = Persistence() nombre = self.txtNombre.text() direccion = self.txtDireccion.text() telefono = self.txtTelefono.text() ciudad = self.txtCiudad.text() tipo = self.txtTipo.text() campos = self.__gestor.getCampos() if not self.__juzgado: self.__juzgado = Juzgado(nombre=nombre, ciudad=ciudad, direccion=direccion, telefono=telefono, tipo=tipo, campos=campos) else: camposNuevos = self.__gestor.getCamposNuevos() camposEliminados = self.__gestor.getCamposEliminados() for campo in camposEliminados: p.borrarCampoJuzgado(campo) for campo in camposNuevos: p.guardarCampoJuzgado(campo, self.__juzgado.getId_juzgado()) self.__juzgado.setNombre(nombre) self.__juzgado.setDireccion(direccion) self.__juzgado.setCiudad(ciudad) self.__juzgado.setTelefono(telefono) self.__juzgado.setTipo(tipo) self.__juzgado.setCampos(campos) guardar = False try: if guardar: p.guardarJuzgado(self.__juzgado) else: p.actualizarJuzgado(self.__juzgado) except sqlite3.IntegrityError: if guardar: self.__juzgado = None QtGui.QMessageBox.information(self, 'Error', 'El elemento ya existe') else: return QtGui.QDialog.accept(self)
def __init__(self): self.p = Persistence() preferencias = self.p.consultarPreferencias() for llaveD, valor in preferencias.iteritems(): # consultar Preferencias: correo if llaveD == self.CORREO: self.__correo = valor # consultar Preferencias: Cantidad Eventos Proximos elif llaveD == self.CANTIDAD_EVENTOS: self.__cantidadEventos = valor # consultar Preferencias: Tipo Alarma es un valor binario, primer bit mensaje emergente, segundo bit ,emsaje en icono de notificación, tercer bit correo electrónico elif llaveD == self.TIPO_ALARMA: self.__tipoAlarma = valor # consultar Preferencias: llave elif llaveD == self.LLAVE: self.__llave = valor # consultar Preferencias: Version elif llaveD == self.VERSION: self.__version = valor # consultar Preferencias: Ultima sincronizacion elif llaveD == self.ULTIMA_SINC: self.__ultimaSinc = valor elif llaveD == self.CORREO_NOTIFICACION: self.__correoNotificacion = valor
def __guardar(self): guardar = True p = Persistence() if self.__campo is None: campo = CampoPersonalizado(self.txtNombre.text()) campo.setLongitudMax(self.sbLongMax.value()) campo.setLongitudMin(self.sbLongMin.value()) campo.setObligatorio(self.cbObligatorio.isChecked()) self.__campo = campo else: self.__campo.setNombre(self.txtNombre.text()) self.__campo.setLongitudMax(self.sbLongMax.value()) self.__campo.setLongitudMin(self.sbLongMin.value()) self.__campo.setObligatorio(self.cbObligatorio.isChecked()) guardar = False try: if guardar: if self.__tipo is self.__class__.PERSONA: p.guardarAtributoPersona(campo) elif self.__tipo is self.__class__.JUZGADO: p.guardarAtributoJuzgado(campo) elif self.__tipo is self.__class__.ACTUACION: p.guardarAtributoActuacion(campo) elif self.__tipo is self.__class__.PROCESO: p.guardarAtributo(campo) else: if self.__tipo is self.__class__.PERSONA: p.actualizarAtributoPersona(self.__campo) elif self.__tipo is self.__class__.JUZGADO: p.actualizarAtributoJuzgado(self.__campo) elif self.__tipo is self.__class__.ACTUACION: p.actualizarAtributoActuacion(self.__campo) elif self.__tipo is self.__class__.PROCESO: p.actualizarAtributo(self.__campo) except sqlite3.IntegrityError: if guardar: self.__campo = None QtGui.QMessageBox.information(self, 'Error', 'El elemento ya existe') else: return QtGui.QDialog.accept(self)
def __init__(self, tipo, parent = None): super(ListadoDialogoMultipleSeleccion, self).__init__(parent) self.__tipo = tipo self.__p = Persistence() self.__editado = [] self.__eliminado = [] self.__agregado = [] if self.__tipo is self.__class__.DEMANDANTE: objetos = self.__p.consultarDemandantes() self.setWindowTitle('Seleccionar Demandantes') elif self.__tipo is self.__class__.DEMANDADO: objetos = self.__p.consultarDemandados() self.setWindowTitle('Seleccionar Demandados') elif self.__tipo is self.__class__.JUZGADO: objetos = self.__p.consultarJuzgados() self.setWindowTitle('Seleccionar Juzgados') elif self.__tipo is self.__class__.CATEGORIA: objetos = self.__p.consultarCategorias() self.setWindowTitle(u'Seleccionar categorías') elif self.__tipo is self.__class__.CAMPOPROCESOP: objetos = self.__p.consultarAtributos() self.setWindowTitle('Seleccione campos') elif self.__tipo is self.__class__.CAMPOJUZGADO: objetos = self.__p.consultarAtributosJuzgado() self.setWindowTitle('Seleccione campos') elif self.__tipo is self.__class__.CAMPOACTUACION: objetos = self.__p.consultarAtributosActuacion() self.setWindowTitle('Seleccione campos') elif self.__tipo is self.__class__.CAMPODEMANDANTE: objetos = self.__p.consultarAtributosPersona() self.setWindowTitle('Seleccione campos') elif self.__tipo is self.__class__.CAMPODEMANDADO: objetos = self.__p.consultarAtributosPersona() self.setWindowTitle('Seleccione campos') elif self.__tipo is self.__class__.PROCESO: objetos = self.__p.consultarProcesos() self.setWindowTitle('Seleccione procesos') elif self.__tipo is self.__class__.PLANTILLA: objetos = self.__p.consultarPlantillas() self.setWindowTitle('Seleccione plantillas') groupBox = QGroupBox("Seleccione uno o varios elementos") self.lista = ListadoBusqueda(objetos) self.lista.setSelectionMode(QListWidget.MultiSelection) layout = QVBoxLayout() layoutBox = QVBoxLayout() btnSelTodo = QPushButton("Seleccionar Todo") self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) buttonlayout = QHBoxLayout() buttonlayout.addStretch() layout.addWidget(self.lista.getSearchField()) layout.addWidget(self.lista) buttonlayout.addWidget(btnSelTodo) buttonlayout.addWidget(self.buttonBox) groupBox.setLayout(layout) layoutBox.addWidget(groupBox) layoutBox.addLayout(buttonlayout) self.setLayout(layoutBox) self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept) self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject) self.connect(btnSelTodo, SIGNAL("clicked()"), self.selTodo)
class ListadoDialogo (QtGui.QDialog): DEMANDANTE = 1 DEMANDADO = 2 JUZGADO = 3 CATEGORIA = 4 CAMPOPROCESOP = 5 # constante que indica el campo personalizado de procesos y plantillas CAMPOJUZGADO = 6 CAMPOACTUACION = 7 CAMPODEMANDANTE = 8 CAMPODEMANDADO = 9 PROCESO = 10 PLANTILLA = 11 ACTUACION = 12 def __init__(self, tipo, parent = None, proceso = None): super(ListadoDialogo, self).__init__(parent) self.__tipo = tipo self.__proceso = proceso self.__p = Persistence() self.__editado = [] self.__eliminado = [] self.__agregado = [] if self.__tipo is self.__class__.DEMANDANTE: objetos = self.__p.consultarDemandantes() self.setWindowTitle('Seleccionar Demandante') elif self.__tipo is self.__class__.DEMANDADO: objetos = self.__p.consultarDemandados() self.setWindowTitle('Seleccionar Demandado') elif self.__tipo is self.__class__.JUZGADO: objetos = self.__p.consultarJuzgados() self.setWindowTitle('Seleccionar Juzgado') elif self.__tipo is self.__class__.CATEGORIA: objetos = self.__p.consultarCategorias() self.setWindowTitle(u'Seleccionar categoría') elif self.__tipo is self.__class__.CAMPOPROCESOP: objetos = self.__p.consultarAtributos() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPOJUZGADO: objetos = self.__p.consultarAtributosJuzgado() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPOACTUACION: objetos = self.__p.consultarAtributosActuacion() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPODEMANDANTE: objetos = self.__p.consultarAtributosPersona() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPODEMANDADO: objetos = self.__p.consultarAtributosPersona() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.PROCESO: objetos = self.__p.consultarProcesos() self.setWindowTitle('seleccione un proceso') elif self.__tipo is self.__class__.PLANTILLA: objetos = self.__p.consultarPlantillas() self.setWindowTitle('Seleccione una plantilla') elif self.__tipo is self.ACTUACION: if proceso: self.setWindowTitle(u'Seleccione una actuación') objetos = self.__p.consultarActuaciones(proceso) else: raise AttributeError('Proceso no puede ser None') groupBox = QtGui.QGroupBox("Seleccione un elemento") self.lista = ListadoBusqueda(objetos) btnAgregar = QtGui.QPushButton('+') layout = QtGui.QVBoxLayout() layoutBox = QtGui.QVBoxLayout() buttonlayout = QtGui.QHBoxLayout() buttonlayout.addStretch() layout.addWidget(self.lista.getSearchField()) layout.addWidget(self.lista) buttonlayout.addWidget(btnAgregar) groupBox.setLayout(layout) layoutBox.addWidget(groupBox) layoutBox.addLayout(buttonlayout) self.setLayout(layoutBox) self.lista.itemClicked.connect(self.click) #self.connect(btnAgregar, SIGNAL("clicked()"), self.button) btnAgregar.clicked.connect(self.button) self.lista.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) actionEliminar = self.__createAction("Eliminar", self.eliminar) actionAgregar = self.__createAction("Agregar", self.button) actionEditar = self.__createAction("Editar", self.editar) self.lista.addAction(actionEliminar) self.lista.addAction(actionAgregar) self.lista.addAction(actionEditar) def click(self, item): self.selected = item.getObjeto() self.accept() def getSelected(self): return self.selected def button(self): from gui.nuevo.NuevoJuzgado import NuevoJuzgado from gui.nuevo.NuevaPersona import NuevaPersona from gui.nuevo.NuevaCategoria import NuevaCategoria from gui.nuevo.NuevoCampo import NuevoCampo from gui.nuevo.NuevoProceso import NuevoProceso from gui.nuevo.NuevaPlantilla import NuevaPlantilla from gui.nuevo.NuevaActuacion import NuevaActuacion if self.__tipo is self.__class__.DEMANDANTE: nuevaPersona = NuevaPersona(tipo = 1 , parent = self) if nuevaPersona.exec_(): demandante = nuevaPersona.getPersona() self.lista.add(demandante) self.__agregado.append(demandante) elif self.__tipo is self.__class__.DEMANDADO: nuevaPersona = NuevaPersona(tipo = 2, parent = self) if nuevaPersona.exec_(): demandado = nuevaPersona.getPersona() self.lista.add(demandado) self.__agregado.append(demandado) elif self.__tipo is self.__class__.JUZGADO: nuevoJuzgado = NuevoJuzgado(parent = self) if nuevoJuzgado.exec_(): juzgado = nuevoJuzgado.getJuzgado() self.lista.add(juzgado) self.__agregado.append(juzgado) elif self.__tipo is self.__class__.CATEGORIA: nuevaCategoria = NuevaCategoria(parent = self) if nuevaCategoria.exec_(): categoria = nuevaCategoria.getCategoria() self.lista.add(categoria) self.__agregado.append(categoria) elif self.__tipo is self.__class__.CAMPODEMANDANTE: nuevoCampoDemandante = NuevoCampo(tipo = NuevoCampo.PERSONA, parent = self) if nuevoCampoDemandante.exec_(): campoPersona = nuevoCampoDemandante.getCampo() self.lista.add(campoPersona) self.__agregado.append(campoPersona) elif self.__tipo is self.__class__.CAMPODEMANDADO: nuevoCampoDemandado = NuevoCampo(tipo = NuevoCampo.PERSONA, parent = self) if nuevoCampoDemandado.exec_(): campoPersona = nuevoCampoDemandado.getCampo() self.lista.add(campoPersona) self.__agregado.append(campoPersona) elif self.__tipo is self.__class__.CAMPOACTUACION: nuevoCampoActuacion = NuevoCampo(tipo = NuevoCampo.ACTUACION, parent = self) if nuevoCampoActuacion.exec_(): campoActuacion = nuevoCampoActuacion.getCampo() self.lista.add(campoActuacion) self.__agregado.append(campoActuacion) elif self.__tipo is self.__class__.CAMPOPROCESOP: nuevoCampoPP = NuevoCampo(tipo = NuevoCampo.PROCESO, parent = self) if nuevoCampoPP.exec_(): campoPP = nuevoCampoPP.getCampo() self.lista.add(campoPP) self.__agregado.append(campoPP) elif self.__tipo is self.__class__.CAMPOJUZGADO: nuevoCampoJuzgado = NuevoCampo(tipo = NuevoCampo.JUZGADO, parent = self) if nuevoCampoJuzgado.exec_(): campoJuzgado = nuevoCampoJuzgado.getCampo() self.lista.add(campoJuzgado) self.__agregado.append(campoJuzgado) elif self.__tipo is self.__class__.PROCESO: nuevoProceso = NuevoProceso(parent=self) if nuevoProceso.exec_(): proceso = nuevoProceso.getProceso() self.lista.add(proceso) self.__agregado.append(proceso) elif self.__tipo is self.__class__.PLANTILLA: nuevaPlantilla = NuevaPlantilla(parent=self) if nuevaPlantilla.exec_(): plantilla = nuevaPlantilla.getPlantilla() self.lista.add(plantilla) self.__agregado.append(plantilla) elif self.__tipo is self.ACTUACION: nuevaActuacion = NuevaActuacion(parent=self) if nuevaActuacion.exec_(): actuacion = nuevaActuacion.getActuacion() self.__p.guardarActuacion(actuacion, self.__proceso.getId_proceso()) self.lista.add(actuacion) self.__agregado.append(actuacion) def __createAction(self, text, slot = None, signal = "triggered()"): action = QtGui.QAction(text, self) if slot is not None: self.connect(action, QtCore.SIGNAL(signal), slot) return action def eliminar(self): objeto = self.lista.currentItem().getObjeto() if self.__tipo is self.__class__.DEMANDANTE: self.__p.borrarPersona(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.DEMANDADO: self.__p.borrarPersona(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.JUZGADO: self.__p.borrarJuzgado(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.CATEGORIA: self.__p.borrarCategoria(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.CAMPODEMANDANTE: self.__p.borrarCampoDemandante(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.CAMPODEMANDADO: self.__p.borrarCampoDemandado(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.CAMPOACTUACION: self.__p.borrarCampoActuacion(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.CAMPOPROCESOP: self.__p.borrarCampoPersonalizado(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.CAMPOJUZGADO: self.__p.borrarCampoJuzgado(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.PROCESO: self.__p.borrarProceso(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.__class__.PLANTILLA: self.__p.borrarPlantilla(objeto) self.__eliminado.append(objeto) elif self.__tipo is self.ACTUACION: self.__p.borrarActuacion(objeto) self.__eliminado.append(objeto) self.lista.remove() def editar(self): from gui.nuevo.NuevoJuzgado import NuevoJuzgado from gui.nuevo.NuevaPersona import NuevaPersona from gui.nuevo.NuevaCategoria import NuevaCategoria from gui.nuevo.NuevoCampo import NuevoCampo from gui.nuevo.NuevoProceso import NuevoProceso from gui.nuevo.NuevaPlantilla import NuevaPlantilla from gui.nuevo.NuevaActuacion import NuevaActuacion if self.__tipo is self.__class__.DEMANDANTE: nuevaPersona = NuevaPersona(persona = self.lista.currentItem().getObjeto(), tipo = 1 , parent = self) if nuevaPersona.exec_(): demandante = nuevaPersona.getPersona() self.lista.replace(demandante) self.__editado.append(demandante) elif self.__tipo is self.__class__.DEMANDADO: nuevaPersona = NuevaPersona(persona = self.lista.currentItem().getObjeto(), tipo = 2, parent = self) if nuevaPersona.exec_(): demandado = nuevaPersona.getPersona() self.lista.replace(demandado) self.__editado.append(demandado) elif self.__tipo is self.__class__.JUZGADO: nuevoJuzgado = NuevoJuzgado(juzgado = self.lista.currentItem().getObjeto(), parent = self) if nuevoJuzgado.exec_(): juzgado = nuevoJuzgado.getJuzgado() self.lista.replace(juzgado) self.__editado.append(juzgado) elif self.__tipo is self.__class__.CATEGORIA: nuevaCategoria = NuevaCategoria(categoria = self.lista.currentItem().getObjeto(), parent = self) if nuevaCategoria.exec_(): categoria = nuevaCategoria.getCategoria() self.lista.replace(categoria) self.__editado.append(categoria) elif self.__tipo is self.__class__.CAMPODEMANDANTE: nuevoCampoDemandante = NuevoCampo(tipo = NuevoCampo.PERSONA, campo = self.lista.currentItem().getObjeto(), parent = self) if nuevoCampoDemandante.exec_(): campoPersona = nuevoCampoDemandante.getCampo() self.lista.replace(campoPersona) self.__editado.append(campoPersona) elif self.__tipo is self.__class__.CAMPODEMANDADO: nuevoCampoDemandado = NuevoCampo(tipo = NuevoCampo.PERSONA, campo = self.lista.currentItem().getObjeto(), parent = self) if nuevoCampoDemandado.exec_(): campoPersona = nuevoCampoDemandado.getCampo() self.lista.replace(campoPersona) self.__editado.append(campoPersona) elif self.__tipo is self.__class__.CAMPOACTUACION: nuevoCampoActuacion = NuevoCampo(tipo = NuevoCampo.ACTUACION, campo = self.lista.currentItem().getObjeto(), parent = self) if nuevoCampoActuacion.exec_(): campoActuacion = nuevoCampoActuacion.getCampo() self.lista.replace(campoActuacion) self.__editado.append(campoActuacion) elif self.__tipo is self.__class__.CAMPOPROCESOP: nuevoCampoPP = NuevoCampo(tipo = NuevoCampo.PROCESO, campo = self.lista.currentItem().getObjeto(), parent = self) if nuevoCampoPP.exec_(): campoPP = nuevoCampoPP.getCampo() self.lista.replace(campoPP) self.__editado.append(campoPP) elif self.__tipo is self.__class__.CAMPOJUZGADO: nuevoCampoJuzgado = NuevoCampo(tipo = NuevoCampo.JUZGADO, campo = self.lista.currentItem().getObjeto(), parent = self) if nuevoCampoJuzgado.exec_(): campoJuzgado = nuevoCampoJuzgado.getCampo() self.lista.replace(campoJuzgado) self.__editado.append(campoJuzgado) elif self.__tipo is self.__class__.PROCESO: nuevoProceso = NuevoProceso(proceso = self.lista.currentItem().getObjeto(), parent = self) if nuevoProceso.exec_(): proceso = nuevoProceso.getProceso() self.lista.replace(proceso) self.__editado.append(proceso) elif self.__tipo is self.__class__.PLANTILLA: nuevaPlantilla = NuevaPlantilla(pantilla = self.lista.currentItem().getObjeto(), parent = self) if nuevaPlantilla.exec_(): plantilla = nuevaPlantilla.getProceso() self.lista.replace(plantilla) self.__editado.append(plantilla) elif self.__tipo is self.ACTUACION: nuevaActuacion = NuevaActuacion(actuacion = self.lista.currentItem().getObjeto(), parent = self) if nuevaActuacion.exec_(): actuacion = nuevaActuacion.getActuacion() self.lista.replace(actuacion) self.__editado.append(actuacion) def getEditados(self): return self.__editado def getEliminados(self): return self.__eliminado def getAgregados(self): return self.__agregado
def __init__(self, tipo, parent = None, proceso = None): super(ListadoDialogo, self).__init__(parent) self.__tipo = tipo self.__proceso = proceso self.__p = Persistence() self.__editado = [] self.__eliminado = [] self.__agregado = [] if self.__tipo is self.__class__.DEMANDANTE: objetos = self.__p.consultarDemandantes() self.setWindowTitle('Seleccionar Demandante') elif self.__tipo is self.__class__.DEMANDADO: objetos = self.__p.consultarDemandados() self.setWindowTitle('Seleccionar Demandado') elif self.__tipo is self.__class__.JUZGADO: objetos = self.__p.consultarJuzgados() self.setWindowTitle('Seleccionar Juzgado') elif self.__tipo is self.__class__.CATEGORIA: objetos = self.__p.consultarCategorias() self.setWindowTitle(u'Seleccionar categoría') elif self.__tipo is self.__class__.CAMPOPROCESOP: objetos = self.__p.consultarAtributos() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPOJUZGADO: objetos = self.__p.consultarAtributosJuzgado() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPOACTUACION: objetos = self.__p.consultarAtributosActuacion() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPODEMANDANTE: objetos = self.__p.consultarAtributosPersona() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.CAMPODEMANDADO: objetos = self.__p.consultarAtributosPersona() self.setWindowTitle('Seleccione un campo') elif self.__tipo is self.__class__.PROCESO: objetos = self.__p.consultarProcesos() self.setWindowTitle('seleccione un proceso') elif self.__tipo is self.__class__.PLANTILLA: objetos = self.__p.consultarPlantillas() self.setWindowTitle('Seleccione una plantilla') elif self.__tipo is self.ACTUACION: if proceso: self.setWindowTitle(u'Seleccione una actuación') objetos = self.__p.consultarActuaciones(proceso) else: raise AttributeError('Proceso no puede ser None') groupBox = QtGui.QGroupBox("Seleccione un elemento") self.lista = ListadoBusqueda(objetos) btnAgregar = QtGui.QPushButton('+') layout = QtGui.QVBoxLayout() layoutBox = QtGui.QVBoxLayout() buttonlayout = QtGui.QHBoxLayout() buttonlayout.addStretch() layout.addWidget(self.lista.getSearchField()) layout.addWidget(self.lista) buttonlayout.addWidget(btnAgregar) groupBox.setLayout(layout) layoutBox.addWidget(groupBox) layoutBox.addLayout(buttonlayout) self.setLayout(layoutBox) self.lista.itemClicked.connect(self.click) #self.connect(btnAgregar, SIGNAL("clicked()"), self.button) btnAgregar.clicked.connect(self.button) self.lista.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) actionEliminar = self.__createAction("Eliminar", self.eliminar) actionAgregar = self.__createAction("Agregar", self.button) actionEditar = self.__createAction("Editar", self.editar) self.lista.addAction(actionEliminar) self.lista.addAction(actionAgregar) self.lista.addAction(actionEditar)
def __init__(self, actuacion=None, parent=None): super(NuevaActuacion, self).__init__(parent) self.__dirty = False if actuacion is not None and not isinstance(actuacion, Actuacion): raise TypeError("El objeto actuacion debe ser de la clase Actuacion") self.setupUi(self) self.__actuacion = actuacion self.__juzgado = None campos = [] if actuacion is not None: self.setWindowTitle(u'Editar actuación') self.groupBox.setTitle(u'Datos de la actuación:') self.__juzgado = actuacion.getJuzgado() campos = actuacion.getCampos() self.txtDescripcion.setText(unicode(actuacion.getDescripcion())) self.lblJuzgado.setText(unicode(self.__juzgado.getNombre())) self.dteFecha.setDateTime(actuacion.getFecha()) self.dteFechaProxima.setDateTime(actuacion.getFechaProxima()) p = Persistence() citas = p.consultarCitasCalendario() for cita in citas: if cita.getId_actuacion() == actuacion.getId_actuacion(): self.__cita = cita self.checkCita.setChecked(True) break else: self.__cita = None self.checkCita.setChecked(False) else: self.dteFecha.setDateTime(datetime.today()) self.dteFechaProxima.setDateTime(datetime.today()) self.lblJuzgado.setText(u'vacío') self.__cita = None self.__dialogo = DialogoAuxiliar(self) self.__clickJuzgado() cambiar = self.__createAction("Cambiar", self.__cambiarJuzgado) cambiar.setData(self.lblJuzgado) editar = self.__createAction("Editar", self.__editarJuzgado) editar.setData(self.lblJuzgado) self.lblJuzgado.addActions([cambiar, editar]) self.__gestor = GestorCampos(campos=campos, formLayout=self.formLayout, parent=self, constante_de_edicion=NuevoCampo.ACTUACION, constante_de_creacion=ListadoDialogo.CAMPOACTUACION) self.btnAdd.clicked.connect(self.__gestor.addCampo) self.txtDescripcion.textChanged.connect(self.setDirty) self.dteFecha.dateTimeChanged.connect(self.setDirty) self.dteFechaProxima.dateTimeChanged.connect(self.setDirty) self.dteFechaProxima.dateTimeChanged.connect(lambda : self.verificarFechas(interna = False)) self.dteFecha.dateTimeChanged.connect(lambda : self.verificarFechas(interna = False)) self.checkCita.clicked.connect(self.setCita) self.actionEditarCita = self.__createAction('Editar cita', self.editarCita) self.checkCita.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.setActionCita()
def actualizarPrefrencia(self, id_preferencia, valor): p = Persistence() # consultar Preferencias: correo if id_preferencia == 10402: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__correo = valor elif id_preferencia == self.CORREO_NOTIFICACION: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__correoNotificacion = valor # consultar Preferencias: Cantidad Eventos Proximos elif id_preferencia == 10501: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__cantidadEventos = valor # consultar Preferencias: Tipo Alarma 0 ninguni, 1 correo y alerta, 2 solo correo, 3 solo alerta elif id_preferencia == 10601: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__tipoAlarma = valor # consultar Preferencias: llave elif id_preferencia == 998: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__llave = valor # consultar Preferencias: Version elif id_preferencia == 999: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__version = valor # consultar Preferencias: Ultima sincronizacion elif id_preferencia == 997: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__ultimaSinc = 0
def borrarPreferencia(self, id_preferencia): p = Persistence() # consultar Preferencias: correo if id_preferencia == 10402: self.__correo = "" p.borrarPreferencia(id_preferencia=10402) elif id_preferencia == self.CORREO_NOTIFICACION: self.__correoNotificacion = "" p.borrarPreferencia(self.CORREO_NOTIFICACION) # consultar Preferencias: Cantidad Eventos Proximos elif id_preferencia == 10501: self.__cantidadEventos = 10 p.borrarPreferencia(id_preferencia=10501) # consultar Preferencias: Tipo Alarma 0 ninguni, 1 correo y alerta, 2 solo correo, 3 solo alerta elif id_preferencia == 10601: self.__tipoAlarma = 0 p.borrarPreferencia(id_preferencia=10601) # consultar Preferencias: llave elif id_preferencia == 998: self.__llave = 0000 p.borrarPreferencia(id_preferencia=998) # consultar Preferencias: Version elif id_preferencia == 999: self.__version = 1 p.borrarPreferencia(id_preferencia=999) # consultar Preferencias: Ultima sincronizacion elif id_preferencia == 997: self.__ultimaSinc = 0000 p.borrarPreferencia(id_preferencia=997)
class Preferencias(object): """ Clase Preferencias tipo alarma mensaje emerjento, correo electronico,icono notificacion, eliminar citas """ TXTPROCESOS = u"Procesos" TXTPLANTILLAS = u"Plantillas" TXTDEMANDANTES = u"Clientes" TXTDEMANDADOS = u"Contrapartes" TXTJUZGADOS = u"Juzgados" TXTACTUACIONES = u"Actuaciones" TXTCATEGORIAS = u"Categorías" TXTCAMPOS = "Campos Personalizados" TXTSINCRONIZAR = "Sincronizar" TXTAJUSTES = "Ajustes" TXTEVENTOS = u"Eventos Próximos" CANTEVENTOS = 10 CORREO = 10402 CORREO_NOTIFICACION = 10602 CANTIDAD_EVENTOS = 10501 TIPO_ALARMA = 10601 LLAVE = 998 VERSION = 999 ULTIMA_SINC = 997 def __init__(self): self.p = Persistence() preferencias = self.p.consultarPreferencias() for llaveD, valor in preferencias.iteritems(): # consultar Preferencias: correo if llaveD == self.CORREO: self.__correo = valor # consultar Preferencias: Cantidad Eventos Proximos elif llaveD == self.CANTIDAD_EVENTOS: self.__cantidadEventos = valor # consultar Preferencias: Tipo Alarma es un valor binario, primer bit mensaje emergente, segundo bit ,emsaje en icono de notificación, tercer bit correo electrónico elif llaveD == self.TIPO_ALARMA: self.__tipoAlarma = valor # consultar Preferencias: llave elif llaveD == self.LLAVE: self.__llave = valor # consultar Preferencias: Version elif llaveD == self.VERSION: self.__version = valor # consultar Preferencias: Ultima sincronizacion elif llaveD == self.ULTIMA_SINC: self.__ultimaSinc = valor elif llaveD == self.CORREO_NOTIFICACION: self.__correoNotificacion = valor # Getters def getId_preferencia(self): return self.__id_preferencia def getCantidadEventos(self): return self.__cantidadEventos def getCorreo(self): return self.__correo def getCorreoNotificacion(self): return self.__correoNotificacion def getTipoAlarma(self): return self.__tipoAlarma def getLlave(self): return self.__llave def getVersion(self): return self.__version def getUltimaSinc(self): return self.__ultimaSinc # Setters def setCantidadEventos(self, cantidadEventos): if isinstance(cantidadEventos, IntType): self.__cantidadEventos = cantidadEventos self.p.actualizarPreferencia(id_preferencia=10501, valor=cantidadEventos) Preferencias.CANTEVENTOS = cantidadEventos else: raise TypeError("Tipo de dato no admitido") def setCorreo(self, correo): if isinstance(correo, basestring): self.__correo = correo self.p.actualizarPreferencia(id_preferencia=10402, valor=correo) else: raise TypeError("Tipo de dato no admitido") def setCorreoNotificacion(self, correo): if isinstance(correo, basestring): self.__correoNotificacion = correo self.p.actualizarPreferencia(id_preferencia=self.CORREO_NOTIFICACION, valor=correo) else: raise TypeError("Tipo de dato no admitido") def setTipoAlarma(self, tipoAlarma): if isinstance(tipoAlarma, IntType): self.__tipoAlarma = tipoAlarma self.p.actualizarPreferencia(id_preferencia=10601, valor=tipoAlarma) else: raise TypeError("Tipo de dato no admitido") def setLlave(self, llave): if isinstance(llave, IntType): self.__llave = llave self.p.actualizarPreferencia(id_preferencia=998, valor=llave) else: raise TypeError("Tipo de dato no admitido") def setVersion(self, version): if isinstance(version, IntType): self.__version = version self.p.actualizarPreferencia(id_preferencia=999, valor=version) else: raise TypeError("Tipo de dato no admitido") def setUltimaSinc(self, ultimaSinc): if isinstance(ultimaSinc, IntType): self.__ultimaSinc = ultimaSinc self.p.actualizarPreferencia(id_preferencia=997, valor=ultimaSinc) else: raise TypeError("Tipo de dato no admitido") def borrarPreferencia(self, id_preferencia): p = Persistence() # consultar Preferencias: correo if id_preferencia == 10402: self.__correo = "" p.borrarPreferencia(id_preferencia=10402) elif id_preferencia == self.CORREO_NOTIFICACION: self.__correoNotificacion = "" p.borrarPreferencia(self.CORREO_NOTIFICACION) # consultar Preferencias: Cantidad Eventos Proximos elif id_preferencia == 10501: self.__cantidadEventos = 10 p.borrarPreferencia(id_preferencia=10501) # consultar Preferencias: Tipo Alarma 0 ninguni, 1 correo y alerta, 2 solo correo, 3 solo alerta elif id_preferencia == 10601: self.__tipoAlarma = 0 p.borrarPreferencia(id_preferencia=10601) # consultar Preferencias: llave elif id_preferencia == 998: self.__llave = 0000 p.borrarPreferencia(id_preferencia=998) # consultar Preferencias: Version elif id_preferencia == 999: self.__version = 1 p.borrarPreferencia(id_preferencia=999) # consultar Preferencias: Ultima sincronizacion elif id_preferencia == 997: self.__ultimaSinc = 0000 p.borrarPreferencia(id_preferencia=997) def borrarPreferencias(self): p = Persistence() p.borrarPreferencias() self.__correo = "" self.__correoNotificacion = "" self.__cantidadEventos = 10 self.__tipoAlarma = 1 self.__llave = 0 self.__version = 1 self.__ultimaSinc = 0 def actualizarPrefrencia(self, id_preferencia, valor): p = Persistence() # consultar Preferencias: correo if id_preferencia == 10402: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__correo = valor elif id_preferencia == self.CORREO_NOTIFICACION: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__correoNotificacion = valor # consultar Preferencias: Cantidad Eventos Proximos elif id_preferencia == 10501: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__cantidadEventos = valor # consultar Preferencias: Tipo Alarma 0 ninguni, 1 correo y alerta, 2 solo correo, 3 solo alerta elif id_preferencia == 10601: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__tipoAlarma = valor # consultar Preferencias: llave elif id_preferencia == 998: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__llave = valor # consultar Preferencias: Version elif id_preferencia == 999: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__version = valor # consultar Preferencias: Ultima sincronizacion elif id_preferencia == 997: p.actualizarPreferencia(id_preferencia=id_preferencia, valor=valor) self.__ultimaSinc = 0