Esempio n. 1
0
    def listOfPersonsMenu(self):
        """
        Function menu for list of persons with activities between date1 and date 2.
        """
        d1 = self._readDate("Date1(dd-mm-yyyy): ")
        d2 = self._readDate("Date2(dd-mm-yyyy): ")
        command = input("Order[alphabetic(a)/date(d)]:")

        if d1 > d2:
            d2, d1 = d1, d2

        if command == "alphabetic" or command == "a":
            for person in self.__persons.getPersonsList():
                print(person)
                l = sortActivitiesAlphabetic(filterByDates(self.__activities.getActivitiesByActivitiesId(
                    self.__pac.findPersonActivities(person.getId())), d1, d2))
                if not l:
                    print("This person does not have activities between {0} and {1}".format(d1, d2))
                else:
                    for activity in l:
                        print(activity)
        elif command == "date" or command == "d":
            for person in self.__persons.getPersonsList():
                print(person)
                l = sortActivitiesByDate(filterByDates(self.__activities.getActivitiesByActivitiesId(
                    self.__pac.findPersonActivities(person.getId())), d1, d2))
                if not l:
                    print("This person does not have activities between {0} and {1}".format(d1, d2))
                else:
                    for activity in l:
                        print(activity)
        else:
            print("Invalid command")
Esempio n. 2
0
    def listOfActivitiesMenu(self):
        """
        Function menu for list of activities for a person.
        """
        pid = self._readPositiveInteger("Person id:")
        command = input("Order[alphabetic(a)/date(d)]:")

        if not self.__persons.findPersonById(pid):
            print("Person with id: {0} does not exist.".format(pid))
        else:
            if command == "alphabetic" or command == "a":
                for activity in sortActivitiesAlphabetic(self.__activities.getActivitiesByActivitiesId(self.__pac.findPersonActivities(pid))):
                    print(activity)
            elif command == "date" or command == "d":
                for activity in sortActivitiesByDate(self.__activities.getActivitiesByActivitiesId(self.__pac.findPersonActivities(pid))):
                    print(activity)
            else:
                print("Invalid command")