Member Action
This commit is contained in:
+42
-13
@@ -7,7 +7,7 @@ from marshmallow import ValidationError
|
||||
from app.api.enums import TransactionType
|
||||
from app.api.integrations import SimbrellaIntegration
|
||||
from app.extensions import db
|
||||
from app.models import Offer, RACCheck, Members
|
||||
from app.models import Offer, RACCheck, Members, MembersActions
|
||||
from app.api.services.offer_analysis import OfferAnalysis
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
@@ -40,20 +40,49 @@ class AccountService(BaseService):
|
||||
|
||||
@staticmethod
|
||||
def process_action_request(data):
|
||||
bar_data = {
|
||||
|
||||
member_actions = MembersActions.get_recent_member_actions(data)
|
||||
member_actions_data = []
|
||||
|
||||
for t in member_actions:
|
||||
product_data.append({
|
||||
'id': t.id,
|
||||
'uid': t.uid,
|
||||
'product_id': t.product_id,
|
||||
'name': t.name,
|
||||
'description': t.description,
|
||||
'status': t.status,
|
||||
'added': t.added,
|
||||
'updated': t.updated,
|
||||
'banner': t.banner
|
||||
})
|
||||
|
||||
action_data = {
|
||||
"recent_actions": member_actions_data,
|
||||
"last_update": datetime.datetime.utcnow(),
|
||||
"top_bar": [
|
||||
{"id": "1", "description": "Contacts", "last_update": "10-10-2010 11:00 AM",
|
||||
"value": random.randint(0, 10), "data_span": 'Last 2 months'},
|
||||
{"id": "2", "description": "Site Traffic", "last_update": "10-10-2010 11:30 AM",
|
||||
"value": random.randint(0, 10), "data_span": 'Past 12 hours'},
|
||||
{"id": "3", "description": "Appointments", "last_update": "10-12-2010 11:30 AM",
|
||||
"value": random.randint(0, 10), "data_span": 'Last 14 days'},
|
||||
{"id": "4", "description": "Purchases", "last_update": "10-12-2010 11:30 AM",
|
||||
"value": random.randint(0, 10), "data_span": 'Last 3 months'},
|
||||
]
|
||||
"initial": random.randint(0, 10),
|
||||
"processing": random.randint(0, 10),
|
||||
"verifying": random.randint(0, 10),
|
||||
"completed": random.randint(0, 10),
|
||||
"actions": member_actions_data
|
||||
}
|
||||
return ResponseHelper.success(data=bar_data)
|
||||
|
||||
logger.info(f"Member Actions Error: {action_data}")
|
||||
|
||||
# bar_data = {
|
||||
# "last_update": datetime.datetime.utcnow(),
|
||||
# "top_bar": [
|
||||
# {"id": "1", "description": "Contacts", "last_update": "10-10-2010 11:00 AM",
|
||||
# "value": random.randint(0, 10), "data_span": 'Last 2 months'},
|
||||
# {"id": "2", "description": "Site Traffic", "last_update": "10-10-2010 11:30 AM",
|
||||
# "value": random.randint(0, 10), "data_span": 'Past 12 hours'},
|
||||
# {"id": "3", "description": "Appointments", "last_update": "10-12-2010 11:30 AM",
|
||||
# "value": random.randint(0, 10), "data_span": 'Last 14 days'},
|
||||
# {"id": "4", "description": "Purchases", "last_update": "10-12-2010 11:30 AM",
|
||||
# "value": random.randint(0, 10), "data_span": 'Last 3 months'},
|
||||
# ]
|
||||
# }
|
||||
return ResponseHelper.success(data=action_data)
|
||||
|
||||
@staticmethod
|
||||
def process_request(data):
|
||||
|
||||
@@ -14,9 +14,9 @@ from .salary import Salary
|
||||
from .members import Members
|
||||
from .products import Products
|
||||
from .members_products import MembersProducts
|
||||
|
||||
from .members_actions import MembersActions
|
||||
|
||||
__all__ = ['Members','Customer', 'Account', 'Products',
|
||||
'MembersProducts', 'Loan', 'Transaction', 'Repayment',
|
||||
'MembersProducts', 'MembersActions', 'Loan', 'Transaction', 'Repayment',
|
||||
'LoanCharge', 'Offer', 'Charge', 'RACCheck', 'LoanRepaymentSchedule',
|
||||
'TransactionOffer', 'RepaymentsData', 'Salary']
|
||||
@@ -0,0 +1,67 @@
|
||||
from datetime import datetime, timezone, timedelta
|
||||
from itertools import product
|
||||
from app.extensions import db
|
||||
from app.models.customer import Customer
|
||||
from app.models.account import Account
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import relationship
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from sqlalchemy import and_, or_, not_
|
||||
from sqlalchemy.sql import func
|
||||
import json
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class MembersActions(db.Model):
|
||||
__tablename__ = 'members_actions'
|
||||
|
||||
id = db.Column(
|
||||
db.Integer,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
)
|
||||
|
||||
uid = db.Column(db.String(150), nullable=False)
|
||||
member_id = db.Column(db.Integer, nullable=False)
|
||||
member_uid = db.Column(db.String(150), nullable=False)
|
||||
action_label = db.Column(db.String(35), nullable=False)
|
||||
action_name = db.Column(db.String(100), nullable=False)
|
||||
status_description = db.Column(db.String(25), nullable=False)
|
||||
status = db.Column(db.Integer, nullable=True, default=0)
|
||||
added = db.Column(db.DateTime(timezone=True), server_default=func.now())
|
||||
updated = db.Column(db.DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
|
||||
|
||||
@classmethod
|
||||
def get_recent_member_actions(cls, member_id):
|
||||
"""
|
||||
Return all offers in dictionary format.
|
||||
query = cls.query
|
||||
"""
|
||||
member_actions = cls.query.limit(4).all()
|
||||
|
||||
if not member_actions:
|
||||
raise ValueError(f"No Member Actions")
|
||||
return member_actions
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Convert the Loan object to a dictionary format for JSON serialization.
|
||||
"""
|
||||
return {
|
||||
'id': self.id,
|
||||
'uid': self.uid,
|
||||
'product_id': self.product_id,
|
||||
'name': self.name,
|
||||
'description' : self.description,
|
||||
'status': self.status,
|
||||
'added': self.added,
|
||||
'updated': self.updated,
|
||||
'banner': self.banner
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f'<Products {self.id}>'
|
||||
Reference in New Issue
Block a user