| |
- client()
- Renders appropriate template (admin or user)
:return: redirects home if not logged in,
renders admin.html if logged in as admin,
user.html otherwise
- create_user()
- Callable from admin.html only
Adds a new user to db by calling db_create_user, then re-renders admin template
:return: redirects to home if user not logged in,
re-renders admin.html otherwise
- db_check_creds(un: str, pw: str) -> bool
- Checks to see if supplied username and password are in the DB's credentials table
:param un: username to check
:param pw: password to check
:return: True if both username and password are correct, False otherwise.
- db_create_user(un: str, pw: str) -> None
- Add provided user and password to the credentials table
Add provided user to the userfoods table
and sets their favorite food to "not set yet"
:param un: username to create
:param pw: password to create
:return: None
- db_get_food(un: str) -> str
- Gets the provided user's favorite food from the DB
:param un: username to get favorite food of
:return: the favorite food of the provided user as a string
- db_get_user_list() -> dict
- Queries the DB's userfoods table to get a list
of all the user and their corresponding favorite food for display on admin.html
:return: a dictionary with username as key and their favorite food as value
this is what populates the 'result' variable in the admin.html template
- db_remove_user(un: str) -> None
- Removes provided user from all DB tables
:param un: username to remove from DB
:return: None
- db_set_food(un: str, ff: str) -> None
- Sets the favorite food of user, un param, to new incoming ff (favorite food) param
:param un: username to update favorite food of
:param ff: user's new favorite food
:return: None
- home()
- Checks whether the user is logged in and returns appropriately.
:return: renders login.html if not logged in,
redirects to client otherwise.
- login()
- Allows client to log in
Calls db_check_creds to see if supplied username and password are correct
:return: redirects to client if login correct,
redirects back to home otherwise
- logout()
- Logs client out, then routes to login
Remove the user from the session
:return: redirects back to home
- remove_user()
- Callable from admin.html only
Removes user from the db by calling db_remove_user, then re-renders admin template.
:return: redirects to home if user not logged in,
re-renders admin.html otherwise
- set_food()
- Callable from user.html only,
Updates user food by calling db_set_food, then re-renders user template
:return: redirects to home if user not logged in,
re-renders user.html otherwise
|