Merge branch 'feature/useradmin' into develop
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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,22 @@ 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))
|
||||
|
||||
|
||||
@@ -702,6 +702,13 @@ class Rower(models.Model):
|
||||
|
||||
rowerplan = models.CharField(default='basic',max_length=30,
|
||||
choices=plans)
|
||||
paymenttype = models.CharField(
|
||||
default='single',max_length=30,
|
||||
choices=(
|
||||
('single','single'),
|
||||
('recurring','recurring')
|
||||
)
|
||||
)
|
||||
|
||||
planexpires = models.DateField(default=timezone.now)
|
||||
teamplanexpires = models.DateField(default=timezone.now)
|
||||
|
||||
@@ -721,6 +721,28 @@ def handle_updatedps(useremail, workoutids, debug=False,**kwargs):
|
||||
|
||||
# send email when a breakthrough workout is uploaded
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_expired(useremail,userfirstname,userlastname,expireddate,
|
||||
**kwargs):
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
else:
|
||||
debug = False
|
||||
|
||||
subject = "Your rowsandall.com paid account has expired"
|
||||
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||
|
||||
d = {
|
||||
'first_name':userfirstname,
|
||||
'last_name':userlastname,
|
||||
'siteurl':siteurl,
|
||||
'expireddate':expireddate,
|
||||
}
|
||||
|
||||
res = send_template_email(from_email,[useremail],
|
||||
subject,'accountexpiredemail.html',
|
||||
d,cc=['support@rowsandall.com'],**kwargs)
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_breakthrough(workoutid, useremail,
|
||||
|
||||
23
rowers/templates/accountexpiredemail.html
Normal file
23
rowers/templates/accountexpiredemail.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{% extends "emailbase.html" %}
|
||||
|
||||
{% block body %}
|
||||
<p>Dear <strong>{{ first_name }}</strong>,</p>
|
||||
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
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!
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Best Regards, the Rowsandall Team
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
@@ -96,6 +96,7 @@ MIDDLEWARE_CLASSES = [
|
||||
'tz_detect.middleware.TimezoneMiddleware',
|
||||
'rowers.middleware.GDPRMiddleWare',
|
||||
'rowers.middleware.PowerTimeFitnessMetricMiddleWare',
|
||||
'rowers.middleware.RowerPlanMiddleWare',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'rowsandall_app.urls'
|
||||
|
||||
@@ -225,6 +225,16 @@
|
||||
</p>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if user.rower.planexpires and user.rower.rowerplan != 'basic' and user.rower.paymenttype == 'single'%}
|
||||
{% if user.rower.planexpires|is_future_date %}
|
||||
{% if user.rower.planexpires|date_dif|ddays < 4 %}
|
||||
<li class="grid_4">
|
||||
<p class="successmessage">
|
||||
You have {{ user.rower.planexpires|date_dif|ddays }} days left of your one year subscription. Please renew on or before {{ user.rower.planexpires }} or your plan will be reset to Basic. Click <a href="/rowers/promembership">here</a> to renew your membership.</p>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if user.rower.protrialexpires and user.rower.protrialexpires|is_future_date %}
|
||||
{% if user.rower.plantrialexpires and user.rower.rowerplan != 'plan' %}
|
||||
<li class="grid_4">
|
||||
|
||||
Reference in New Issue
Block a user