Пример #1
0
    def search_by_rfid(self):
        """ Поиск пользователя по RFID и получение списка карт,
        соответствующих событию."""
        def callback(rfid):
            self.rfid_id = rfid

        # диалог rfid считывателя
        dialog = WaitingRFID(self, callback=callback)
        dialog.setModal(True)
        if QDialog.Accepted == dialog.exec_():
            http = self.params.http
            if not http.request(
                    '/api/client/%s/' % self.rfid_id, 'GET', force=True):
                QMessageBox.critical(
                    self, self.tr('Client info'),
                    self.tr('Unable to fetch: %s') % http.error_msg)
                return
            response = http.parse()

            if 0 == len(response):
                QMessageBox.warning(self, self.tr('Warning'),
                                    self.tr('This RFID belongs to nobody.'))
                return False
            else:
                self.last_user_uuid = response[0].get('uuid')
                return self.visit_register(self.last_user_uuid)
Пример #2
0
    def user_search_rfid(self, klass, mode):
        """
        Метод для поиска клиента по RFID.
        """

        def callback(rfid):
            self.rfid_id = rfid

        if self.params.logged_in:
            dialog = WaitingRFID(self, mode=mode, callback=callback)
            dialog.setModal(True)
            if QDialog.Accepted == dialog.exec_() and self.rfid_id:
                h = self.params.http
                if not h.request("/api/%s/%s/" % (mode, self.rfid_id), "GET", force=True):
                    QMessageBox.critical(self, self.tr("Client info"), self.tr("Unable to fetch: %s") % h.error_msg)
                    return
                response = h.parse()

                if 0 == len(response):
                    QMessageBox.warning(self, self.tr("Warning"), self.tr("This RFID belongs to nobody."))
                else:
                    self.dialog = klass(self)
                    self.dialog.setModal(True)
                    self.dialog.initData(response[0])
                    self.dialog.exec_()
                    del (self.dialog)
                    self.rfid_id = None
Пример #3
0
    def user_search_rfid(self, klass, mode):
        """
        Метод для поиска клиента по RFID.
        """
        def callback(rfid):
            self.rfid_id = rfid

        if self.params.logged_in:
            dialog = WaitingRFID(self, mode=mode, callback=callback)
            dialog.setModal(True)
            if QDialog.Accepted == dialog.exec_() and self.rfid_id:
                h = self.params.http
                if not h.request(
                        '/api/%s/%s/' %
                    (mode, self.rfid_id), 'GET', force=True):
                    QMessageBox.critical(
                        self, self.tr('Client info'),
                        self.tr('Unable to fetch: %s') % h.error_msg)
                    return
                response = h.parse()

                if 0 == len(response):
                    QMessageBox.warning(
                        self, self.tr('Warning'),
                        self.tr('This RFID belongs to nobody.'))
                else:
                    self.dialog = klass(self)
                    self.dialog.setModal(True)
                    self.dialog.initData(response[0])
                    self.dialog.exec_()
                    del (self.dialog)
                    self.rfid_id = None
Пример #4
0
    def assign_rfid(self):
        """
        Метод для назначения пользователю RFID идентификатора.
        """
        def callback(rfid):
            self.rfid_code = rfid

        dialog = WaitingRFID(self, mode='client', callback=callback)
        dialog.setModal(True)
        dlgStatus = dialog.exec_()

        if QDialog.Accepted == dlgStatus:
            http = self.params.http
            if not http.request('/api/rfid/%s/' % self.rfid_code, 'POST'):
                QMessageBox.critical(
                    self, self.tr('Client Information'),
                    self.tr('Unable to fetch: %1').arg(http.error_msg))
                return
            status, response = http.piston()
            if status == 'DUPLICATE_ENTRY':
                QMessageBox.warning(self, self.tr('Warning'),
                                    self.tr('This RFID is used already!'))
            elif status == 'CREATED':
                self.rfid_uuid = response.get('uuid')
                self.buttonRFID.setText(self.rfid_code)
                self.buttonRFID.setDisabled(True)
Пример #5
0
    def assignRFID(self):
        def callback(rfid):
            self.rfid_id = rfid

        params = {
            'http': self.http,
            'static': self.static,
            'mode': 'client',
            'callback': callback,
            }
        dialog = WaitingRFID(self, params)
        dialog.setModal(True)
        dlgStatus = dialog.exec_()

        if QDialog.Accepted == dlgStatus:
            # check the rfid code
            params = {'rfid_code': self.rfid_id, 'mode': 'client'}
            if not self.http.request('/manager/get_client_info/', params):
                QMessageBox.critical(self, _('Client info'), _('Unable to fetch: %s') % self.http.error_msg)
                return
            default_response = None
            response = self.http.parse(default_response)
            if response and 'info' in response and response['info'] is not None:
                QMessageBox.warning(self, _('Warning'),
                                    _('This RFID is used already!'))
            else:
                self.buttonRFID.setText(self.rfid_id)
                self.buttonRFID.setDisabled(True)
