def abrir_mesa(self, datos_tag): """Abre la mesa.""" apertura = Apertura.desde_tag(datos_tag) apertura.mesa = self.sesion.mesa self._validar_configuracion(mesa=apertura.mesa, pin=None, con_acta_apertura=True, datos_tag=datos_tag)
def _validar_configuracion(self, mesa=None, pin=None, con_acta_apertura=False, datos_tag=''): """ Recibe el numero de mesa y el pin de la pantalla de configuración y verifica que sea correcto. Si es *con_acta_apertura* se carga la mesa automaticamente y con datos tag carga los datos del presidente Si es correcto configura la mesa para dejarla operativa y pasa al menú de administración, en otro caso presenta la pantalla principal. """ if mesa is not None: self._mesa = mesa # Le seteo el atributo abierta si la configuracion de la mesa fue # con el acta de apertura self._configurar_mesa() if con_acta_apertura: apertura = Apertura.desde_tag(datos_tag) self.sesion.apertura = apertura self.estado = E_CONFIGURADA realizar_apertura = self.config("realizar_apertura") self.ret_code = SUBMODULO_DATOS_APERTURA if realizar_apertura \ else MODULO_MENU if self.rampa.tiene_papel: self.rampa.expulsar_boleta() idle_add(self.quit) else: self.estado = E_INICIAL self._cargar_ui_web() self.ventana.show_all() self._pantalla_principal() self.controlador.msg_mesaypin_incorrecto()
def _configurar_mesa(self, datos_tag): """Configura la mesa con los datos que contiene el tag.""" apertura = Apertura.desde_tag(datos_tag) if apertura.mesa is not None: self.sesion.apertura = apertura self.sesion.mesa = apertura.mesa self.mesa_abierta = True self._inicio()
def cargar_apertura(self, tag_dict): """Carga los datos de la apertura en el menu cuando se apoya.""" apertura = Apertura.desde_tag(tag_dict['datos']) estado = self.controlador.estado mesa = self.sesion.mesa if estado != E_INGRESO_DATOS or (estado == E_INGRESO_DATOS and mesa.numero == apertura.mesa.numero): self.apertura = apertura self.controlador.set_pantalla({"mesa": apertura.mesa.numero})
def imprimir_serializado(self, tipo_tag, tag, transpose, only_buffer=False, extra_data=None): """Registra un documento que fue enviado serializado via d-bus. Argumentos: tipo_tag -- el tipo de documento que queremos registrar. Puede ser: (Seleccion, Apertura, Recuento o Prueba) tag -- Contenido del tag serializado. transpose -- transpone la imagen. only_buffer -- Solo guarda en el buffer, no imprime. extra_data -- datos extra que queremos imprimir pero que no se guardan en el chip. """ self._buffering = True if tipo_tag == "Seleccion": if type(tag) == Seleccion: boleta = tag else: boleta = Seleccion.desde_string(tag) image = boleta.a_imagen() elif tipo_tag == "Apertura": boleta = Apertura.desde_tag(b64decode(tag)) image = boleta.a_imagen() elif tipo_tag == "Recuento": boleta = Recuento.desde_tag(b64decode(tag)) extra_data = loads(extra_data) autoridades = extra_data.get('autoridades') if autoridades is not None and len(autoridades): boleta.autoridades = [Autoridad.desde_dict(aut) for aut in autoridades] boleta.hora = extra_data['hora'] image = boleta.a_imagen(extra_data['tipo_acta']) elif tipo_tag == "Prueba": image = ImagenPrueba().render_image() image = image.convert('L') if transpose: image = image.transpose(Image.ROTATE_270) if only_buffer: if self.parent.impresion_v2: self.parent.printer.register_load_buffer_compressed_full() else: self.parent.printer.register_load_buffer_compressed() else: self.parent.printer.register_print_finished() data = image.getdata() if self.parent.impresion_v2: width, height = image.size self.parent.printer.load_buffer_compressed_full( data, self.parent._free_page_mem, width, height, print_immediately=not only_buffer) else: self.parent.printer.load_buffer_compressed( data, self.parent._free_page_mem, print_immediately=not only_buffer)
def _configurar_mesa_apertura(self, datos_tag): """ Configura la mesa con los datos que contiene el tag. """ apertura = Apertura.desde_tag(datos_tag) def _salir(): """Estamblece la apertura y la mesa en la sesion y sale al menu.""" apertura.mesa = self.sesion.mesa self.sesion.apertura = apertura self.rampa.desregistrar_eventos() self.salir_a_menu() if apertura.mesa is not None: if apertura.mesa.numero == self.sesion.mesa.numero: self.sesion.impresora.expulsar_boleta() self.sesion.impresora.consultar_tarjeta( lambda x: timeout_add(500, _salir)) else: self.controlador.set_mensaje(_("acta_mesa_erronea")) self.rampa.expulsar_boleta()
def imprimir_serializado(self, tipo_tag, tag, transpose, only_buffer=False, extra_data=None): """Registra un documento que fue enviado serializado via d-bus. Argumentos: tipo_tag -- el tipo de documento que queremos registrar. Puede ser: (Seleccion, Apertura, Recuento o Prueba) tag -- Contenido del tag serializado. transpose -- transpone la imagen. only_buffer -- Solo guarda en el buffer, no imprime. extra_data -- datos extra que queremos imprimir pero que no se guardan en el chip. """ self._buffering = True if tipo_tag == "Seleccion": if type(tag) == Seleccion: boleta = tag else: boleta = Seleccion.desde_string(tag) image = boleta.a_imagen() elif tipo_tag == "Apertura": boleta = Apertura.desde_tag(b64decode(tag)) image = boleta.a_imagen() elif tipo_tag == "Recuento": boleta = Recuento.desde_tag(b64decode(tag)) extra_data = loads(extra_data) autoridades = extra_data.get('autoridades') if autoridades is not None and len(autoridades): boleta.autoridades = [ Autoridad.desde_dict(aut) for aut in autoridades ] boleta.hora = extra_data['hora'] image = boleta.a_imagen(extra_data['tipo_acta']) elif tipo_tag == "Prueba": image = ImagenPrueba().render_image() image = image.convert('L') if transpose: image = image.transpose(Image.ROTATE_270) if only_buffer: if self.parent.impresion_v2: self.parent.printer.register_load_buffer_compressed_full() else: self.parent.printer.register_load_buffer_compressed() else: self.parent.printer.register_print_finished() data = image.getdata() if self.parent.impresion_v2: width, height = image.size self.parent.printer.load_buffer_compressed_full( data, self.parent._free_page_mem, width, height, print_immediately=not only_buffer) else: self.parent.printer.load_buffer_compressed( data, self.parent._free_page_mem, print_immediately=not only_buffer)