Пример #1
0
    def _OnShoptimeChoice(self, event):
        controller = GetController()
        controller.StopFlashing()

        type = event.GetType()

        if type == "worktrade":
            if not controller.AuthenticateMechanic(
                    self, trans.authenticateWorktrade):
                return

        elif type == "volunteer":
            if not controller.AuthenticateMechanic(
                    self, trans.authenticateVolunteer):
                return

        person = self._selectPerson.GetPerson()
        if person:
            if controller.SignPersonIn(person, type):
                self.ResetValues()
        else:
            name = self._selectPerson.GetNameEntered()
            nameWords = name.split()
            numWords = len(nameWords)
            halfWords = int(ceil(numWords / 2.0))
            firstName = " ".join(nameWords[:halfWords])
            lastName = " ".join(nameWords[halfWords:])

            person = controller.GetPersonByFullName(firstName, lastName)
            if person:
                if controller.SignPersonIn(person, type):
                    self.ResetValues()
            elif controller.ShowNewPersonDialog(self, firstName, lastName):
                controller.SignPersonIn(None, type)
                self.ResetValues()
Пример #2
0
    def OnOK(self, event):
        if self.editNamePanel.Validate():
            createBike = False
            if not self.editBikePanel.IsEmpty():
                createBike = True
                if not self.editBikePanel.Validate():
                    return

            person = GetController().CreatePerson(self.editNamePanel.Get())

            if createBike:
                GetController().CreateBike(self.editBikePanel.Get(), person)

            self.EndModal(event.GetEventObject().GetId())
Пример #3
0
    def Validate(self):
        shoptime = self.Get()

        if shoptime.start > datetime.datetime.now():
            GetController().FlashError(trans.editShoptimeNoFuture,
                                       self["start"].Widget())
        elif shoptime.end < shoptime.start:
            GetController().FlashError(trans.editShoptimeNoTimeTravel,
                                       self["end"].Widget())
        elif not shoptime.type:
            GetController().FlashError(trans.editShoptimeNeedType,
                                       self["type"].Widget())
        else:
            return True

        return False
Пример #4
0
    def Validate(self):
        errors = []
        for value in ["color", "type", "serial"]:
            if not self[value].Get():
                errors.append(self[value].Widget())
        if errors:
            GetController().FlashError(trans.editBikeNotEnoughInfo, errors)
            return False

        return True
Пример #5
0
    def Validate(self):
        feedback = self.Get()

        if not feedback.feedback:
            GetController().FlashError(trans.editFeedbackNeedFeedback,
                                       [self["feedback"].Widget()])
        else:
            return True

        return False
Пример #6
0
    def Validate(self, updating=None):
        person = self.Get()

        namesMatch = (updating and updating.firstName == person.firstName
                      and updating.lastName == person.lastName)

        if not person.firstName:
            GetController().FlashError(trans.editPersonFirstName,
                                       [self["firstName"].Widget()])
        elif len(person.firstName) + len(person.lastName) < 3:
            GetController().FlashError(
                trans.editPersonThreeLetters,
                [self["firstName"].Widget(), self["lastName"].Widget()])
        elif not namesMatch and GetController().GetPersonByFullName(
                person.firstName, person.lastName):
            GetController().FlashError(
                trans.editPersonAlreadyExists,
                [self["firstName"].Widget(), self["lastName"].Widget()])
        else:
            return True

        return False
