my product settings start
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
from marshmallow import Schema, fields
|
||||
|
||||
class MyProductSettingsSchema(Schema):
|
||||
token = fields.Str(required=True)
|
||||
uid = fields.Str(required=True)
|
||||
product_id = fields.Str(required=True)
|
||||
settings = fields.Str( required=False)
|
||||
@@ -22,6 +22,46 @@ class BaseService:
|
||||
SEND_EMAIL_PASS = Config.SEND_EMAIL_PASS
|
||||
THIS_SITE_URL = Config.THIS_SITE_URL
|
||||
|
||||
@staticmethod
|
||||
def send_completepass_mail(signup_email, pending_uid, pending_id, firstname, lastname):
|
||||
msg_body = f"""
|
||||
Hello {firstname},
|
||||
|
||||
Password Reset Completed
|
||||
|
||||
|
||||
For any Support
|
||||
Reach Out
|
||||
support@mermsemr.com
|
||||
"""
|
||||
|
||||
sender_email = BaseService.SEND_EMAIL_FROM
|
||||
sender_password = BaseService.SEND_EMAIL_PASS
|
||||
receiver_email = signup_email
|
||||
subject = "Reset Password Completed"
|
||||
body = msg_body
|
||||
|
||||
msg = MIMEMultipart()
|
||||
msg['Subject'] = subject
|
||||
msg['From'] = sender_email
|
||||
msg['To'] = receiver_email
|
||||
msg.attach(MIMEText(body, 'plain')) # or 'html' for HTML content
|
||||
|
||||
try:
|
||||
# For Gmail, use 'smtp.gmail.com' and port 587 (TLS) or 465 (SSL)
|
||||
# For other providers, consult their documentation for SMTP server and port
|
||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
||||
# server.starttls() # Enable TLS encryption
|
||||
server.login(sender_email, sender_password)
|
||||
server.sendmail(sender_email, receiver_email, msg.as_string())
|
||||
print("Email sent successfully!")
|
||||
except Exception as e:
|
||||
print(f"Error sending email: {e}")
|
||||
logger.error(f"Error sending email: {e}")
|
||||
finally:
|
||||
server.quit() # Close the connection
|
||||
|
||||
|
||||
@staticmethod
|
||||
def send_resetpass_mail(signup_email, pending_uid, pending_id, firstname, lastname):
|
||||
|
||||
|
||||
@@ -176,12 +176,13 @@ class LoginService(BaseService):
|
||||
encrypted_pass = generate_password_hash(new_password)
|
||||
Members.update_user_password(reset_data.id, member["uid"], member["id"], encrypted_pass)
|
||||
# update_user_passowrd(cls, reset_id, member_uid, member_id, new_passwprd_hash)
|
||||
|
||||
BaseService.send_completepass_mail(member.email, str(reset_data.uid), reset_data.id, member.firstname,
|
||||
member.lastname) # pending_uid, pending_id, firstname, lastname
|
||||
|
||||
response_data = {
|
||||
"error_message": "",
|
||||
"reset_message": "Check your email to continue password reset.",
|
||||
"message_key": "check_your_email_message",
|
||||
"reset_message": "Password Reset Completed.",
|
||||
"message_key": "password_reset_completed",
|
||||
}
|
||||
|
||||
return ResponseHelper.success(data=response_data)
|
||||
|
||||
@@ -7,6 +7,7 @@ from app.models import MembersProducts, Products, Members, ProductsDetails, Prod
|
||||
from app.api.helpers.response_helper import ResponseHelper
|
||||
from app.api.schemas.myproduct import MyProductSchema
|
||||
from app.api.schemas.provision import ProvisionSchema
|
||||
from app.api.schemas.myproduct_settings import MyProductSettingsSchema
|
||||
|
||||
import datetime
|
||||
import jwt
|
||||
@@ -155,7 +156,9 @@ class MyProductsService(BaseService):
|
||||
try:
|
||||
with db.session.begin():
|
||||
logger.info(f"Incoming MyProduct Settings Data ==>>>> {data}")
|
||||
validated_data = MyProductsService.validate_data(data, MyProductSchema())
|
||||
settings = data["settings"]
|
||||
data.pop("settings")
|
||||
validated_data = MyProductsService.validate_data(data, MyProductSettingsSchema())
|
||||
token = validated_data.get('token')
|
||||
uid = validated_data.get('uid')
|
||||
|
||||
@@ -181,6 +184,20 @@ class MyProductsService(BaseService):
|
||||
}
|
||||
}
|
||||
|
||||
# my_dict = {"apple": 1, "banana": 2, "cherry": 3}
|
||||
|
||||
for key in settings.keys():
|
||||
# logger.info(f"settings_key : {key}")
|
||||
# logger.info(f"settings_value : {settings[key]}") # Accessing value using the key
|
||||
# logger.info(f"subscription_uid: {memberSubscription.uid}")
|
||||
# logger.info(f"product_id : {product_id}")
|
||||
# logger.info(f"member_id : {member_id}")
|
||||
setting_value = settings[key]
|
||||
subscription_uid = memberSubscription.uid
|
||||
MembersProducts.save_update_product_settings(member_id,subscription_uid,product_id,key, 'TXT', setting_value)
|
||||
|
||||
|
||||
|
||||
# Simulate processing
|
||||
response_data = {
|
||||
"result": result_data,
|
||||
|
||||
@@ -95,6 +95,16 @@ class MembersProducts(db.Model):
|
||||
return subscription
|
||||
|
||||
|
||||
@classmethod
|
||||
def save_update_product_settings(cls, member_id,subscription_uid,product_id,settings_key,setting_type,setting_value ):
|
||||
logger.info(f"settings_key : {settings_key}")
|
||||
logger.info(f"setting_type : {setting_type}")
|
||||
logger.info(f"settings_value : {setting_value}")
|
||||
logger.info(f"subscription_uid: {subscription_uid}")
|
||||
logger.info(f"product_id : {product_id}")
|
||||
logger.info(f"member_id : {member_id}")
|
||||
return 0
|
||||
|
||||
def to_dict(self):
|
||||
"""
|
||||
Convert the Loan object to a dictionary format for JSON serialization.
|
||||
|
||||
Reference in New Issue
Block a user