def __init__(self):
     super(RoleProxy, self).__init__(RoleProxy.NAME, [])
     self.data = []
     self.addItem(
         vo.RoleVO('lstooge', [enum.ROLE_PAYROLL, enum.ROLE_EMP_BENEFITS]))
     self.addItem(
         vo.RoleVO(
             'cstooge',
             [enum.ROLE_ACCT_PAY, enum.ROLE_ACCT_RCV, enum.ROLE_GEN_LEDGER
              ]))
     self.addItem(
         vo.RoleVO('mstooge', [
             enum.ROLE_INVENTORY, enum.ROLE_PRODUCTION, enum.ROLE_SALES,
             enum.ROLE_SHIPPING
         ]))
    def handleNotification(self, note):
        noteName = note.getName()

        if noteName == main.AppFacade.NEW_USER:
            self.clearForm()

        elif noteName == main.AppFacade.USER_ADDED:
            self.viewComponent.user = note.getBody()
            roleVO = vo.RoleVO(self.viewComponent.user.user_name)
            self.roleProxy.addItem(roleVO)
            self.clearForm()

        elif noteName == main.AppFacade.USER_UPDATED:
            self.clearForm()

        elif noteName == main.AppFacade.USER_DELETED:
            self.clearForm()

        elif noteName == main.AppFacade.CANCEL_SELECTED:
            self.clearForm()

        elif noteName == main.AppFacade.USER_SELECTED:
            self.viewComponent.user = note.getBody()
            self.viewComponent.updateRoleList(
                self.roleProxy.getUserRoles(self.viewComponent.user.user_name))

        elif noteName == main.AppFacade.ADD_ROLE_RESULT:
            self.viewComponent.updateRoleList(
                self.roleProxy.getUserRoles(self.viewComponent.user.user_name))
Esempio n. 3
0
    def handleNotification(self, note):
        try:
            noteName = note.getName()

            if noteName == Notification.NEW_USER:
                self.clearForm()

            elif noteName == Notification.USER_ADDED:
                self.viewComponent.user = note.getBody()
                roleVO = vo.RoleVO(self.viewComponent.user.username)
                self.roleProxy.addItem(roleVO)
                self.clearForm()

            elif noteName == Notification.USER_UPDATED:
                self.clearForm()

            elif noteName == Notification.USER_DELETED:
                self.clearForm()

            elif noteName == Notification.CANCEL_SELECTED:
                self.clearForm()

            elif noteName == Notification.USER_SELECTED:
                self.viewComponent.user = note.getBody()
                if not self.viewComponent.user:
                    self.viewComponent.updateRoleList(
                        self.roleProxy.getUserRoles(None))
                else:
                    self.viewComponent.updateRoleList(
                        self.roleProxy.getUserRoles(
                            self.viewComponent.user.username))

            elif noteName == Command.ADD_ROLE_RESULT:
                self.viewComponent.updateRoleList(
                    self.roleProxy.getUserRoles(
                        self.viewComponent.user.username))
        except:
            raise