forked from mirrors/bookwyrm
Add deletion of progress updates
And only show progress edit for editing unfinished readthroughs
This commit is contained in:
parent
1e13997c5d
commit
da8d8cd434
4 changed files with 31 additions and 6 deletions
|
@ -45,12 +45,21 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% for progress_update in readthrough.progress_updates %}
|
{% for progress_update in readthrough.progress_updates %}
|
||||||
<li>
|
<li>
|
||||||
{{ progress_update.created_date | naturalday }}:
|
<form name="delete-update" action="/delete-progressupdate" method="POST">
|
||||||
{% if progress_update.mode == 'PG' %}
|
{% csrf_token %}
|
||||||
page {{ progress_update.progress }} of {{ book.pages }}
|
{{ progress_update.created_date | naturalday }}:
|
||||||
{% else %}
|
{% if progress_update.mode == 'PG' %}
|
||||||
{{ progress_update.progress }}%
|
page {{ progress_update.progress }} of {{ book.pages }}
|
||||||
{% endif %}
|
{% else %}
|
||||||
|
{{ progress_update.progress }}%
|
||||||
|
{% endif %}
|
||||||
|
<input type="hidden" name="id" value="{{ progress_update.id }}"/>
|
||||||
|
<button type="submit" class="button is-small" for="delete-progressupdate-{{ progress_update.id }}" role="button" tabindex="0">
|
||||||
|
<span class="icon icon-x">
|
||||||
|
<span class="is-sr-only">Delete this progress update</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<li>{{ readthrough.start_date | naturalday }}: started</li>
|
<li>{{ readthrough.start_date | naturalday }}: started</li>
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
<input type="date" name="start_date" class="input" id="id_start_date-{{ readthrough.id }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
|
<input type="date" name="start_date" class="input" id="id_start_date-{{ readthrough.id }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
{# Only show progress for editing existing readthroughs #}
|
||||||
|
{% if readthrough.id and not readthrough.finish_date %}
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">
|
<label class="label">
|
||||||
Finished reading
|
Finished reading
|
||||||
|
|
|
@ -111,6 +111,7 @@ urlpatterns = [
|
||||||
re_path(r'^edit-readthrough/?$', actions.edit_readthrough),
|
re_path(r'^edit-readthrough/?$', actions.edit_readthrough),
|
||||||
re_path(r'^delete-readthrough/?$', actions.delete_readthrough),
|
re_path(r'^delete-readthrough/?$', actions.delete_readthrough),
|
||||||
re_path(r'^create-readthrough/?$', actions.create_readthrough),
|
re_path(r'^create-readthrough/?$', actions.create_readthrough),
|
||||||
|
re_path(r'^delete-progressupdate/?$', actions.delete_progressupdate),
|
||||||
|
|
||||||
re_path(r'^rate/?$', actions.rate),
|
re_path(r'^rate/?$', actions.rate),
|
||||||
re_path(r'^review/?$', actions.review),
|
re_path(r'^review/?$', actions.review),
|
||||||
|
|
|
@ -541,6 +541,18 @@ def create_readthrough(request):
|
||||||
readthrough.save()
|
readthrough.save()
|
||||||
return redirect(request.headers.get('Referer', '/'))
|
return redirect(request.headers.get('Referer', '/'))
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@require_POST
|
||||||
|
def delete_progressupdate(request):
|
||||||
|
''' remove a progress update '''
|
||||||
|
update = get_object_or_404(models.ProgressUpdate, id=request.POST.get('id'))
|
||||||
|
|
||||||
|
# don't let people edit other people's data
|
||||||
|
if request.user != update.user:
|
||||||
|
return HttpResponseBadRequest()
|
||||||
|
|
||||||
|
update.delete()
|
||||||
|
return redirect(request.headers.get('Referer', '/'))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@require_POST
|
@require_POST
|
||||||
|
|
Loading…
Reference in a new issue