first cut at followers
This commit is contained in:
@@ -2820,3 +2820,71 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
|
||||
'rower':r,
|
||||
'w_form':w_form,
|
||||
})
|
||||
|
||||
def addfollower_view(request,id=0):
|
||||
try:
|
||||
race = VirtualRace.objects.get(id=id)
|
||||
except VirtualRace.DoesNotExist:
|
||||
raise Http404("Virtual Challenge does not exist")
|
||||
|
||||
if not request.user.is_anonymous:
|
||||
follower = VirtualRaceFollower(
|
||||
user=request.user,
|
||||
race=race,
|
||||
emailaddress = request.user.email
|
||||
)
|
||||
follower.save()
|
||||
messages.info(request,"You will receive challenge notifications per email")
|
||||
url = reverse(virtualevent_view,
|
||||
kwargs={'id':id})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# Anonymous
|
||||
if request.method == 'POST':
|
||||
form = FollowerForm(request.POST)
|
||||
if form.is_valid():
|
||||
email = form.cleaned_data['emailaddress']
|
||||
|
||||
follower = VirtualRaceFollower(
|
||||
race=race,
|
||||
emailaddress = email
|
||||
)
|
||||
follower.save()
|
||||
|
||||
messages.info(request,"You will receive challenge notifications per email")
|
||||
|
||||
url = reverse(virtualevent_view,
|
||||
kwargs={'id':id})
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
else:
|
||||
form = FollowerForm()
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url':reverse('virtualevents_view'),
|
||||
'name': 'Challenges'
|
||||
},
|
||||
{
|
||||
'url':reverse('virtualevent_view',
|
||||
kwargs={'id':race.id}
|
||||
),
|
||||
'name': race.name
|
||||
},
|
||||
{
|
||||
'url': reverse(addfollower_view,
|
||||
kwargs = {'id':race.id}
|
||||
),
|
||||
'name': 'Follow'
|
||||
}
|
||||
]
|
||||
|
||||
return render(request,'followerform.html',
|
||||
{
|
||||
'form':form,
|
||||
'active':'nav-racing',
|
||||
'breadcrumbs':breadcrumbs,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -116,6 +116,7 @@ from rowers.models import (
|
||||
PlannedSessionComment,CoachRequest,CoachOffer,
|
||||
VideoAnalysis,ShareKey,
|
||||
StandardCollection,CourseStandard,
|
||||
VirtualRaceFollower,
|
||||
)
|
||||
from rowers.models import (
|
||||
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
||||
@@ -129,7 +130,8 @@ from rowers.models import (
|
||||
VirtualRaceForm,VirtualRaceResultForm,RowerImportExportForm,
|
||||
IndoorVirtualRaceResultForm,IndoorVirtualRaceResult,
|
||||
IndoorVirtualRaceForm,PlannedSessionCommentForm,
|
||||
Alert, Condition, StaticChartRowerForm
|
||||
Alert, Condition, StaticChartRowerForm,
|
||||
FollowerForm,
|
||||
)
|
||||
from rowers.models import (
|
||||
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
||||
|
||||
Reference in New Issue
Block a user