Added AWS SES email

This commit is contained in:
2026-04-26 20:45:48 -04:00
parent fe19511d11
commit 88f6e8259d
4 changed files with 112 additions and 5 deletions
+2
View File
@@ -859,7 +859,9 @@ ALTER TABLE office_users ALTER COLUMN password TYPE VARCHAR(250);
ALTER TABLE office_users OWNER TO merms_panel;
INSERT INTO office_users (username, password, firstname, lastname, acc_level) VALUES ('mermsadmin','password','Merms','Admin',1000);
INSERT INTO office_users (username, password, firstname, lastname, acc_level) VALUES ('adminsanya','password','Sanya','Ameye',1000);
-- Dr.Sanya.Alan1!
CREATE TABLE products_contacts(
+8 -1
View File
@@ -741,7 +741,7 @@ def get_subscription_transaction_office():
def get_recent_signup_office():
# Call the dashboard service
filters = {}
result = OfficeDashboardService.get_payments_data(filters)
result = OfficeDashboardService.get_recent_signup_data(filters)
return jsonify(result)
@@ -930,3 +930,10 @@ def refresh():
# logger.info(f"Authorize refresh request received: {data}")
response = AuthorizationService.process_refresh_request()
return response
@api.route("/cron/report-subscription", methods=["GET"])
def report_subs():
data = {}
AccountService.process_test_email(data)
return {"status": "ok"}, 200
+54 -4
View File
@@ -6,8 +6,6 @@ from app.config import settings
from app.utils.logger import logger
from app.api.services.base_service import BaseService
from sqlalchemy import func, desc
from datetime import datetime, timedelta, timezone
from app.extensions import db
from app.models import MembersProducts, Products, Payments, Members, CustomTemplates, ProductsTemplates, MembersProfile, \
ProductsDetails, MembersWebfiles
@@ -226,7 +224,6 @@ class OfficeDashboardService(BaseService):
return products_result
@staticmethod
def get_office_product_templates(filters):
@@ -594,4 +591,57 @@ class OfficeDashboardService(BaseService):
except Exception as e:
logger.error(f"An error occurred while getting dashboard data: {str(e)}", exc_info=True)
return jsonify({"message": "Internal Server Error"}), 500
return jsonify({"message": "Internal Server Error"}), 500
@staticmethod
def get_recent_signup_data(filters):
try:
if filters is None:
filters = {}
# Extract pagination parameters
page = int(filters.get('page', 1))
limit = int(filters.get('limit', 20))
# Ensure page and limit are valid
if page < 1:
page = 1
if limit < 1 or limit > 100:
limit = 20
membersList, total_count = Members.get_all_member(None,None,1,30)
# Convert loans to dictionary format
member_data = []
for member in membersList:
member_data.append({
'id': member.id,
'username': member.username,
'email': member.email,
'firstname': member.firstname,
'lastname': member.lastname,
'country': member.country,
'member_uid': member.uid,
'profile_completed': member.profile_completed,
"added": member.added,
})
response_data = {
'members': member_data,
'count': 30,
'pagination': {
'total_count': total_count,
'total_pages': 1,
'current_page': page,
'limit': limit,
'has_next': page < 1,
'has_prev': page > 1
}
}
return response_data
except Exception as e:
logger.error(f"An error occurred while getting dashboard data: {str(e)}", exc_info=True)
return jsonify({"message": "Internal Server Error"}), 500
+48
View File
@@ -15,6 +15,19 @@ def send_email_factory(to_email, subject, html_content, text_content=None):
raise
def alert_email_factory(to_email, subject, html_content, text_content=None):
try:
send_email_ses(
to_email=to_email,
subject=subject,
html_content=alert_template(html_content)
)
except Exception as e:
logger.error(f"Alert_Email_Factory failed: {e}")
raise
def body_template(html_content):
html_body = f"""\
<html>
@@ -45,3 +58,38 @@ def body_template(html_content):
</html>
"""
return html_body
def alert_template(html_content):
html_body = f"""\
<html>
<head></head>
<body style="font-size:14px;line-height:1.5;">
<table width="550px" border="0" cellpadding="3" cellspacing="3" background-color="#F0F8FF" style="font-size:16px">
<tr>
<td style="text-align:center">
<img style="width:150px; height:auto;" src="https://www.mermsemr.com/images/logo-pink.png" />
</td>
</tr>
<tr>
<td>
{html_content}
</td>
</tr>
<tr>
<td>
<br />
LINKS --- ---- ---- -----
<br />
For any support<br>
Reach Out<br>
support@mermsemr.com<br>
https://www.mermsemr.com/
</td>
</tr>
</table>
</body>
</html>
"""
return html_body