Пример #7
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        AddLabel(self, sizer, MedFont(), u"Select feedback to view.")
        self._feedbackListBox = wx.ListBox(self, wx.ID_ANY)
        self._feedbackListBox.Bind(wx.EVT_LISTBOX, self._OnListClick)
        self._feedbackListBox.Bind(wx.EVT_LISTBOX_DCLICK, self._OnListClick)
        sizer.Add(self._feedbackListBox, 1, wx.EXPAND)

        def FeedbackString(item):
            name = item.name
            if len(name) > 16:
                name = name[:7] + "..."

            feedback = item.feedback
            if len(feedback) > 10:
                feedback = feedback[:7] + "..."

            return "{0}: \"{1}\" said \"{2}\"".format(FormatFeedbackDate(item),
                                                      name, feedback)

        self._feedback = GetController().GetFeedback()
        self._feedbackListBox.SetItems(
            [FeedbackString(item) for item in self._feedback])

        displaySizer = MakeInfoEntrySizer()
        sizer.Add(displaySizer, 1, wx.EXPAND)

        def AddFeedbackField(label, multiline=False):
            text = wx.StaticText(self, label=label)
            text.SetFont(MedFont())
            displaySizer.Add(
                text, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.ALL, 5)

            style = wx.TE_READONLY
            if multiline:
                style |= wx.TE_MULTILINE
            field = wx.TextCtrl(self, style=style)
            field.SetFont(MedFont())
            displaySizer.Add(field, 1, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)
            return field

        self._currentDate = AddFeedbackField("Date:")
        self._currentName = AddFeedbackField("Name:")
        self._currentFeedback = AddFeedbackField("Feedback:", multiline=True)
Пример #8
0
    def _PopulateList(self, partialName):
        if self._nameListBox is not None:
            self._nameListBox.Destroy()

        #We recreate the listbox here because there's no way to reset horizontal
        #	size or scroll position on an existiing box. Very long names widen the
        #	scrollbox, leaving it possible to set the scrollbar to a point where no
        #	results are visible. This confuses patrons.
        self._nameListBox = wx.ListBox(self, wx.ID_ANY, style=wx.LB_NEEDED_SB)
        self._nameListBox.Bind(wx.EVT_LISTBOX, self._OnListClick)
        self._nameListBox.Bind(wx.EVT_LISTBOX_DCLICK, self._OnListClick)
        self._nameListBox.Bind(wx.EVT_KEY_DOWN, self._OnListKeydown)
        for event in [
                wx.EVT_LEFT_UP, wx.EVT_MIDDLE_DOWN, wx.EVT_RIGHT_DOWN,
                wx.EVT_LEFT_DCLICK, wx.EVT_MIDDLE_DCLICK, wx.EVT_RIGHT_DCLICK
        ]:
            self._nameListBox.Bind(event, self._OnListDeadSpaceClick)

        self.GetSizer().Insert(2, self._nameListBox, 1, wx.EXPAND)

        self._nameListBox.SetSizeHints(200, 80)
        self._nameListBox.SetVirtualSize((1, 1))
        self.GetSizer().Layout()

        event = PersonSelectedEvent(self, None)

        if partialName:
            self._people = GetController().FindPeopleByPartialName(partialName)
            names = [person.Name() for person in self._people]

            self._nameListBox.SetItems(names)
            self._nameListBox.SetSelection(-1)

            for i in range(len(names)):
                enteredName = partialName.lower().split()
                listName = names[i].lower().split()
                if enteredName == listName:
                    self._nameListBox.SetSelection(i)
                    event.SetPerson(self._people[i])
                    break

        self._nameListBox.Layout()
        self._nameListBox.Fit()
        self._nameListBox.FitInside()

        self._SendEvent(event)
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.occupants = []

        titleFont = wx.Font(16, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL)
        self.titleText = wx.StaticText(self, wx.ID_ANY,
                                       trans.occupantListHeader)
        self.titleText.SetFont(titleFont)
        self.dateText = wx.StaticText(self, wx.ID_ANY, u"")
        self.dateText.SetFont(titleFont)

        titleSizer = wx.BoxSizer()
        titleSizer.Add(self.titleText, 0, wx.ALL, 5)
        titleSizer.AddSpacer((0, 0), 1, wx.EXPAND, 5)
        titleSizer.Add(self.dateText, 0, wx.ALL, 5)

        self._scrollRate = 20
        self._scrollbox = wx.ScrolledWindow(self)
        self._scrollbox.SetScrollRate(0, self._scrollRate)
        self._scrollSizer = wx.BoxSizer()
        self._scrollbox.SetSizer(self._scrollSizer)

        self._gridContainer = wx.Panel(self._scrollbox)
        self._scrollSizer.Add(self._gridContainer, 1, wx.EXPAND)

        self._listSizer = wx.FlexGridSizer(rows=0, cols=4, hgap=10, vgap=0)
        self._listSizer.SetFlexibleDirection(wx.BOTH)
        self._listSizer.AddGrowableCol(1)
        self._gridContainer.SetSizer(self._listSizer)

        def AddColumnHeader(name, flags=0):
            label = wx.StaticText(self._gridContainer, wx.ID_ANY, name)
            label.SetFont(
                wx.Font(12, wx.FONTFAMILY_SWISS, wx.NORMAL, wx.NORMAL))
            localSizer = wx.BoxSizer(wx.VERTICAL)
            localSizer.Add(label, flag=flags)
            localSizer.Add(wx.StaticLine(self._gridContainer), wx.ALIGN_BOTTOM,
                           wx.EXPAND)
            self._listSizer.Add(localSizer, 0, wx.ALIGN_CENTER | wx.EXPAND)

        AddColumnHeader(u"")
        AddColumnHeader(trans.occupantColumnName)
        AddColumnHeader(trans.occupantColumnActivity)
        AddColumnHeader(trans.occupantColumnTime, wx.ALIGN_RIGHT)

        outerSizer = wx.FlexGridSizer(2, 1)
        outerSizer.SetFlexibleDirection(wx.BOTH)
        outerSizer.AddGrowableCol(0)
        outerSizer.AddGrowableCol(1)
        outerSizer.AddGrowableRow(1)
        outerSizer.Add(titleSizer, 1, wx.EXPAND)
        outerSizer.Add(self._scrollbox, 1, wx.EXPAND)
        self.SetSizer(outerSizer)

        peopleInShop = GetController().GetPeopleInShop()
        if peopleInShop is not None:
            for person in peopleInShop:
                self.AddOccupant(person, person.occupantInfo.start,
                                 person.occupantInfo.type)

        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.updateTimer = wx.Timer(self)
        self.updateTimer.Start(1000)

        self.UpdateTimes()
 def OnSignOutClicked(self, event):
     GetController().SignPersonOut(self._person)
 def OnViewInfoClicked(self, event):
     GetController().ViewPersonInfo(self._parent, self._person)
 def _OnCancel(self, event):
     GetController().StopFlashing()
     GetController().Rollback()
     self.EndModal(wx.ID_CANCEL)
