add feature to remove duplicates
This commit is contained in:
BIN
db.sqlite3-journal
Normal file
BIN
db.sqlite3-journal
Normal file
Binary file not shown.
@@ -37,6 +37,15 @@
|
||||
<i class="fas fa-layer-plus fa-fw"></i> Glue Workouts
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
{% if user|is_promember %}
|
||||
<a href="/rowers/workouts-dupes-select/">
|
||||
{% else %}
|
||||
<a href="/rowers/paidplans/">
|
||||
{% endif %}
|
||||
<i class="fas fa-trash-alt fa-fw"></i> Remove Duplicates
|
||||
</a>
|
||||
</li>
|
||||
<li class="has-children" id="imports">
|
||||
<input type="checkbox" name ="group-1" id="group-1">
|
||||
<label for="group-1"><i class="fas fa-cloud-download fa-fw"></i> Import</label>
|
||||
|
||||
50
rowers/templates/workout_duplicates_select.html
Normal file
50
rowers/templates/workout_duplicates_select.html
Normal file
@@ -0,0 +1,50 @@
|
||||
{% extends "newbase.html" %}
|
||||
{% load static %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Workouts{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<script>
|
||||
function toggle(source) {
|
||||
checkboxes = document.querySelectorAll("input[name='workouts']");
|
||||
for(var i=0, n=checkboxes.length;i<n;i++) {
|
||||
checkboxes[i].checked = source.checked;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<h1>{{ team.name }} Select Duplicate Workouts</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<li class="grid_4">
|
||||
<p>
|
||||
The workouts in the list are duplicate workouts. They are overlapping in time with other
|
||||
workouts you have performed. They are not used in analysis or statistics. With the
|
||||
form below you can select any number of duplicate workouts and remove them
|
||||
permanently. This action is not reversible.
|
||||
</p>
|
||||
{% if workouts %}
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
|
||||
|
||||
<table width="100%" class="listtable">
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input name='workoutselectform' type="submit" value="Remove Selected">
|
||||
</form>
|
||||
{% else %}
|
||||
<p> No workouts found </p>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
{% block sidebar %}
|
||||
{% include 'menu_workouts.html' %}
|
||||
{% endblock %}
|
||||
@@ -349,6 +349,8 @@ urlpatterns = [
|
||||
re_path(
|
||||
r'^user-analysis-select/(?P<function>\w.*)/team/(?P<teamid>\d+)/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',
|
||||
views.analysis_new, name='analysis_new'),
|
||||
re_path(r'^workouts-dupes-select/$',
|
||||
views.workouts_duplicates_select_view, name='workouts_duplicates_select_view'),
|
||||
re_path(
|
||||
r'^user-analysis-select/(?P<function>\w.*)/session/(?P<session>\d+)/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',
|
||||
views.analysis_new, name='analysis_new'),
|
||||
|
||||
@@ -807,6 +807,44 @@ def workout_recalcsummary_view(request, id=0):
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# Selecting duplicates
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
message="This functionality requires a Pro plan or higher."
|
||||
" If you are already a Pro user, please log in to access this functionality",
|
||||
redirect_field_name=None)
|
||||
def workouts_duplicates_select_view(request):
|
||||
r = getrequestrower(request)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = WorkoutMultipleCompareForm(request.POST)
|
||||
if form.is_valid():
|
||||
workouts = form.cleaned_data['workouts']
|
||||
for w in workouts:
|
||||
w.delete()
|
||||
|
||||
workouts = Workout.objects.filter(user=r,duplicate=True).order_by("-startdatetime")[:19]
|
||||
|
||||
form = WorkoutMultipleCompareForm()
|
||||
form.fields["workouts"].queryset = workouts
|
||||
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url': '/rowers/list-workouts/',
|
||||
'name': 'Workouts'
|
||||
},
|
||||
{'url': reverse('workouts_duplicates_select_view'),
|
||||
'name': 'Select Duplicates'
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
return render(request,'workout_duplicates_select.html',
|
||||
{
|
||||
'workouts':workouts,
|
||||
'rower':r,
|
||||
'form':form,
|
||||
'breadcrumbs': breadcrumbs,
|
||||
})
|
||||
|
||||
# Joining workout
|
||||
@user_passes_test(ispromember, login_url="/rowers/paidplans",
|
||||
|
||||
Reference in New Issue
Block a user