示例#1
0
    def add_activity(self):
        activity_id = input("activity id:")
        
        if not Common.get_type(activity_id) is int:
            raise ValueError("Activity id must be an integer.")
        
        activity_id = int(activity_id)
        
        date = input("date:")
        
        if not Common.get_type(date) is datetime.date:
            raise ValueError("Activity date must have the format day.month.year.")  
        
        date = Common.convert_to_date(date)
        
        time = input("time:")
        
        if not Common.get_type(time) is datetime.time:
            raise ValueError("Activity time must have the format hour:minute.")

        time = Common.convert_to_time(time)

        description = input("description:")

        CallStack.add_undo_operation(UndoHandlers.ADD_ACTIVITY_HANDLER,self.__activity_controller,Activity(activity_id,date,time,description))

        self.__activity_controller.add(activity_id,date,time,description)
示例#2
0
    def update_participation(self):
        participation_id = input("participation id:")

        if not Common.get_type(participation_id) is int:
            raise ValueError("Participation id must be an integer.")

        participation_id = int(participation_id)

        person_id = input("person_id:")

        if not Common.get_type(person_id) is int:
            raise ValueError("Person id must be an integer.")

        person_id = int(person_id)

        activity_id = input("activity id:")

        if not Common.get_type(activity_id) is int:
            raise ValueError("Activity id must be an integer.")
        
        activity_id = int(activity_id)

        CallStack.add_undo_operation(UndoHandlers.UPDATE_PARTICIPATION_HANDLER,self.__participation_controller,self.__participation_controller.find_by_id(participation_id))

        self.__participation_controller.update(participation_id,person_id,activity_id)
示例#3
0
    def remove_participation(self):
        participation_id = input("participation id:")

        if not Common.get_type(participation_id) is int:
            raise ValueError("Participation id must be an integer.")

        participation_id = int(participation_id)

        CallStack.add_undo_operation(UndoHandlers.DELETE_PARTICIPATION_HANDLER,self.__participation_controller,self.__participation_controller.find_by_id(participation_id))

        self.__participation_controller.remove(participation_id)
示例#4
0
    def remove_person(self):
        person_id = input("person id:")

        if not Common.get_type(person_id) is int:
            raise ValueError("Person id must be an integer.")

        person_id = int(person_id)
        
        CallStack.add_undo_operation(UndoHandlers.DELETE_PERSON_HANDLER,self.__person_controller,self.__person_controller.find_by_id(person_id),self.__participation_controller,self.__participation_controller.find_by_person_id(person_id))

        self.__person_controller.remove(person_id)
        # also delete the participations for this person
        self.__participation_controller.delete_by_person_id(person_id)
示例#5
0
    def remove_activity(self):
        activity_id = input("activity id:")

        if not Common.get_type(activity_id) is int:
            raise ValueError("Activity id must be an integer.")

        activity_id = int(activity_id)

        CallStack.add_undo_operation(UndoHandlers.DELETE_ACTIVITY_HANDLER,self.__activity_controller,self.__activity_controller.find_by_id(activity_id),self.__participation_controller,self.__participation_controller.find_by_activity_id(activity_id))
        
        # remove the activity
        self.__activity_controller.remove(activity_id)

        # we can also remove the participations that have this activity
        self.__participation_controller.delete_by_activity_id(activity_id)
示例#6
0
    def update_person(self):
        person_id = input("person id:")

        if not Common.get_type(person_id) is int:
            raise ValueError("Person id must be an integer.")

        person_id = int(person_id)

        name = input("name:")

        phone_number = input("phone number:")

        address = input("address:")

        CallStack.add_undo_operation(UndoHandlers.UPDATE_PERSON_HANDLER,self.__person_controller,self.__person_controller.find_by_id(person_id))
        
        self.__person_controller.update(person_id,name,phone_number,address)