Initial commit
This commit is contained in:
commit
ff50ea6784
12 changed files with 509 additions and 0 deletions
38
controllers/catalog_controller.py
Normal file
38
controllers/catalog_controller.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from models.toy_model import ToyModel
|
||||
from views.catalog_view import CatalogView
|
||||
|
||||
|
||||
class CatalogController:
|
||||
def __init__(self, database, full_name, role, auth):
|
||||
self.database = database
|
||||
self.model = ToyModel(database)
|
||||
self.view = CatalogView(full_name, role)
|
||||
self.auth = auth
|
||||
self.role = role
|
||||
|
||||
self.view.refresh_button.clicked.connect(
|
||||
self.load_data
|
||||
)
|
||||
self.view.sort_button.clicked.connect(
|
||||
self.sort_by_price
|
||||
)
|
||||
self.view.logout_button.clicked.connect(
|
||||
self.logout
|
||||
)
|
||||
|
||||
self.load_data()
|
||||
|
||||
def show(self):
|
||||
self.view.show()
|
||||
|
||||
def load_data(self):
|
||||
toys = self.model.get_all()
|
||||
self.view.load_data(toys)
|
||||
|
||||
def sort_by_price(self):
|
||||
toys = self.model.sort_by_price()
|
||||
self.view.load_data(toys)
|
||||
|
||||
def logout(self):
|
||||
self.view.close()
|
||||
self.auth.show()
|
||||
Loading…
Add table
Add a link
Reference in a new issue