duplicates concept
This commit is contained in:
1
rowers/.#models.py
Normal file
1
rowers/.#models.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
E408191@CZ27LT9RCGN72.21348:1542056188
|
||||||
@@ -999,13 +999,30 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
maxhr = np.nan_to_num(maxhr)
|
maxhr = np.nan_to_num(maxhr)
|
||||||
averagehr = np.nan_to_num(averagehr)
|
averagehr = np.nan_to_num(averagehr)
|
||||||
|
|
||||||
|
duplicate = True
|
||||||
|
|
||||||
|
t = datetime.datetime.strptime(duration,"%H:%M:%S.%f")
|
||||||
|
delta = datetime.timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)
|
||||||
|
|
||||||
|
workoutenddatetime = workoutstartdatetime+delta
|
||||||
|
|
||||||
# check for duplicate start times and duration
|
# check for duplicate start times and duration
|
||||||
ws = Workout.objects.filter(startdatetime=workoutstartdatetime,
|
ws = Workout.objects.filter(user=r,date=workoutdate).exclude(
|
||||||
distance=totaldist,
|
startdatetime__gt=workoutenddatetime
|
||||||
user=r)
|
)
|
||||||
if (len(ws) != 0):
|
|
||||||
message = "Warning: This workout probably already exists in the database"
|
ws2 = []
|
||||||
privacy = 'hidden'
|
|
||||||
|
for ww in ws:
|
||||||
|
t = ww.duration
|
||||||
|
delta = datetime.timedelta(hours=t.hour, minutes=t.minute, seconds=t.second)
|
||||||
|
enddatetime = ww.startdatetime+delta
|
||||||
|
if enddatetime > workoutstartdatetime:
|
||||||
|
ws2.append(ww)
|
||||||
|
|
||||||
|
if (len(ws2) != 0):
|
||||||
|
message = "Warning: This workout overlaps with an existing one and was marked as a duplicate"
|
||||||
|
duplicate = True
|
||||||
|
|
||||||
|
|
||||||
w = Workout(user=r, name=title, date=workoutdate,
|
w = Workout(user=r, name=title, date=workoutdate,
|
||||||
@@ -1014,6 +1031,7 @@ def save_workout_database(f2, r, dosmooth=True, workouttype='rower',
|
|||||||
duration=duration, distance=totaldist,
|
duration=duration, distance=totaldist,
|
||||||
weightcategory=r.weightcategory,
|
weightcategory=r.weightcategory,
|
||||||
starttime=workoutstarttime,
|
starttime=workoutstarttime,
|
||||||
|
duplicate=duplicate,
|
||||||
workoutsource=workoutsource,
|
workoutsource=workoutsource,
|
||||||
rankingpiece=rankingpiece,
|
rankingpiece=rankingpiece,
|
||||||
forceunit=forceunit,
|
forceunit=forceunit,
|
||||||
|
|||||||
@@ -2134,6 +2134,7 @@ class Workout(models.Model):
|
|||||||
privacy = models.CharField(default='visible',max_length=30,
|
privacy = models.CharField(default='visible',max_length=30,
|
||||||
choices=privacychoices)
|
choices=privacychoices)
|
||||||
rankingpiece = models.BooleanField(default=False,verbose_name='Ranking Piece')
|
rankingpiece = models.BooleanField(default=False,verbose_name='Ranking Piece')
|
||||||
|
duplicate = models.BooleanField(default=False,verbose_name='Duplicate Workout')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
||||||
@@ -2404,7 +2405,7 @@ class WorkoutForm(ModelForm):
|
|||||||
# duration = forms.TimeInput(format='%H:%M:%S.%f')
|
# duration = forms.TimeInput(format='%H:%M:%S.%f')
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Workout
|
model = Workout
|
||||||
fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','rankingpiece']
|
fields = ['name','date','starttime','timezone','duration','distance','workouttype','boattype','weightcategory','notes','rankingpiece','duplicate']
|
||||||
widgets = {
|
widgets = {
|
||||||
'date': AdminDateWidget(),
|
'date': AdminDateWidget(),
|
||||||
'notes': forms.Textarea,
|
'notes': forms.Textarea,
|
||||||
|
|||||||
@@ -3380,6 +3380,11 @@ def addmanual_view(request):
|
|||||||
rankingpiece = form.cleaned_data['rankingpiece']
|
rankingpiece = form.cleaned_data['rankingpiece']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
rankingpiece = False
|
rankingpiece = False
|
||||||
|
|
||||||
|
try:
|
||||||
|
duplicate = form.cleaned_data['duplicate']
|
||||||
|
except KeyError:
|
||||||
|
duplicate = False
|
||||||
|
|
||||||
if private:
|
if private:
|
||||||
privacy = 'private'
|
privacy = 'private'
|
||||||
@@ -3403,6 +3408,7 @@ def addmanual_view(request):
|
|||||||
avghr=avghr,
|
avghr=avghr,
|
||||||
rankingpiece=rankingpiece,
|
rankingpiece=rankingpiece,
|
||||||
avgpwr=avgpwr,
|
avgpwr=avgpwr,
|
||||||
|
duplicate=duplicate,
|
||||||
avgspm=avgspm,
|
avgspm=avgspm,
|
||||||
title = name,
|
title = name,
|
||||||
notes=notes,
|
notes=notes,
|
||||||
|
|||||||
Reference in New Issue
Block a user