office user
This commit is contained in:
@@ -38,27 +38,30 @@ class OfficeUsers(db.Model):
|
||||
@classmethod
|
||||
def get_office_users_list(cls):
|
||||
users_list = cls.query.all()
|
||||
|
||||
if not users_list:
|
||||
raise ValueError(f"No available users")
|
||||
return users_list
|
||||
|
||||
@classmethod
|
||||
def get_office_user_id(cls, user_id):
|
||||
"""
|
||||
Get customer's active loans by loan_id.
|
||||
"""
|
||||
users_list = cls.query.filter_by(id=user_id).first()
|
||||
if not users_list:
|
||||
# raise ValueError(f"pProduct with ID {product_id} does not exist.")
|
||||
logger.error(f"users_list with ID {user_id} does not exist.")
|
||||
return None
|
||||
return users_list
|
||||
|
||||
@classmethod
|
||||
def get_office_user_by_username(cls, username):
|
||||
logger.info(f"users_list looking for {username} .")
|
||||
users_list = cls.query.filter_by(username=username).first()
|
||||
logger.info(f"users_list looking for {username} after.")
|
||||
if not users_list:
|
||||
logger.error(f"users_list with ID {user_id} does not exist.")
|
||||
return None
|
||||
return users_list
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Convert the Loan object to a dictionary format for JSON serialization.
|
||||
"""
|
||||
return {
|
||||
'id': self.id,
|
||||
'uid': self.uid,
|
||||
|
||||
Reference in New Issue
Block a user