diff --git a/rowers/emails.py b/rowers/emails.py
index dff06210..7dfa16d1 100644
--- a/rowers/emails.py
+++ b/rowers/emails.py
@@ -59,8 +59,12 @@ def send_template_email(from_email,to_email,subject,
html_content = htmly.render(context)
text_content = textify(html_content)
+
+ if 'cc' in kwargs:
+ msg = EmailMultiAlternatives(subject, text_content, from_email, to_email,cc=kwargs['cc'])
+ else:
+ msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
- msg = EmailMultiAlternatives(subject, text_content, from_email, to_email)
msg.attach_alternative(html_content, "text/html")
if 'attach_file' in kwargs:
@@ -82,6 +86,8 @@ def send_template_email(from_email,to_email,subject,
else:
emailbounced = False
+
+
if not emailbounced:
res = msg.send()
else:
diff --git a/rowers/middleware.py b/rowers/middleware.py
index 736af9c0..72c1ed7e 100644
--- a/rowers/middleware.py
+++ b/rowers/middleware.py
@@ -5,8 +5,9 @@ import datetime
from utils import myqueue
import django_rq
queue = django_rq.get_queue('default')
-from rowers.tasks import handle_updatefitnessmetric
+from rowers.tasks import handle_updatefitnessmetric,handle_sendemail_expired
from rowers.mytypes import otwtypes
+from django.contrib import messages
def getrower(user):
try:
@@ -101,3 +102,24 @@ class GDPRMiddleWare(object):
return redirect(
'/rowers/me/gdpr-optin/?next=%s' % nexturl
)
+
+class RowerPlanMiddleWare(object):
+ def process_request(self, request):
+ if request.user.is_authenticated() and request.user.rower.rowerplan != 'basic':
+ if request.user.rower.paymenttype == 'single':
+ if request.user.rower.planexpires < timezone.now().date():
+ messg = 'Your paid plan has expired. We have reset you to a free basic plan.'
+ messages.error(request,messg)
+ r = getrower(request.user)
+ r.rowerplan = 'basic'
+ r.save()
+ # send email
+ job = myqueue(queue,
+ handle_sendemail_expired,
+ r.user.email,
+ r.user.first_name,
+ r.user.last_name,
+ str(r.planexpires))
+ elif request.user.rower.planexpires-datetime.timedelta(days=5)
+ Your Pro account on rowsandall.com expired on {{ expireddate }}. It + has now been automatically reset to Basic. + Let me know if you have any questions. If you want to continue using Pro membership, + just sign up again through the site and I will change your membership back to Pro. +
+ ++ If you do not want to continue the Pro membership, I'd be interested to know why you + decided to not continue your Pro account. Did it not fulfill your expectations? + This information is valuable to improve the site for all users. Thank you! +
+ ++ Best Regards, the Rowsandall Team +
+{% endblock %} + diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py index 5de3f066..ab69eeca 100644 --- a/rowsandall_app/settings.py +++ b/rowsandall_app/settings.py @@ -96,6 +96,7 @@ MIDDLEWARE_CLASSES = [ 'tz_detect.middleware.TimezoneMiddleware', 'rowers.middleware.GDPRMiddleWare', 'rowers.middleware.PowerTimeFitnessMetricMiddleWare', + 'rowers.middleware.RowerPlanMiddleWare', ] ROOT_URLCONF = 'rowsandall_app.urls'