Private
Public Access
1
0

initial implementation.

To Do: Add unsubscribe/subscribe functionality for participants
This commit is contained in:
Sander Roosendaal
2018-11-30 17:15:50 +01:00
parent 3fa95b8088
commit 73b8941825
7 changed files with 162 additions and 3 deletions

View File

@@ -2422,6 +2422,8 @@ class VirtualRaceResult(models.Model):
verbose_name='Gender')
age = models.IntegerField(null=True)
emailnotifications = models.BooleanField(default=True,
verbose_name = 'Receive race notifications by email')
def __unicode__(self):
rr = Rower.objects.get(id=self.userid)
@@ -2472,6 +2474,8 @@ class IndoorVirtualRaceResult(models.Model):
verbose_name='Gender')
age = models.IntegerField(null=True)
emailnotifications = models.BooleanField(default=True,
verbose_name = 'Receive race notifications by email')
def __unicode__(self):
rr = Rower.objects.get(id=self.userid)

View File

@@ -729,10 +729,11 @@ def race_can_submit(r,race):
if is_complete == False:
return True
else:
return False
return True
else:
return False
print 'pop'
return False
def race_can_resubmit(r,race):

View File

@@ -740,6 +740,64 @@ def handle_updatedps(useremail, workoutids, debug=False,**kwargs):
# send email when a breakthrough workout is uploaded
@app.task
def handle_sendemail_raceregistration(
useremail, username, registeredname, racename, raceid, **kwargs):
if 'debug' in kwargs:
debug = kwargs['debug']
else:
debug = True
subject = "A new competitor has registered for virtual race {n}".format(
n = racename
)
from_email = 'Rowsandall <info@rowsandall.com>'
d = {
'username':username,
'registeredname':registeredname,
'racename':racename,
'raceid':raceid,
}
res = send_template_email(from_email,[useremail],
subject,
'raceregisteredemail.html',
d,**kwargs)
return 1
@app.task
def handle_sendemail_racesubmission(
useremail, username, registeredname, racename, raceid, **kwargs):
if 'debug' in kwargs:
debug = kwargs['debug']
else:
debug = True
subject = "A new result has been submitted for virtual race {n}".format(
n = racename
)
from_email = 'Rowsandall <info@rowsandall.com>'
d = {
'username':username,
'registeredname':registeredname,
'racename':racename,
'raceid':raceid,
}
res = send_template_email(from_email,[useremail],
subject,
'racesubmissionemail.html',
d,**kwargs)
return 1
@app.task
def handle_send_disqualification_email(
useremail,username,reason,message, racename, **kwargs):

View File

@@ -0,0 +1,19 @@
{% extends "emailbase.html" %}
{% block body %}
<p>Dear <strong>{{ username }}</strong>,</p>
<p>
A new competitor has registered for the race {{ racename }}: {{ registeredname }}
</p>
<p>
You can check race participants and results on the race page on Rowsandall:
<a href="https://rowsandall.com/rowers/virtualevent/{{ raceid }}">{{ racename }}</a>
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}

View File

@@ -0,0 +1,19 @@
{% extends "emailbase.html" %}
{% block body %}
<p>Dear <strong>{{ username }}</strong>,</p>
<p>
One of your competitors, {{ registeredname }}, has submitted a result for {{ racename }}
</p>
<p>
Check out the results on the race page!
<a href="https://rowsandall.com/rowers/virtualevent/{{ raceid }}">{{ racename }}</a>
</p>
<p>
Best Regards, the Rowsandall Team
</p>
{% endblock %}

View File

@@ -39,8 +39,12 @@
<p>
<a class="twitter-share-button"
href="https://twitter.com/intent/tweet"
data-url="{{ request.build_absolute_uri }}"
data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{ race.name }}'">Tweet</a>
data-url="{{ request.build_absolute_uri }}"
{% if race.sessiontype == 'race' %}
data-text="@rowsandall #rowingdata Participate in virtual race '{{ race.name }}'">Tweet</a>
{% else %}
data-text="@rowsandall #rowingdata Participate in Indoor Rowing virtual race '{{ race.name }}'">Tweet</a>
{% endif %}
</p>

View File

@@ -168,6 +168,8 @@ from rowers.tasks import (
handle_update_empower,
handle_sendemailics,
handle_sendemail_userdeleted,
handle_sendemail_raceregistration,
handle_sendemail_racesubmission,
)
from scipy.signal import savgol_filter
@@ -16526,6 +16528,22 @@ def virtualevent_register_view(request,id=0):
add_rower_race(r,race)
otherrecords = IndoorVirtualRaceResult.objects.filter(
race = race).exclude(userid = r.id)
for otherrecord in otherrecords:
otheruser = Rower.objects.get(id=otherrecord.userid)
othername = otheruser.user.first_name+' '+otheruser.user.last_name
registeredname = r.user.first_name+' '+r.user.last_name
if otherrecord.emailnotifications:
job = myqueue(
queue,
handle_sendemail_raceregistration,
otheruser.user.email, othername,
registeredname,
race.name,
race.id
)
messages.info(
@@ -16633,6 +16651,22 @@ def indoorvirtualevent_register_view(request,id=0):
add_rower_race(r,race)
otherrecords = IndoorVirtualRaceResult.objects.filter(
race = race).exclude(userid = r.id)
for otherrecord in otherrecords:
otheruser = Rower.objects.get(id=otherrecord.userid)
othername = otheruser.user.first_name+' '+otheruser.user.last_name
registeredname = r.user.first_name+' '+r.user.last_name
if otherrecord.emailnotifications:
job = myqueue(
queue,
handle_sendemail_raceregistration,
otheruser.user.email, othername,
registeredname,
race.name,
race.id
)
messages.info(
@@ -17142,6 +17176,7 @@ def virtualevent_submit_result_view(request,id=0):
race=race
)
entrychoices = []
for record in records:
@@ -17235,6 +17270,25 @@ def virtualevent_submit_result_view(request,id=0):
messages.info(request,"We are evaluating your result. The page will reload when we're done. Your result will show up if you adhered to the course")
if result:
otherrecords = resultobj.objects.filter(
race = race).exclude(userid = r.id)
for otherrecord in otherrecords:
otheruser = Rower.objects.get(id=otherrecord.userid)
othername = otheruser.user.first_name+' '+otheruser.user.last_name
registeredname = r.user.first_name+' '+r.user.last_name
if otherrecord.emailnotifications:
job = myqueue(
queue,
handle_sendemail_racesubmission,
otheruser.user.email, othername,
registeredname,
race.name,
race.id
)
# redirect to race page
url = reverse(virtualevent_view,
kwargs = {