zFix users
This commit is contained in:
@@ -447,7 +447,7 @@ def get_office_sidebar():
|
||||
|
||||
@api.route('/office/users', methods=['GET'])
|
||||
def get_office_users():
|
||||
# Call the dashboard service
|
||||
logger.info('API::get office users')
|
||||
filters = {}
|
||||
result = OfficeUsersService.get_office_users(filters)
|
||||
return jsonify(result)
|
||||
|
||||
@@ -4,32 +4,40 @@ from app.api.services.base_service import BaseService
|
||||
from sqlalchemy import func, desc
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from app.extensions import db
|
||||
from app.models import MembersProducts, Products, Members, ProductsDetails, ProductsDetails, ProvisionActions, Payments, \
|
||||
OfficeUsers
|
||||
from app.models import OfficeUsers
|
||||
|
||||
|
||||
class OfficeUsersService(BaseService):
|
||||
|
||||
@staticmethod
|
||||
def get_office_users(filters):
|
||||
office_users = OfficeUsers.get_office_users_list()
|
||||
office_users_data = []
|
||||
if office_users:
|
||||
for t in office_users:
|
||||
office_users_data.append({
|
||||
'id': t.id,
|
||||
'uid': t.uid,
|
||||
'product_id': t.product_id,
|
||||
'description': t.description,
|
||||
'name': t.name,
|
||||
'status': t.status,
|
||||
'added': t.added.isoformat() if t.added else None,
|
||||
'updated': t.updated.isoformat() if t.updated else None,
|
||||
'banner': t.banner,
|
||||
})
|
||||
logger.info('get office users')
|
||||
try:
|
||||
office_users = OfficeUsers.get_office_users_list()
|
||||
office_users_data = []
|
||||
if office_users:
|
||||
for t in office_users:
|
||||
office_users_data.append({
|
||||
'id': t.id,
|
||||
'uid': t.uid,
|
||||
'username': t.username,
|
||||
'firstname': t.firstname,
|
||||
'lastname': t.lastname,
|
||||
'acc_level': t.acc_level,
|
||||
'status': t.status,
|
||||
'added': t.added.isoformat() if t.added else None
|
||||
})
|
||||
|
||||
office_users_result = {
|
||||
"office_users": office_users_data,
|
||||
}
|
||||
return office_users_result
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {str(e)}", exc_info=True)
|
||||
office_users_result = {
|
||||
"error": f"An error occurred: {str(e)}",
|
||||
}
|
||||
return office_users_result
|
||||
|
||||
office_users_result = {
|
||||
"office_users": office_users_data,
|
||||
}
|
||||
|
||||
return office_users_result
|
||||
|
||||
@@ -37,9 +37,6 @@ class OfficeUsers(db.Model):
|
||||
|
||||
@classmethod
|
||||
def get_office_users_list(cls):
|
||||
"""
|
||||
Return all offers in dictionary format.
|
||||
"""
|
||||
users_list = cls.query.all()
|
||||
|
||||
if not users_list:
|
||||
|
||||
Reference in New Issue
Block a user