Пример #13
0
 def _FlashTasks(self):
     widgets = self._shoptimeChoice.GetWidgets()
     GetController().FlashError(trans.signinselectTask, widgets)
Пример #14
0
 def _OnFeedback(self, event):
     dialog = FeedbackDialog(self)
     if dialog.ShowModal() == wx.ID_OK:
         feedback = dialog.Get()
         feedback.date = datetime.datetime.now()
         GetController().AddFeedback(feedback)
Пример #15
0
 def _OnToolbox(self, event):
     if GetController().AuthenticateMechanic(self,
                                             trans.authenticateToolbox):
         dialog = MechanicToolboxDialog()
         dialog.ShowModal()
 def OnSignout(self, event):
     people = GetController().GetPeopleInShop()
     for person in people:
         GetController().SignPersonOut(person)
 def _OnOK(self, event):
     GetController().StopFlashing()
     if self._personEditPanel.Validate(self._person):
         self._personEditPanel.Update(self._person)
         GetController().Commit()
         self.EndModal(wx.ID_OK)
Пример #18
0
 def _FlashName(self):
     widgets = [self._selectPerson.GetNameEntryWidget()]
     GetController().FlashError(trans.signinenterName, widgets)
 def _OnOK(self, event):
     GetController().StopFlashing()
     if self.Validate():
         self.Get()
         self.EndModal(wx.ID_OK)