def create_user(firstname, lastname, email, pwd, promo): status = False email = email.lower() if not user_exists(email): hashedpwd = bcrypt.hashpw(pwd.encode(), bcrypt.gensalt()).decode() UserCRUD.create(firstname, lastname, email, hashedpwd, promo) return True return False
def delete_user(uid): UserLocationCRUD.delete(uid=uid) UserPreferencesCRUD.delete(uid=uid) UserCRUD.delete(uid=uid)
def update_user(uid, **kwargs): return UserCRUD.update(uid, **kwargs)
def search_users(filters): # retrieve and normalize filters promo_filter = normalize_filter(filters.get('promo', None)) firstname_filter = normalize_filter(filters.get('firstname', None)) lastname_filter = normalize_filter(filters.get('lastname', None)) return UserCRUD.search(firstname_filter, lastname_filter, promo_filter)
def retrieve_all_users(): (s, q) = UserCRUD.retrieve() res = q.all() s.close() return res
def retrieve_user_by_email(email): email = email.lower() (s, q) = UserCRUD.retrieve(email=email) res = q.one_or_none() s.close() return res
def retrieve_user_by_id(uid): (s, q) = UserCRUD.retrieve(uid=uid) res = q.one_or_none() s.close() return res