Add subscriotn
This commit is contained in:
@@ -40,7 +40,11 @@ class MyProductsService(BaseService):
|
||||
mumberSub = MembersProducts.get_member_product_by_product__member_id(member_id, product_id)
|
||||
if not mumberSub:
|
||||
logger.error(f"Ready to add data to tables")
|
||||
|
||||
internal_url = str(random.randint(10000, 99999)) + ".devprov.mermsemr.com"
|
||||
#INSERT_NEW_PRODUCT = "INSERT INTO members_products (member_id ,product_id,status,internal_url) VALUES (%s, %s, %s, %s)"
|
||||
# val_insert = (member_id, product_id,6,internal_url)
|
||||
status = 6
|
||||
MembersProducts.create_subscription(member_id ,product_id,status,internal_url)
|
||||
|
||||
response_data = {
|
||||
"subscription": "No ready",
|
||||
|
||||
@@ -47,6 +47,22 @@ class MembersProducts(db.Model):
|
||||
return None
|
||||
return member_product
|
||||
|
||||
@classmethod
|
||||
def create_subscription(cls, member_id ,product_id,status,internal_url):
|
||||
# Create the subscription
|
||||
subscription = cls(
|
||||
member_id=member_id,
|
||||
product_id=product_id,
|
||||
status=status,
|
||||
internal_url=internal_url
|
||||
)
|
||||
|
||||
try:
|
||||
db.session.add(subscription)
|
||||
except IntegrityError as err:
|
||||
raise ValueError(f"Database integrity error: {err}")
|
||||
return subscription
|
||||
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user