Пример #1
0
    def search_activities_with_date(self):
        '''
        Read a date and prints the activities taking place on that date.
        '''

        system("clear")

        print(
            "# You have chosen to search activities which take place on a certain date."
        )

        if self.__activitiesCtrl.number_of_activities() == 0:
            raise NABException("The list of activities is empty.")

        date = input("Type the date in format {0}: ".format(
            ActivityValidator.dateFormat()))

        try:
            system("clear")

            foundActivities = self.__activitiesCtrl.find_activities_by_date(
                date)

            print("# The following activities have been found: ")
            print(foundActivities, end='')

        except NABException as err:
            print(err)
Пример #2
0
    def add_activity(self):
        '''
        Reads information about an activity and adds it to the NAB.
        '''

        system("clear")

        print("# You have chosen to add a new activity.")

        print(
            "ID must be the one of a person already existing in the list of people."
        )
        id = Console.read_positive_integer(
            "Type the ID of the person who performs the activity: ")
        print("Date must be one between {0} and {1}.".format(
            ActivityValidator.minDate(), ActivityValidator.maxDate()))
        date = input("Type the date of the activity in format {0}: ".format(
            ActivityValidator.dateFormat()))
        print("Time must be one between {0} and {1}.".format(
            ActivityValidator.minTime(), ActivityValidator.maxTime()))
        time = input("Type the time of the activity in format {0}: ".format(
            ActivityValidator.timeFormat()))
        description = input("Type the description of the activity: ")

        try:
            system("clear")

            person = self.__peopleCtrl.find_person_by_id(id)
            self.__activitiesCtrl.add_activity(
                Activity(person, date, time, description))
            self.__undoRedoCtrl.do_activities()
            print("Activity has been successfully added.")
        except NABException as err:
            print(err)