24 lines
795 B
Python
24 lines
795 B
Python
from datetime import datetime
|
|
from app import db
|
|
|
|
class Customer(db.Model):
|
|
__tablename__ = 'customers'
|
|
__table_args__ = {'schema': 'flask_app'}
|
|
|
|
id = db.Column(db.String(50), primary_key=True)
|
|
msisdn = db.Column(db.String(20), unique=True, nullable=False)
|
|
country_code = db.Column(db.String(3), nullable=False)
|
|
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
|
updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
@classmethod
|
|
def is_eligible(cls, customer_id):
|
|
customer = cls.query.filter_by(id=customer_id).first()
|
|
if not customer:
|
|
return False, "Customer not found"
|
|
return True, "Customer is eligible"
|
|
|
|
def __repr__(self):
|
|
return f'<Customer {self.id}>'
|
|
|