first version
This commit is contained in:
@@ -83,8 +83,24 @@
|
||||
</li>
|
||||
|
||||
{% if workouts %}
|
||||
{% if request.GET.selectworkouts %}
|
||||
<li class="grid_4">
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
<h3>Bulk Operation</h3>
|
||||
<select name="selectworkouts_operation" id="selectworkouts_operation">
|
||||
<option value="">--Please choose an option--</option>
|
||||
<option value="remove">Remove</option>
|
||||
</select>
|
||||
{% csrf_token %}
|
||||
<input name='selectworkouts' type="submit" value="Submit">
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% for workout in workouts %}
|
||||
<li class="grid_4 divlines">
|
||||
{% if request.GET.selectworkouts %}
|
||||
<input type="checkbox" id="workoutid" value={{ workout.id|encode }} name="workoutid" />
|
||||
{% endif %}
|
||||
{{ workout.date|date:"Y-m-d" }} {{ workout.starttime|date:"H:i" }}
|
||||
{% if workout.duplicate %}
|
||||
<span style="font-size: smaller"><i class="fal fa-angle-double-up"></i></span>
|
||||
@@ -181,6 +197,9 @@
|
||||
{% else %}
|
||||
<li> No workouts found </li>
|
||||
{% endif %}
|
||||
{% if request.GET.selectworkouts %}
|
||||
</form>
|
||||
{% endif %}
|
||||
<li class="grid_4">
|
||||
<p>Filter on date
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
|
||||
@@ -2047,7 +2047,16 @@ def workouts_view(request, message='', successmessage='',
|
||||
enddate = datetime.datetime.combine(enddate, datetime.time(23, 59, 59))
|
||||
|
||||
query = None
|
||||
|
||||
if request.method == 'POST':
|
||||
print(request.POST)
|
||||
if 'selectworkouts' in request.POST:
|
||||
if 'remove' in request.POST.get('selectworkouts_operation'):
|
||||
remove_ids = request.POST.getlist('workoutid')
|
||||
for id in remove_ids:
|
||||
w = Workout.objects.get(id=encoder.decode_hex(id))
|
||||
messages.info(request,'Removed workout '+str(id))
|
||||
w.delete()
|
||||
dateform = DateRangeForm(request.POST)
|
||||
searchform = SearchForm(request.POST)
|
||||
if dateform.is_valid(): # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user