예제 #1
0
def run():
    """
	Starts this module and displays its menu.
	* User can access default special features from here.
	* User can go back to main menu from here.

	Returns:
		None
	"""
    list_options = [
        'Human resources', 'Show all people', 'Add', 'Remove', 'Update',
        'Get oldest person', 'Get persons closest to average',
        'Exit to main menu'
    ]
    list_labels = [['Name', 'name'], ['Birth year', 'year']]
    data_file = "model/hr/persons.csv"
    crud_module = hr
    while True:
        table = data_manager.get_table_from_file(data_file)
        max_id = len(table)
        user_choice = terminal_view.get_choice(list_options)
        if user_choice in ['1', '2', '3', '4']:
            make_crud(crud_module, list_labels, list_options, max_id, table,
                      user_choice)
        elif user_choice == '5':
            terminal_view.print_result(hr.get_oldest_person(table),
                                       'Get oldest person:')
        elif user_choice == '6':
            terminal_view.print_result(
                hr.get_persons_closest_to_average(table),
                'Get persons closest to average:')
        elif user_choice == '0':
            break
        else:
            terminal_view.print_error_message("There is no such choice.")
예제 #2
0
def run():
	"""
	Starts this module and displays its menu.
	* User can access default special features from here.
	* User can go back to main menu from here.

	Returns:
		None
	"""
	
	list_options = [
		'Sales',
		'Show all data',
		'Add',
		'Remove',
		'Update',
		'Get lowest price item id',
		'Get items sold between',
		'Exit to main menu'
	]
	data_file = "model/sales/sales.csv"
	crud_module = sales
	while True:
		table = data_manager.get_table_from_file(data_file)
		max_id = len(table)
		list_labels = [
			['Title', str],
			['Price', int],
			['Month', 'month'],
			['Day', 'day'],
			['Year', 'year'],
			['Customer', str]
		]
		user_choice = terminal_view.get_choice(list_options)
		if user_choice in ['1', '2', '3', '4']:
			make_crud(crud_module, list_labels, list_options, max_id, table, user_choice)
		elif user_choice == '5':
			result = sales.get_lowest_price_item_id(table)
			terminal_view.print_result(result, "Lowest price item ID")
		elif user_choice == '6':
			inputs_labels_between = [
				['Date from', 'date'],
				['Date to', 'date'],
			]
			inputs = terminal_view.get_inputs(['must'] + inputs_labels_between, 'Date from to')
			inputs = [int(item) for item in inputs]
			result = sales.get_items_sold_between(table, *inputs)
			print(common.bcolors.WARNING + common.bcolors.BOLD)
			terminal_view.os.system('clear')
			if common.check_if_empty(result):
				terminal_view.print_table(result, list_labels)
			print(common.bcolors.ENDC)
		
		elif user_choice == '0':
			break
		
		else:
			terminal_view.print_error_message("There is no such choice.")
def run():
	"""
	Starts this module and displays its menu.
	* User can access default special features from here.
	* User can go back to main menu from here.

	Returns:
		None
	"""

	list_options = [
			'Customer Relations Management',
			'Show all customers',
			'Add',
			'Remove',
			'Update',
			'Get ID of the customer with the longest name',
			'Get customers subscribed to newsletter',
			'Exit to main menu'
		]
	data_file = "model/crm/customers.csv"
	crud_module = crm
	while True:
		table = data_manager.get_table_from_file(data_file)
		max_id = len(table)
		list_labels = [
			['Name', 'name'],
			['Email', 'email'],
			['Subscription', 'subscription']
		]
		user_choice = terminal_view.get_choice(list_options)
		if user_choice in ['1', '2', '3', '4']:
			make_crud(crud_module, list_labels, list_options, max_id, table, user_choice)
		elif user_choice == '5':
			result = crm.get_longest_name_id(table)
			terminal_view.print_result(result, "ID of the customer with the longest name")
		elif user_choice == '6':
			result = crm.get_subscribed_emails(table)
			terminal_view.print_result(result, "Customers subscribed to the newsletter")
		elif user_choice == '0':
			break
		else:
			terminal_view.print_error_message("There is no such choice.")
