chefboyrd package¶
Subpackages¶
- chefboyrd.controllers package
- Submodules
- chefboyrd.controllers.booking_controller module
- chefboyrd.controllers.customer_controller module
- chefboyrd.controllers.data_controller module
- chefboyrd.controllers.feedback_controller module
- chefboyrd.controllers.model_controller module
- chefboyrd.controllers.prediction_controller module
- Module contents
- chefboyrd.models package
- chefboyrd.tests package
- chefboyrd.views package
Submodules¶
chefboyrd.auth module¶
Module for authentication and authorization
- written by: Zachary Blanco
- tested by: Zachary Blanco
- debugged by: Zachary Blanco
Uses the flask-login plugin as well as some custom wrapper functions to ensure that logged in users are only able to access authorized resources.
-
chefboyrd.auth.
require_login
(func)[source]¶ Wrapper around the login_required wrapper from flask-login
This allows us to keep the same style and also not have to have multiple imports for roles and require_login
-
chefboyrd.auth.
require_role
(role, **kwargss)[source]¶ Decorate a function with this in order to require a specific role(s), to access a view.
Also decorates a function, so that you must pass the current user’s role into it’s first argument if it’s needed.
By decorating a function with @require_role you are implicity forcing @login_required as well. Example:
@APP.route('/admin-dashboard') @require_role('admin') def view_dash(): # Something here @APP.route('/reservationH') @require_role('admin','host',getrole=True) def view_dash(role): ...
Parameters: role (list or str) – A single role name or list of role names for which users are allowed to access the specified resource If a user is not authorized then the flask_login.unauthorized handler is called.
Module contents¶
Main file to register blueprints and run the flask application
written by: Zachary Blanco, Jeffrey Huang, Seo Bo Shim, Brandon Smith, Jarod Morin tested by: Zachary Blanco, Jeffrey Huang, Seo Bo Shim, Brandon Smith, Jarod Morin debugged by: Zachary Blanco, Jeffrey Huang, Seo Bo Shim, Brandon Smith, Jarod Morin
This is where most of the app setup is done. We shouldn’t have to modify this file except for two different cases:
- We are adding new views to the application
- We are adding new models to the application
Otherwise this file should not be touched.
Every view which is to be part of the app must be registered appropriately using:
APP.register_blueprint(viewpage, ...)
Other args to register_blueprint might include the url_prefix if you want your pages to reside on a specific path.
If models are being added we just need to make sure the corresponding tables are created (if they don’t already exist) when starting the application. We do this by making the call
model.create_table(True)
The True
argument forces any failures to be silent when creating the table - i.e. not crash
the application. Other than that we shouldn’t need to add much else to this file.
Please see the following files for examples of each part of the MVC structure of this project
- Model ==> models/customers.py
- View ==> views/root.py
- Controller ==> controllers/customer_controller.py
Other helpful sources of documentaiton and reading:
- http://docs.peewee-orm.com/en/latest/index.html
- https://github.com/coleifer/peewee (See example apps at the bottom of the readme)
- http://flask.pocoo.org/docs/0.12/blueprints/