added option to kill parents with join workouts
This commit is contained in:
@@ -408,7 +408,7 @@ def filter_df(datadf, fieldname, value, largerthan=True):
|
|||||||
def join_workouts(r,ids,title='Joined Workout',
|
def join_workouts(r,ids,title='Joined Workout',
|
||||||
parent=None,
|
parent=None,
|
||||||
setprivate=False,
|
setprivate=False,
|
||||||
forceunit='lbs'):
|
forceunit='lbs',killparents=False):
|
||||||
|
|
||||||
message = None
|
message = None
|
||||||
|
|
||||||
@@ -477,6 +477,10 @@ def join_workouts(r,ids,title='Joined Workout',
|
|||||||
dosmooth=False,
|
dosmooth=False,
|
||||||
consistencychecks=False)
|
consistencychecks=False)
|
||||||
|
|
||||||
|
if killparents:
|
||||||
|
for w in ws:
|
||||||
|
w.delete()
|
||||||
|
|
||||||
return (id, message)
|
return (id, message)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1091,6 +1091,8 @@ metricchoices = list(sorted(formaxlabels.items(), key = lambda x:x[1]))
|
|||||||
class WorkoutJoinParamForm(forms.Form):
|
class WorkoutJoinParamForm(forms.Form):
|
||||||
workout_name = forms.CharField(required = True, initial = 'Joined Workout')
|
workout_name = forms.CharField(required = True, initial = 'Joined Workout')
|
||||||
set_private = forms.BooleanField(initial=False, required = False)
|
set_private = forms.BooleanField(initial=False, required = False)
|
||||||
|
killparents = forms.BooleanField(initial=False, required = False,
|
||||||
|
label='Delete original workouts')
|
||||||
|
|
||||||
class FusionMetricChoiceForm(ModelForm):
|
class FusionMetricChoiceForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -17,21 +17,21 @@
|
|||||||
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
// Get the form fields and hidden div
|
// Get the form fields and hidden div
|
||||||
var modality = $("#id_modality");
|
var modality = $("#id_modality");
|
||||||
var hidden = $("#id_waterboattype");
|
var hidden = $("#id_waterboattype");
|
||||||
|
|
||||||
|
|
||||||
// Hide the fields.
|
// Hide the fields.
|
||||||
// Use JS to do this in case the user doesn't have JS
|
// Use JS to do this in case the user doesn't have JS
|
||||||
// enabled.
|
// enabled.
|
||||||
|
|
||||||
hidden.hide();
|
hidden.hide();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Setup an event listener for when the state of the
|
// Setup an event listener for when the state of the
|
||||||
// checkbox changes.
|
// checkbox changes.
|
||||||
modality.change(function() {
|
modality.change(function() {
|
||||||
// Check to see if the checkbox is checked.
|
// Check to see if the checkbox is checked.
|
||||||
@@ -45,10 +45,10 @@
|
|||||||
// Make sure that the hidden fields are indeed
|
// Make sure that the hidden fields are indeed
|
||||||
// hidden.
|
// hidden.
|
||||||
hidden.hide();
|
hidden.hide();
|
||||||
|
|
||||||
// You may also want to clear the value of the
|
// You may also want to clear the value of the
|
||||||
// hidden fields here. Just in case somebody
|
// hidden fields here. Just in case somebody
|
||||||
// shows the fields, enters data to them and then
|
// shows the fields, enters data to them and then
|
||||||
// unticks the checkbox.
|
// unticks the checkbox.
|
||||||
//
|
//
|
||||||
// This would do the job:
|
// This would do the job:
|
||||||
@@ -60,12 +60,20 @@
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
console.log('kill parents')
|
||||||
|
$("#id_killparents").change(function() {
|
||||||
|
if (this.checked) {
|
||||||
|
$("#id_killparentswarning").html("<p><em>Warning: Deleted workouts cannot be recovered</em></p>");
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h1>{{ team.name }} Glue Workouts</h1>
|
<h1>{{ team.name }} Glue Workouts</h1>
|
||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
@@ -76,7 +84,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<form id="searchform" action="/rowers/workouts-join-select/"
|
<form id="searchform" action="/rowers/workouts-join-select/"
|
||||||
method="get" accept-charset="utf-8">
|
method="get" accept-charset="utf-8">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ searchform }}
|
{{ searchform }}
|
||||||
<input type="submit" value="GO"></input>
|
<input type="submit" value="GO"></input>
|
||||||
</form>
|
</form>
|
||||||
@@ -84,7 +92,7 @@
|
|||||||
<li class="grid_2 maxheight">
|
<li class="grid_2 maxheight">
|
||||||
<form enctype="multipart/form-data" action="/rowers/workouts-join/" method="post">
|
<form enctype="multipart/form-data" action="/rowers/workouts-join/" method="post">
|
||||||
{% if workouts %}
|
{% if workouts %}
|
||||||
|
|
||||||
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
|
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
|
||||||
|
|
||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
@@ -97,10 +105,14 @@
|
|||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
<p>Select two or more workouts on the left,
|
<p>Select two or more workouts on the left,
|
||||||
and press submit</p>
|
and press submit. Be careful with the "delete original workouts" option. Deleted
|
||||||
|
workouts cannot be recovered.</p>
|
||||||
<table>
|
<table>
|
||||||
{{ joinparamform.as_table }}
|
{{ joinparamform.as_table }}
|
||||||
</table>
|
</table>
|
||||||
|
<div id="id_killparentswarning">
|
||||||
|
|
||||||
|
</div>
|
||||||
<p>
|
<p>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input name='workoutselectform' type="submit" value="Submit">
|
<input name='workoutselectform' type="submit" value="Submit">
|
||||||
@@ -127,6 +139,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block sidebar %}
|
{% block sidebar %}
|
||||||
{% include 'menu_workouts.html' %}
|
{% include 'menu_workouts.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -890,6 +890,7 @@ def workouts_join_view(request,userid=0):
|
|||||||
if form.is_valid() and paramform.is_valid():
|
if form.is_valid() and paramform.is_valid():
|
||||||
workout_name = paramform.cleaned_data['workout_name']
|
workout_name = paramform.cleaned_data['workout_name']
|
||||||
set_private = paramform.cleaned_data['set_private']
|
set_private = paramform.cleaned_data['set_private']
|
||||||
|
killparents = paramform.cleaned_data['killparents']
|
||||||
|
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
workouts = cd['workouts']
|
workouts = cd['workouts']
|
||||||
@@ -899,7 +900,8 @@ def workouts_join_view(request,userid=0):
|
|||||||
|
|
||||||
id,message = dataprep.join_workouts(r,ids,
|
id,message = dataprep.join_workouts(r,ids,
|
||||||
title=workout_name,
|
title=workout_name,
|
||||||
setprivate=set_private)
|
setprivate=set_private,
|
||||||
|
killparents=killparents)
|
||||||
|
|
||||||
if message:
|
if message:
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
|
|||||||
Reference in New Issue
Block a user