diff --git a/rowers/models.py b/rowers/models.py
index c7cbf391..430ffffc 100644
--- a/rowers/models.py
+++ b/rowers/models.py
@@ -2973,6 +2973,9 @@ class VirtualRaceResult(models.Model):
entrycategory = models.ForeignKey(CourseStandard,null=True,on_delete=models.SET_NULL,
verbose_name='Group')
+ acceptsocialmedia = models.BooleanField(default=True,
+ verbose_name = 'I agree with sharing my name in challenge related social media posts (unchecking this does not prevent you from participation)')
+
def __str__(self):
rr = Rower.objects.get(id=self.userid)
name = '{u1} {u2}'.format(
@@ -3048,6 +3051,8 @@ class IndoorVirtualRaceResult(models.Model):
verbose_name = 'Receive challenge notifications by email')
entrycategory = models.ForeignKey(CourseStandard,null=True,on_delete=models.SET_NULL,
verbose_name='Group')
+ acceptsocialmedia = models.BooleanField(default=True,
+ verbose_name = 'I agree with sharing my name in challenge related social media posts (unchecking this does not prevent you from participation)')
def __str__(self):
rr = Rower.objects.get(id=self.userid)
@@ -3097,7 +3102,7 @@ class IndoorVirtualRaceResultForm(ModelForm):
class Meta:
model = IndoorVirtualRaceResult
fields = ['teamname','weightcategory','boatclass','age','adaptiveclass',
- 'entrycategory'
+ 'entrycategory','acceptsocialmedia'
]
@@ -3115,7 +3120,7 @@ class VirtualRaceResultForm(ModelForm):
model = VirtualRaceResult
fields = ['teamname','weightcategory','boatclass','boattype',
'age','adaptiveclass',
- 'entrycategory'
+ 'entrycategory','acceptsocialmedia'
]
diff --git a/rowers/tasks.py b/rowers/tasks.py
index f2408632..b91faff1 100644
--- a/rowers/tasks.py
+++ b/rowers/tasks.py
@@ -1116,6 +1116,38 @@ def handle_sendemail_raceregistration(
return 1
+@app.task
+def handle_sendemail_optout(
+ useremail, username, registeredname, racename, raceid, **kwargs):
+
+ if 'debug' in kwargs:
+ debug = kwargs['debug']
+ else:
+ debug = True
+
+ subject = "{name} has opted out from social media posts around challenge {n}".format(
+ n = racename,
+ name = registeredname
+ )
+
+ from_email = 'Rowsandall Dear {{ username }},
+ {{ registeredname }} has opted out from Social Media posts regarding the
+ virtual challenge {{ racename }}
+
+ If you are making any posts to Social Media about the event, you have to
+ do this without mentioning their name.
+
+ As the organizer of the virtual challenge it is your responsibility to
+ respect this. Rowsandall.com is not responsible for any damage caused.
+
+ Best Regards, the Rowsandall Team
+
+ The challenge organizer may want to publish about the challenge on social media and + use your name in the results. If you do not want your name to appear on social media, + you can let this know by unchecking the check box in the form. +
{% if race.coursestandards %}This race uses standard times and limits the race groups to those where standard times exist. The "Group" form choice will overrule other selections you @@ -52,7 +57,7 @@ {% csrf_token %} - + diff --git a/rowers/views/racesviews.py b/rowers/views/racesviews.py index e2b06a4d..09a3cb0e 100644 --- a/rowers/views/racesviews.py +++ b/rowers/views/racesviews.py @@ -1518,6 +1518,7 @@ def virtualevent_addboat_view(request,id=0): adaptiveclass = cd['adaptiveclass'] age = cd['age'] mix = cd['mix'] + acceptsocialmedia = cd['acceptsocialmedia'] sex = r.sex if mix: @@ -1612,12 +1613,22 @@ def virtualevent_addboat_view(request,id=0): entrycategory=coursestandard, sex=sex, age=age, + acceptsocialmedia=acceptsocialmedia, ) record.save() add_rower_race(r,race) + # send email about opt out + if not acceptsocialmedia: + job = myqueue( + queue, + handle_sendemail_optout, + race.manager.email,race.manager.first_name, + r.user.first_name+' '+r.user.last_name, + race.name,race.id, + ) messages.info( @@ -1767,6 +1778,7 @@ def virtualevent_register_view(request,id=0): adaptiveclass = cd['adaptiveclass'] age = cd['age'] mix = cd['mix'] + acceptsocialmedia = cd['acceptsocialmedia'] sex = r.sex if mix: @@ -1829,13 +1841,23 @@ def virtualevent_register_view(request,id=0): coursecompleted=False, sex=sex, age=age, - entrycategory=coursestandard, - referencespeed=referencespeed, + entrycategory=coursestandard, + referencespeed=referencespeed, + acceptsocialmedia = acceptsocialmedia, ) record.save() add_rower_race(r,race) + # send email about opt out + if not acceptsocialmedia: + job = myqueue( + queue, + handle_sendemail_optout, + race.manager.email,race.manager.first_name, + r.user.first_name+' '+r.user.last_name, + race.name,race.id, + ) # remove followers myfollows = VirtualRaceFollower.objects.filter(user=r.user,race=race) @@ -2028,6 +2050,7 @@ def indoorvirtualevent_register_view(request,id=0): adaptiveclass = cd['adaptiveclass'] age = cd['age'] boatclass = cd['boatclass'] + acceptsocialmedia = cd['acceptsocialmedia'] sex = r.sex @@ -2086,13 +2109,24 @@ def indoorvirtualevent_register_view(request,id=0): sex=sex, age=age, entrycategory=coursestandard, - referencespeed=referencespeed + referencespeed=referencespeed, + acceptsocialmedia=acceptsocialmedia, ) record.save() add_rower_race(r,race) + # send email about opt out + if not acceptsocialmedia: + job = myqueue( + queue, + handle_sendemail_optout, + race.manager.email,race.manager.first_name, + r.user.first_name+' '+r.user.last_name, + race.name,race.id, + ) + # remove followers myfollows = VirtualRaceFollower.objects.filter(user=r.user,race=race) for f in myfollows: diff --git a/rowers/views/statements.py b/rowers/views/statements.py index 2bd13221..24c3290d 100644 --- a/rowers/views/statements.py +++ b/rowers/views/statements.py @@ -211,6 +211,7 @@ from rowers.tasks import ( handle_sendemail_userdeleted, handle_sendemail_raceregistration, handle_sendemail_racesubmission, + handle_sendemail_optout, handle_sendemail_ical, )