Private
Public Access
1
0

Merge branch 'feature/emails' into develop

This commit is contained in:
Sander Roosendaal
2018-12-12 10:35:22 +01:00
7 changed files with 22 additions and 5 deletions
+9 -1
View File
@@ -53,6 +53,14 @@ def textify(html):
# Strip single spaces in the beginning of each line
return text_only.replace('\n ', '\n').strip()
def htmlstripnobr(html):
safe_html = re.sub('[ \t]+', ' ', strip_tags(html))
return safe_html
def htmlstrip(html):
safe_html = re.sub('[ \t]+', ' ', strip_tags(html))
return newlinetobr(safe_html)
def newlinetobr(html):
html = html.replace('\n\n','<br>')
return html.replace('\n','<br>')
@@ -65,7 +73,7 @@ def send_template_email(from_email,to_email,subject,
html_content = htmly.render(context)
text_content = textify(html_content)
html_content = newlinetobr(html_content)
# html_content = newlinetobr(html_content)
if 'cc' in kwargs:
msg = EmailMultiAlternatives(subject, text_content, from_email, to_email,cc=kwargs['cc'])
+4 -1
View File
@@ -692,7 +692,10 @@ def fitnessmetric_chart(fitnessmetrics,user,workoutmode='rower'):
df = df[df['power2k']>0]
df = df[df['mode']==workoutmode]
try:
df = df[df['mode']==workoutmode]
except TypeError:
df = pd.DataFrame()
groups = df.groupby(by='date').max()
+4
View File
@@ -25,6 +25,8 @@ from rowers.models import (
from rowers.courses import get_time_course
from rowers.emails import htmlstrip,htmlstripnobr
import rowers.mytypes as mytypes
import metrics
@@ -616,6 +618,7 @@ def update_plannedsession(ps,cd):
def update_indoorvirtualrace(ps,cd):
for attr, value in cd.items():
if attr == 'comment':
value = htmlstripnobr(value)
value.replace("\r\n", "&#10");
value.replace("\n", "&#10");
setattr(ps, attr, value)
@@ -666,6 +669,7 @@ def update_indoorvirtualrace(ps,cd):
def update_virtualrace(ps,cd):
for attr, value in cd.items():
if attr == 'comment':
value = htmlstripnobr(value)
value.replace("\r\n", "&#10");
value.replace("\n", "&#10");
setattr(ps, attr, value)
+2 -1
View File
@@ -40,6 +40,7 @@ from django.utils import timezone
from django.utils.html import strip_tags
from utils import deserialize_list,ewmovingaverage,wavg
from emails import htmlstrip
from HTMLParser import HTMLParser
class MLStripper(HTMLParser):
@@ -819,7 +820,7 @@ def handle_send_disqualification_email(
'username':username,
'reason':reason,
'siteurl':siteurl,
'message': strip_tags(message),
'message': htmlstrip(message),
'racename':racename,
}
+1 -1
View File
@@ -39,7 +39,7 @@
</table>
<p>
{% csrf_token %}
<input class="button green" type="submit" value="Submit">
<input type="submit" value="Submit">
</p>
</li>
</ul>
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -186,7 +186,7 @@ import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from rowers.emails import send_template_email
from rowers.emails import send_template_email,htmlstrip
from pytz import timezone as tz,utc
from timezonefinder import TimezoneFinder