Пример #6
0
    def client_search_rfid(self):
        '''
        Search client in the database
        by RFID (Radio Frequency IDentificator).
        
        After RFID was successfully read from card, server is
        L{requested<Http.request>} client info.
        
        If user is found in database, L{dialog<ClientInfo>}
        with information about client is displayed.
        
        Otherwise, messageboxes with warnings are displayed.
        '''
        
        if not self.http or not self.http.is_session_open():
            return # login first

        def callback(rfid):
            self.rfid_id = rfid

        params = {
            'http': self.http,
            'static': self.static,
            'mode': 'client',
            'callback': callback,
            }
        dialog = WaitingRFID(self, params)
        dialog.setModal(True)
        dlgStatus = dialog.exec_()

        if QDialog.Accepted == dlgStatus and self.rfid_id is not None:
            params = {'rfid_code': self.rfid_id, 'mode': 'client'}
            if not self.http.request('/manager/get_client_info/', params):
                QMessageBox.critical(self, _('Client info'), _('Unable to fetch: %s') % self.http.error_msg)
                return
            default_response = None
            response = self.http.parse(default_response)

            if not response or response['info'] is None:
                QMessageBox.warning(self, _('Warning'),
                                    _('This RFID belongs to nobody.'))
            else:
                user_info = response['info']
                params = {
                    'http': self.http,
                    'static': self.static,
                    }
                self.dialog = ClientInfo(self, params)
                self.dialog.setModal(True)

                self.dialog.initData(user_info)
                self.dialog.exec_()
                self.rfid_id = None
Пример #7
0
    def visitEventRFID(self):
        """
        Register the visit by client's RFID label.
        """

        def callback(rfid):
            self.rfid_id = rfid

        params = {
            'http': self.http,
            'callback': callback,
            }
        dialog = WaitingRFID(self, params)
        dialog.setModal(True)
        dlgStatus = dialog.exec_()

        if QDialog.Accepted == dlgStatus:
            user_id = None

            # get user_id by rfid_code
            params = {'rfid_code': self.rfid_id, 'mode': 'client'}
            if not self.http.request('/manager/get_client_info/', params):
                QMessageBox.critical(self, _('Client info'), _('Unable to fetch: %s') % self.http.error_msg)
                return
            default_response = None
            response = self.http.parse(default_response)
            if response and 'info' in response:
                user_id = response['info'].get('id', None)
            else:
                QMessageBox.critical(self, _('Client registration'),
                                     _('Could not find user by RFID!'))
                return

            # register user on the event
            params = {'event_id': self.schedule['id'],
                      'client_id': user_id}
            if not self.http.request('/manager/register_visit/', params):
                QMessageBox.critical(self, _('Register visit'), _('Unable to register: %s') % self.http.error_msg)
                return
            default_response = None
            response = self.http.parse(default_response)
            if response:
                message = _('The client is registered on this event.')
            else:
                error_msg = self.http.error_msg
                message = _('Unable to register the visit!\nReason:\n%s') % error_msg
            QMessageBox.information(self, _('Client registration'), message)
Пример #8
0
    def search_by_rfid(self):
        """ Поиск пользователя по RFID и получение списка карт,
        соответствующих событию."""

        def callback(rfid):
            self.rfid_id = rfid

        # диалог rfid считывателя
        dialog = WaitingRFID(self, callback=callback)
        dialog.setModal(True)
        if QDialog.Accepted == dialog.exec_():
            http = self.params.http
            if not http.request('/api/client/%s/' % self.rfid_id, 'GET', force=True):
                QMessageBox.critical(self, self.tr('Client info'), self.tr('Unable to fetch: %s') % http.error_msg)
                return
            response = http.parse()

            if 0 == len(response):
                QMessageBox.warning(self, self.tr('Warning'), self.tr('This RFID belongs to nobody.'))
                return False
            else:
                self.last_user_uuid = response[0].get('uuid')
                return self.visit_register(self.last_user_uuid)
Пример #9
0
    def assign_rfid(self):
        """
        Метод для назначения пользователю RFID идентификатора.
        """
        def callback(rfid):
            self.rfid_code = rfid

        dialog = WaitingRFID(self, mode='client', callback=callback)
        dialog.setModal(True)
        dlgStatus = dialog.exec_()

        if QDialog.Accepted == dlgStatus:
            http = self.params.http
            if not http.request('/api/rfid/%s/' % self.rfid_code, 'POST'):
                QMessageBox.critical(self, self.tr('Client Information'), self.tr('Unable to fetch: %1').arg(http.error_msg))
                return
            status, response = http.piston()
            if status == 'DUPLICATE_ENTRY':
                QMessageBox.warning(self, self.tr('Warning'), self.tr('This RFID is used already!'))
            elif status == 'CREATED':
                self.rfid_uuid = response.get('uuid')
                self.buttonRFID.setText(self.rfid_code)
                self.buttonRFID.setDisabled(True)