def run():
    """
	Starts this module and displays its menu.
	* User can access default special features from here.
	* User can go back to main menu from here.

	Returns:
		None
	"""

    list_options = [
        'Inventory', 'Show all data', 'Add', 'Remove', 'Update',
        'Get available items', 'Get average durability by manufacturers',
        'Exit to main menu'
    ]
    list_labels = [['Name of console', str], ['Manufacturer', str],
                   ['Purchase year', "year"], ['Durability', "durability"]]
    data_file = "model/inventory/inventory.csv"
    crud_module = inventory
    while True:
        table = data_manager.get_table_from_file(data_file)
        max_id = len(table)
        user_choice = terminal_view.get_choice(list_options)
        if user_choice in ['1', '2', '3', '4']:
            make_crud(crud_module, list_labels, list_options, max_id, table,
                      user_choice)
        elif user_choice == '5':
            print(bcolors.WARNING + bcolors.BOLD)
            terminal_view.print_table(inventory.get_available_items(table),
                                      list_labels)
            print(bcolors.ENDC)
        elif user_choice == '6':
            terminal_view.print_result(
                inventory.get_average_durability_by_manufacturers(table),
                'Average durability by manufactures')
        elif user_choice == '0':
            break
        else:
            terminal_view.print_error_message("There is no such choice.")
def run():
    """
	Starts this module and displays its menu.
	* User can access default special features from here.
	* User can go back to main menu from here.

	Returns:
		None
	"""

    list_options = [
        'Accounting', 'Show all data', 'Add', 'Remove', 'Update',
        'Year with the highest profit', 'Average amount', 'Exit to main menu'
    ]
    list_labels = [['Month', 'month'], ['Day', 'day'], ['Year', 'year'],
                   ['Type', 'type'], ['Amount', int]]
    data_file = "model/accounting/items.csv"
    crud_module = accounting
    while True:
        table = data_manager.get_table_from_file(data_file)
        max_id = len(table)
        user_choice = terminal_view.get_choice(list_options)
        if user_choice in ['1', '2', '3', '4']:
            make_crud(crud_module, list_labels[:], list_options, max_id, table,
                      user_choice)
        elif user_choice == '5':
            terminal_view.print_result(accounting.which_year_max(table),
                                       'Year with the highest income')
        elif user_choice == '6':
            year = terminal_view.get_inputs(['must'] + [
                ['Year to get average', 'year'],
            ], '')
            terminal_view.print_result(accounting.avg_amount(table, year[0]),
                                       'Average')
        elif user_choice == '0':
            break
        else:
            terminal_view.print_error_message("There is no such choice.")
def run():
    """
	Starts this module and displays its menu.
	* User can access default special features from here.
	* User can go back to main menu from here.
	"""

    list_options = [
        'Store', 'Show all data', 'Add', 'Remove', 'Update',
        'Get counts by manufacturers', 'Get average by manufacturer',
        'Exit to main menu'
    ]
    list_labels = [['Title', str], ['Manufacturer', str], ['Price', int],
                   ['In stock', int]]
    data_file = "model/store/games.csv"
    crud_module = store
    while True:
        table = data_manager.get_table_from_file(data_file)
        max_id = len(table)
        user_choice = terminal_view.get_choice(list_options)
        if user_choice in ['1', '2', '3', '4']:
            make_crud(crud_module, list_labels, list_options, max_id, table,
                      user_choice)
        elif user_choice == '5':
            terminal_view.print_result(
                store.get_counts_by_manufacturers(table),
                'Counts by manufactures')
        elif user_choice == '6':
            manufacturer = terminal_view.get_inputs([
                ['Manufacturer to get average', str],
            ], 'Manufacturer')
            terminal_view.print_result(
                store.get_average_by_manufacturer(table, *manufacturer),
                'Average by {}'.format(*manufacturer))
        elif user_choice == '0':
            break
        else:
            terminal_view.print_error_message("There is no such choice.")