traisl date end

This commit is contained in:
CHIEFSOFT\ameye
2025-08-30 09:12:31 -04:00
parent 037ef64694
commit a604aeba8a
4 changed files with 15 additions and 4 deletions
+11 -2
View File
@@ -1,4 +1,4 @@
from datetime import datetime, timezone
from datetime import datetime, timezone, timedelta
from app.extensions import db
from sqlalchemy.sql import func
from sqlalchemy.exc import IntegrityError
@@ -25,6 +25,7 @@ class Members(db.Model):
stripe_customer_id = db.Column(db.String(100), nullable=True)
option_name = db.Column(db.String(100), nullable=True)
next_billing= db.Column(db.DateTime(timezone=False))
trial_end = db.Column(db.DateTime(timezone=False))
def to_dict(self):
return {
@@ -45,6 +46,7 @@ class Members(db.Model):
"lastname": self.lastname,
'option_name': self.option_name,
"next_billing": self.next_billing,
"trial_end": self.trial_end,
"stripe_customer_id": self.stripe_customer_id
}
@@ -80,7 +82,13 @@ class Members(db.Model):
@classmethod
def add_member(cls, firstname, lastname, email, username,password, country):
def add_member(cls, firstname, lastname, email, username,password, country, trials_days = 90):
# Get the current date and time
current_date = datetime.now()
# Calculate the date "next_billing_days" days from now
trial_end = current_date + timedelta(days=trials_days)
# Save the response
member_data = cls(
@@ -91,6 +99,7 @@ class Members(db.Model):
email=email,
country=country,
password=password,
trial_end=trial_end,
added=datetime.now(timezone.utc),
updated=datetime.now(timezone.utc)
)