def _sign_button_press(self):
        """Validate input from ent_id, then sign in to the Timesheet."""
        user_id = self.ent_id.text().strip()

        try:
            status = controller.sign(user_id)

        # ERROR: User type is unknown (!student and !tutor)
        except ValueError as e:
            logger.error(e, exc_info=True)
            QMessageBox.critical(
                self,
                __title__ + ' Error',
                str(e),
                buttons=QMessageBox.Ok,
                defaultButton=QMessageBox.Ok,
            )

        # ERROR: User is unregistered
        except controller.UnregisteredUser as e:
            logger.debug(e)
            QMessageBox.warning(
                self,
                'Unregistered User',
                str(e),
                buttons=QMessageBox.Ok,
                defaultButton=QMessageBox.Ok,
            )

        # User needs to select type
        except controller.AmbiguousUserType as e:
            logger.debug(e)
            u = QtUserTypeSelectionDialog('Select User Type: ', self)
            if u.exec_() == QDialog.Accepted:
                status = controller.sign(user_id, user_type=u.user_type)
                self._show_feedback_label(
                    'Signed {}: {} ({})'.format(
                        status.in_or_out, status.user_name, status.user_type
                    )
                )

        # User has signed in or out normally
        else:
            sign_choice_confirmed = QMessageBox.question(
                self,
                'Confirm Sign-{}'.format(status.in_or_out),
                'Sign {}: {}?'.format(status.in_or_out, status.user_name),
                buttons=QMessageBox.Yes | QMessageBox.No,
                defaultButton=QMessageBox.Yes,
            )

            logger.debug('Sign {} confirmed: {}'.format(
                status.in_or_out, sign_choice_confirmed
            ))

            if sign_choice_confirmed == QMessageBox.No:
                # Undo sign-in or sign-out
                if status.in_or_out == 'in':
                    controller.undo_sign_in(status.entry)
                elif status.in_or_out == 'out':
                    controller.undo_sign_out(status.entry)
            else:
                self._show_feedback_label(
                    'Signed {}: {}'.format(status.in_or_out, status.user_name)
                )

        finally:
            self._set_signed_in()
            self.ent_id.clear()
            self.ent_id.setFocus()
def _sign_button_press ( self ) : user_id = self . ent_id . text ( ) . strip ( ) try : status = controller . sign ( user_id ) except ValueError as e : logger . error ( e , exc_info = True ) QMessageBox . critical ( self , __title__ + ' Error' , str ( e ) , buttons = QMessageBox . Ok , defaultButton = QMessageBox . Ok , ) except controller . UnregisteredUser as e : logger . debug ( e ) QMessageBox . warning ( self , 'Unregistered User' , str ( e ) , buttons = QMessageBox . Ok , defaultButton = QMessageBox . Ok , ) except controller . AmbiguousUserType as e : logger . debug ( e ) u = QtUserTypeSelectionDialog ( 'Select User Type: ' , self ) if u . exec_ ( ) == QDialog . Accepted : status = controller . sign ( user_id , user_type = u . user_type ) self . _show_feedback_label ( 'Signed {}: {} ({})' . format ( status . in_or_out , status . user_name , status . user_type ) ) else : sign_choice_confirmed = QMessageBox . question ( self , 'Confirm Sign-{}' . format ( status . in_or_out ) , 'Sign {}: {}?' . format ( status . in_or_out , status . user_name ) , buttons = QMessageBox . Yes | QMessageBox . No , defaultButton = QMessageBox . Yes , ) logger . debug ( 'Sign {} confirmed: {}' . format ( status . in_or_out , sign_choice_confirmed ) ) if sign_choice_confirmed == QMessageBox . No : if status . in_or_out == 'in' : controller . undo_sign_in ( status . entry ) elif status . in_or_out == 'out' : controller . undo_sign_out ( status . entry ) else : self . _show_feedback_label ( 'Signed {}: {}' . format ( status . in_or_out , status . user_name ) ) finally : self . _set_signed_in ( ) self . ent_id . clear ( ) self . ent_id . setFocus ( )
Validate input from ent_id, then sign in to the Timesheet.