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