Esempio n. 1
0
def main():

    # configure logging
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)

    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    root.addHandler(handler)

    logging.info("Start 2eat App")

    # Init db
    logging.info("Init database")
    database_engine = DatabaseEngine(url='sqlite:///database.db')
    database_engine.create_database()

    # controller
    restaurant_controller = RestaurantController(database_engine)
    product_controller = ProductController(database_engine)
    person_controller = PersonController(database_engine)
    basket_controller = BasketController(database_engine)
    order_controller = OrderController(database_engine)
    # init vue
    root = RootFrame(restaurant_controller, product_controller,
                     person_controller, basket_controller, order_controller)
    root.master.title("2eat subscription app")
    root.show_auth_portal()

    # start
    root.mainloop()
Esempio n. 2
0
def main():

    # configure logging
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)

    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    root.addHandler(handler)

    logging.info("Start BDS App")

    # Init db
    logging.info("Init database")
    database_engine = DatabaseEngine(url='sqlite:///bds.db')
    database_engine.create_database()

    # controller
    person_controller = PersonController(database_engine)
    sport_controller = SportController(database_engine)

    # init vue
    root = RootFrame(person_controller, sport_controller)
    root.master.title("bds subscription app")
    root.show_menu_connexion()

    # start
    root.mainloop()
Esempio n. 3
0
    def setUp(self):
        self.person_repository = Repository(PersonValidator)
        self.person_controller = PersonController(self.person_repository)

        self.activity_repository = Repository(ActivityValidator)
        self.activity_controller = ActivityController(self.activity_repository)

        self.repository = Repository(ParticipationValidator)
        self.controller = ParticipationController(self.repository,
                                                  self.person_controller,
                                                  self.activity_controller)

        # add test data
        self.person_controller.add(1, "John", "1234567890", "street 1")
        self.person_controller.add(2, "John", "1234567890", "street 1")
        self.person_controller.add(3, "John", "1234567890", "street 1")

        self.activity_controller.add(1, Common.convert_to_date("15.11.2016"),
                                     Common.convert_to_time("06:03"),
                                     "description")
        self.activity_controller.add(2, Common.convert_to_date("16.11.2016"),
                                     Common.convert_to_time("06:03"),
                                     "description")
        #self.activity_controller.add(3,Common.convert_to_date("16.11.2016"),Common.convert_to_time("06:04"),"description")
        #self.activity_controller.add(4,Common.convert_to_date("16.11.2016"),Common.convert_to_time("06:06"),"description")

        return super().setUp()
    def start_session(self):
        # profile may be:
        # - a string if loging is invalid OR user is ADMIN
        # - an Account object, if a customer performed a successful login
        # - a person object, if a manager performed a successful login
        profile = self.login()
        if profile == 'invalid':
            return

        option = -1
        while option != 0:
            # Shows main menu according to profile
            option = self.view.show_main_menu(profile)
            # client - account deposit
            if option == 1:
                AccountController().create_transaction(profile, 'Deposit')
            # client - account withdrawal
            elif option == 2:
                AccountController().create_transaction(profile, 'Withdrawal')
            # client - account balance
            elif option == 3:
                AccountController().list_balance(profile)
            # client - account history
            elif option == 4:
                AccountController().list_statement(profile)
            # admin - create branch
            elif option == 100:
                BranchController().create_branch()
            # admin - list branches
            elif option == 101:
                BranchController().list_branches()
            # admin - create manager
            elif option == 102:
                PersonController().create_person('Manager')
            # admin - list managers
            elif option == 103:
                PersonController().list_people('Manager')
            # manager-create account
            elif option == 200:
                AccountController().create_account()
            # manager-list accounts
            elif option == 201:
                AccountController().list_client_accounts()
            elif option != 0:
                self.view.show_message('Error',
                                       'Invalid option. Please try again.',
                                       True)
Esempio n. 5
0
def main():
    print("Welcome in BDS App")

    # Init db
    database_engine = DatabaseEngine(url='sqlite:///bds.db')
    database_engine.create_database()


    # controller
    person_controller = PersonController(database_engine)
    sport_controller = SportController(database_engine)
    planning_controller = SportController(database_engine) #a changer

    # init vue
    root = RootFrame(person_controller, sport_controller, planning_controller)
    root.master.title("bds subscription app")
    root.show_menu()

    # start
    root.mainloop()
Esempio n. 6
0
 def setUp(self) -> None:
     """
     Function called before each test
     """
     self.person_controller = PersonController(self._database_engine)
Esempio n. 7
0
from repository.file_repository import FileRepository
from repository.pickle_repository import PickleRepository
from ui.Config import Config, StorageType

if __name__=="__main__":
    #try:
        config = Config("settings.properties")
        config.parse_config()

        print(config.storage_type)

        if(config.storage_type=="inmemory"):
            person_repository = Repository(PersonValidator)
            activity_repository = Repository(ActivityValidator)
            participation_repository = Repository(ParticipationValidator)
            person_controller = PersonController(person_repository)
            activity_controller = ActivityController(activity_repository)
            participation_controller=ParticipationController(participation_repository,person_controller,activity_controller)
            console = Console(person_controller,activity_controller,participation_controller)
            console.run()
            print("True")
        
        if(config.storage_type=="infile"):
            person_repository = FileRepository(config.person_repository,PersonController.read_entity,PersonController.write_entity,PersonValidator)
            activity_repository = FileRepository(config.activity_repository,ActivityController.read_entity,ActivityController.write_entity,ActivityValidator)
            participation_repository = FileRepository(config.participation_repository,ParticipationController.read_entity,ParticipationController.write_entity,ParticipationController)
            person_controller = PersonController(person_repository)
            activity_controller = ActivityController(activity_repository)
            participation_controller=ParticipationController(participation_repository,person_controller,activity_controller)
            console = Console(person_controller,activity_controller,participation_controller)
            console.run()
Esempio n. 8
0
def _create_person_controller():
    return PersonController(DatabaseEngine(url='sqlite:///bds.db'))