Merge branch 'release/v6.86'
This commit is contained in:
@@ -1495,7 +1495,8 @@ class Workout(models.Model):
|
||||
plannedsession = models.ForeignKey(PlannedSession, blank=True,null=True)
|
||||
name = models.CharField(max_length=150)
|
||||
date = models.DateField()
|
||||
workouttype = models.CharField(choices=workouttypes,max_length=50)
|
||||
workouttype = models.CharField(choices=workouttypes,max_length=50,
|
||||
verbose_name='Exercise/Boat Class')
|
||||
workoutsource = models.CharField(max_length=100,
|
||||
default='unknown')
|
||||
boattype = models.CharField(choices=boattypes,max_length=50,
|
||||
@@ -1508,7 +1509,11 @@ class Workout(models.Model):
|
||||
max_length=100)
|
||||
distance = models.IntegerField(default=0,blank=True)
|
||||
duration = models.TimeField(default=1,blank=True)
|
||||
weightcategory = models.CharField(default="hwt",max_length=10,choices=weightcategories)
|
||||
weightcategory = models.CharField(
|
||||
default="hwt",
|
||||
max_length=10,
|
||||
choices=weightcategories,
|
||||
verbose_name='Weight Category')
|
||||
weightvalue = models.FloatField(default=80.0,blank=True,verbose_name = 'Average Crew Weight (kg)')
|
||||
csvfilename = models.CharField(blank=True,max_length=150)
|
||||
uploadedtoc2 = models.IntegerField(default=0)
|
||||
@@ -1794,7 +1799,7 @@ class WorkoutForm(ModelForm):
|
||||
# duration = forms.TimeInput(format='%H:%M:%S.%f')
|
||||
class Meta:
|
||||
model = Workout
|
||||
fields = ['name','date','starttime','timezone','duration','distance','workouttype','weightcategory','notes','privacy','rankingpiece','boattype']
|
||||
fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','privacy','rankingpiece']
|
||||
widgets = {
|
||||
'date': AdminDateWidget(),
|
||||
'notes': forms.Textarea,
|
||||
@@ -1806,7 +1811,7 @@ class WorkoutForm(ModelForm):
|
||||
# this line to be removed
|
||||
del self.fields['privacy']
|
||||
|
||||
if self.instance.workouttype != 'water':
|
||||
if self.instance.workouttype not in types.otwtypes:
|
||||
del self.fields['boattype']
|
||||
|
||||
fieldorder = (
|
||||
|
||||
@@ -145,6 +145,8 @@ def get_polar_notifications():
|
||||
|
||||
return available_data
|
||||
|
||||
from rowers.utils import isprorower
|
||||
|
||||
def get_all_new_workouts(available_data,testing=False):
|
||||
for record in available_data:
|
||||
if testing:
|
||||
@@ -153,7 +155,7 @@ def get_all_new_workouts(available_data,testing=False):
|
||||
try:
|
||||
r = Rower.objects.get(polaruserid=record['user-id'])
|
||||
u = r.user
|
||||
if r.polar_auto_import:
|
||||
if r.polar_auto_import and isprorower(r):
|
||||
exercise_list = get_polar_workouts(u)
|
||||
if testing:
|
||||
print exercise_list
|
||||
|
||||
@@ -78,6 +78,28 @@
|
||||
{% block scripts %}
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
$('#id_workouttype').on('change', function(){
|
||||
if (
|
||||
$(this).val() == 'rower'
|
||||
|| $(this).val() == 'skierg'
|
||||
|| $(this).val() == 'dynamic'
|
||||
|| $(this).val() == 'sliders'
|
||||
|| $(this).val() == 'paddle'
|
||||
|| $(this).val() == 'snow'
|
||||
) {
|
||||
$('#id_boattype').toggle(false);
|
||||
$('#id_boattype').val('1x');
|
||||
} else {
|
||||
$('#id_boattype').toggle(true);
|
||||
}
|
||||
});
|
||||
$('#id_workouttype').change();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var td = new FormData();
|
||||
var formdatasetok = false;
|
||||
@@ -97,7 +119,7 @@
|
||||
|
||||
if (formdatasetok) {
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
|
||||
console.log("CSRF token",csrftoken);
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@
|
||||
|
||||
<h2>Auto Import/Export Settings</h2>
|
||||
|
||||
|
||||
<p>Use the form below to set your auto import/export settings.
|
||||
As we implement auto import/export for various partner sites, this form will be expanded.</p>
|
||||
|
||||
@@ -112,6 +113,9 @@
|
||||
|
||||
<p>Auto Export = New workouts uploaded to rowsandall.com will be automatically synchronized
|
||||
to the partner site</p>
|
||||
|
||||
<p>These settings only have effect if you are a user on one
|
||||
of the <a href="/rowers/promembership">paid plans</a></p>
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<form id="importexportform" method="post">
|
||||
@@ -124,6 +128,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -39,12 +39,19 @@
|
||||
<td>✔</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Import, Export, Synchronization and download of all your data</td>
|
||||
<td>Manual Import, Export, Synchronization and download of all your data</td>
|
||||
<td>✔</td>
|
||||
<td>✔</td>
|
||||
<td>✔</td>
|
||||
<td>✔</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Automatic Synchronization with other fitness sites</td>
|
||||
<td> </td>
|
||||
<td>✔</td>
|
||||
<td>✔</td>
|
||||
<td>✔</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Heart rate and power zones</td>
|
||||
<td>✔</td>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
workouttypes = (
|
||||
('water','On-water - Olympic'),
|
||||
('water','Standard Racing Shell'),
|
||||
('rower','Indoor Rower'),
|
||||
('skierg','Ski Erg'),
|
||||
('dynamic','Dynamic Indoor Rower'),
|
||||
|
||||
@@ -373,15 +373,17 @@ def make_private(w,options):
|
||||
|
||||
return 1
|
||||
|
||||
from rowers.utils import isprorower
|
||||
|
||||
def do_sync(w,options):
|
||||
if ('upload_to_C2' in options and options['upload_to_C2']) or w.user.c2_auto_export:
|
||||
if ('upload_to_C2' in options and options['upload_to_C2']) or (w.user.c2_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = c2stuff.workout_c2_upload(w.user.user,w)
|
||||
except c2stuff.C2NoTokenError:
|
||||
id = 0
|
||||
message = "Something went wrong with the Concept2 sync"
|
||||
|
||||
if ('upload_to_Strava' in options and options['upload_to_Strava']) or w.user.strava_auto_export:
|
||||
if ('upload_to_Strava' in options and options['upload_to_Strava']) or (w.user.strava_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = stravastuff.workout_strava_upload(
|
||||
w.user.user,w
|
||||
@@ -391,7 +393,7 @@ def do_sync(w,options):
|
||||
message = "Please connect to Strava first"
|
||||
|
||||
|
||||
if ('upload_to_SportTracks' in options and options['upload_to_SportTracks']) or w.user.sporttracks_auto_export:
|
||||
if ('upload_to_SportTracks' in options and options['upload_to_SportTracks']) or (w.user.sporttracks_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = sporttracksstuff.workout_sporttracks_upload(
|
||||
w.user.user,w
|
||||
@@ -401,7 +403,7 @@ def do_sync(w,options):
|
||||
id = 0
|
||||
|
||||
|
||||
if ('upload_to_RunKeeper' in options and options['upload_to_RunKeeper']) or w.user.runkeeper_auto_export:
|
||||
if ('upload_to_RunKeeper' in options and options['upload_to_RunKeeper']) or (w.user.runkeeper_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = runkeeperstuff.workout_runkeeper_upload(
|
||||
w.user.user,w
|
||||
@@ -410,7 +412,7 @@ def do_sync(w,options):
|
||||
message = "Please connect to Runkeeper first"
|
||||
id = 0
|
||||
|
||||
if ('upload_to_MapMyFitness' in options and options['upload_to_MapMyFitness']) or w.user.mapmyfitness_auto_export:
|
||||
if ('upload_to_MapMyFitness' in options and options['upload_to_MapMyFitness']) or (w.user.mapmyfitness_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = underarmourstuff.workout_ua_upload(
|
||||
w.user.user,w
|
||||
@@ -420,7 +422,7 @@ def do_sync(w,options):
|
||||
id = 0
|
||||
|
||||
|
||||
if ('upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']) or w.user.trainingpeaks_auto_export:
|
||||
if ('upload_to_TrainingPeaks' in options and options['upload_to_TrainingPeaks']) or (w.user.trainingpeaks_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = tpstuff.workout_tp_upload(
|
||||
w.user.user,w
|
||||
|
||||
@@ -369,3 +369,12 @@ def totaltime_sec_to_string(totaltime):
|
||||
duration = "%s:%s:%s.%s" % (hours, minutes, seconds, tenths)
|
||||
|
||||
return duration
|
||||
|
||||
def isprorower(r):
|
||||
result = False
|
||||
result = r.rowerplan in ['pro','coach','plan']
|
||||
if not result and r.protrialexpires:
|
||||
result = r.rowerplan is 'basic' and r.protrialexpires >= datetime.date.today()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -926,6 +926,8 @@ def hasplannedsessions(user):
|
||||
|
||||
return result
|
||||
|
||||
from rowers.utils import isprorower
|
||||
|
||||
# Check if a user is a Pro member
|
||||
def ispromember(user):
|
||||
if not user.is_anonymous():
|
||||
@@ -934,10 +936,8 @@ def ispromember(user):
|
||||
except Rower.DoesNotExists:
|
||||
r = Rower(user=user)
|
||||
r.save()
|
||||
|
||||
result = user.is_authenticated() and (r.rowerplan=='pro' or r.rowerplan=='coach' or r.rowerplan=='plan')
|
||||
if not result and r.protrialexpires:
|
||||
result = user.is_authenticated() and r.rowerplan=='basic' and r.protrialexpires >= datetime.date.today()
|
||||
|
||||
result = user.is_authenticated() and isprorower(r)
|
||||
else:
|
||||
result = False
|
||||
return result
|
||||
@@ -2684,9 +2684,6 @@ def imports_view(request):
|
||||
|
||||
r.save()
|
||||
|
||||
# polar_auto_import = cd['polar_auto_import']
|
||||
# r.polar_auto_import = polar_auto_import
|
||||
# r.save()
|
||||
else:
|
||||
form = RowerImportExportForm(instance=r)
|
||||
|
||||
@@ -9195,6 +9192,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
distance = form.cleaned_data['distance']
|
||||
notes = form.cleaned_data['notes']
|
||||
thetimezone = form.cleaned_data['timezone']
|
||||
|
||||
try:
|
||||
boattype = request.POST['boattype']
|
||||
except KeyError:
|
||||
@@ -10516,7 +10514,7 @@ def workout_upload_view(request,
|
||||
request.session['async_tasks'] = [(jobid,'make_plot')]
|
||||
|
||||
# upload to C2
|
||||
if (upload_to_c2) or (w.user.c2_auto_export):
|
||||
if (upload_to_c2) or (w.user.c2_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = c2stuff.workout_c2_upload(request.user,w)
|
||||
except C2NoTokenError:
|
||||
@@ -10527,7 +10525,7 @@ def workout_upload_view(request,
|
||||
else:
|
||||
messages.error(request,message)
|
||||
|
||||
if (upload_to_strava) or (w.user.strava_auto_export):
|
||||
if (upload_to_strava) or (w.user.strava_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = stravastuff.workout_strava_upload(
|
||||
request.user,w
|
||||
@@ -10540,7 +10538,7 @@ def workout_upload_view(request,
|
||||
else:
|
||||
messages.error(request,message)
|
||||
|
||||
if (upload_to_st) or (w.user.sporttracks_auto_export):
|
||||
if (upload_to_st) or (w.user.sporttracks_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = sporttracksstuff.workout_sporttracks_upload(
|
||||
request.user,w
|
||||
@@ -10553,7 +10551,7 @@ def workout_upload_view(request,
|
||||
else:
|
||||
messages.error(request,message)
|
||||
|
||||
if (upload_to_rk) or (w.user.runkeeper_auto_export):
|
||||
if (upload_to_rk) or (w.user.runkeeper_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = runkeeperstuff.workout_runkeeper_upload(
|
||||
request.user,w
|
||||
@@ -10568,7 +10566,7 @@ def workout_upload_view(request,
|
||||
messages.error(request,message)
|
||||
|
||||
|
||||
if (upload_to_ua) or (w.user.mapmyfitness_auto_export):
|
||||
if (upload_to_ua) or (w.user.mapmyfitness_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = underarmourstuff.workout_ua_upload(
|
||||
request.user,w
|
||||
@@ -10583,7 +10581,7 @@ def workout_upload_view(request,
|
||||
messages.error(request,message)
|
||||
|
||||
|
||||
if (upload_to_tp) or (w.user.trainingpeaks_auto_export):
|
||||
if (upload_to_tp) or (w.user.trainingpeaks_auto_export and isprorower(w.user)):
|
||||
try:
|
||||
message,id = tpstuff.workout_tp_upload(
|
||||
request.user,w
|
||||
|
||||
Reference in New Issue
Block a user