first cut at followers
This commit is contained in:
@@ -2917,6 +2917,16 @@ def update_duplicates_on_delete(sender, instance, **kwargs):
|
|||||||
# conn.close()
|
# conn.close()
|
||||||
# engine.dispose()
|
# engine.dispose()
|
||||||
|
|
||||||
|
class VirtualRaceFollower(models.Model):
|
||||||
|
user = models.ForeignKey(User,on_delete=models.CASCADE,null=True)
|
||||||
|
race = models.ForeignKey(VirtualRace,on_delete=models.CASCADE)
|
||||||
|
emailaddress = models.EmailField(max_length=254,blank=True,null=True)
|
||||||
|
|
||||||
|
class FollowerForm(ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = VirtualRaceFollower
|
||||||
|
fields = ['emailaddress']
|
||||||
|
|
||||||
# Virtual Race results (for keeping results when workouts are deleted)
|
# Virtual Race results (for keeping results when workouts are deleted)
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class VirtualRaceResult(models.Model):
|
class VirtualRaceResult(models.Model):
|
||||||
|
|||||||
47
rowers/templates/followerform.html
Normal file
47
rowers/templates/followerform.html
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
{% load tz %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}Comment Session {% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<h1>Comments {{ plannedession.name }}</h1>
|
||||||
|
|
||||||
|
<ul class="main-content">
|
||||||
|
<li class="grid_2">
|
||||||
|
{% for c in comments %}
|
||||||
|
<p>
|
||||||
|
{{ c.created }}
|
||||||
|
<b>{{ c.user.first_name }} {{ c.user.last_name }}</b>
|
||||||
|
<div class="talk-bubble tri-right left-top">
|
||||||
|
<div class="talktext">
|
||||||
|
{{ c.comment }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
{% endfor %}
|
||||||
|
<form enctype="multipart/form-data" method="post">
|
||||||
|
<table width=100%>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="submit" value="Save">
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% if 'racing' in active %}
|
||||||
|
{% include 'menu_racing.html' %}
|
||||||
|
{% else %}
|
||||||
|
{% include 'menu_plan.html' %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
@@ -160,12 +160,14 @@
|
|||||||
<div id="registerbuttons">
|
<div id="registerbuttons">
|
||||||
{% if request.user.is_anonymous %}
|
{% if request.user.is_anonymous %}
|
||||||
<p>
|
<p>
|
||||||
Registered users of rowsandall.com can participate in this challenge. Participation is free, unless specified differently in the race comment above.
|
Registered users of rowsandall.com can participate in this challenge.
|
||||||
|
Participation is free, unless specified differently in the race comment above.
|
||||||
{% if race.sessiontype == 'race' %}
|
{% if race.sessiontype == 'race' %}
|
||||||
<a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a>
|
<a href="/rowers/virtualevent/{{ race.id }}/register"><h3>Register</h3></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a>
|
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<a href="/rowers/virtualevent/{{ race.id }}/follow/"><h3>Follow this challenge</h3></a>
|
||||||
</p>
|
</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>
|
<p>
|
||||||
@@ -184,6 +186,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a>
|
<a href="/rowers/virtualevent/{{ race.id }}/registerindoor"><h3>Register</h3></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<a href="/rowers/virtualevent/{{ race.id }}/follow/"><h3>Follow this challenge</h3></a>
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if button == 'submitbutton' %}
|
{% if button == 'submitbutton' %}
|
||||||
|
|||||||
@@ -346,6 +346,8 @@ urlpatterns = [
|
|||||||
views.virtualevent_uploadimage_view,name='virtualevent_uploadimage_view'),
|
views.virtualevent_uploadimage_view,name='virtualevent_uploadimage_view'),
|
||||||
re_path(r'^virtualevent/(?P<id>\d+)/setimage/(?P<logoid>\d+)/$',
|
re_path(r'^virtualevent/(?P<id>\d+)/setimage/(?P<logoid>\d+)/$',
|
||||||
views.virtualevent_setlogo_view,name='virtualevent_setlog_view'),
|
views.virtualevent_setlogo_view,name='virtualevent_setlog_view'),
|
||||||
|
re_path(r'^virtualevent/(?P<id>\d+)/follow/$',
|
||||||
|
views.addfollower_view,name='addfollower_view'),
|
||||||
re_path(r'^logo/(?P<id>\d+)/delete/$',
|
re_path(r'^logo/(?P<id>\d+)/delete/$',
|
||||||
views.logo_delete_view,name='logo_delete_view'),
|
views.logo_delete_view,name='logo_delete_view'),
|
||||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/darkskywind/$',views.workout_downloadwind_view,name='workout_downloadwind_view'),
|
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/darkskywind/$',views.workout_downloadwind_view,name='workout_downloadwind_view'),
|
||||||
|
|||||||
@@ -2820,3 +2820,71 @@ def virtualevent_submit_result_view(request,id=0,workoutid=0):
|
|||||||
'rower':r,
|
'rower':r,
|
||||||
'w_form':w_form,
|
'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,
|
PlannedSessionComment,CoachRequest,CoachOffer,
|
||||||
VideoAnalysis,ShareKey,
|
VideoAnalysis,ShareKey,
|
||||||
StandardCollection,CourseStandard,
|
StandardCollection,CourseStandard,
|
||||||
|
VirtualRaceFollower,
|
||||||
)
|
)
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
|
||||||
@@ -129,7 +130,8 @@ from rowers.models import (
|
|||||||
VirtualRaceForm,VirtualRaceResultForm,RowerImportExportForm,
|
VirtualRaceForm,VirtualRaceResultForm,RowerImportExportForm,
|
||||||
IndoorVirtualRaceResultForm,IndoorVirtualRaceResult,
|
IndoorVirtualRaceResultForm,IndoorVirtualRaceResult,
|
||||||
IndoorVirtualRaceForm,PlannedSessionCommentForm,
|
IndoorVirtualRaceForm,PlannedSessionCommentForm,
|
||||||
Alert, Condition, StaticChartRowerForm
|
Alert, Condition, StaticChartRowerForm,
|
||||||
|
FollowerForm,
|
||||||
)
|
)
|
||||||
from rowers.models import (
|
from rowers.models import (
|
||||||
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement,BasePlannedSessionFormSet,
|
||||||
|
|||||||
Reference in New Issue
Block a user