first version of autojoin (just collecting workouts)
This commit is contained in:
22
rowers/management/commands/autojoin.py
Normal file
22
rowers/management/commands/autojoin.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
import requests
|
||||||
|
import datetime
|
||||||
|
import arrow
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from rowers.models import Rower,Workout
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
rs = (r for r in Rower.objects.all() if r.ispaid and r.autojoin)
|
||||||
|
now = timezone.now()
|
||||||
|
|
||||||
|
for r in rs:
|
||||||
|
workouts = Workout.objects.filter(user=r,
|
||||||
|
startdatetime__gte=timezone.now()-datetime.timedelta(days=2))
|
||||||
|
|
||||||
|
|
||||||
|
print('ready autojoin')
|
||||||
@@ -901,6 +901,9 @@ class Rower(models.Model):
|
|||||||
slowpaceotw = models.DurationField(default=otwpaceslow,verbose_name='Slowest OTW Pace')
|
slowpaceotw = models.DurationField(default=otwpaceslow,verbose_name='Slowest OTW Pace')
|
||||||
fastpaceotw = models.DurationField(default=otwpacefast,verbose_name='Fastest OTW Pace')
|
fastpaceotw = models.DurationField(default=otwpacefast,verbose_name='Fastest OTW Pace')
|
||||||
|
|
||||||
|
# Auto Join
|
||||||
|
autojoin = models.BooleanField(default=False,verbose_name='Auto Join Workout Segments')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.first_name+' '+self.user.last_name
|
return self.user.first_name+' '+self.user.last_name
|
||||||
|
|
||||||
@@ -935,6 +938,10 @@ class Rower(models.Model):
|
|||||||
|
|
||||||
return coaches
|
return coaches
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ispaid(self):
|
||||||
|
return self.rowerplan in ['pro','plan','coach']
|
||||||
|
|
||||||
class DeactivateUserForm(forms.ModelForm):
|
class DeactivateUserForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
|
|||||||
Reference in New Issue
Block a user