add mark_history page. add delete all logs
This commit is contained in:
parent
e1ceaadec0
commit
7952bc4820
6 changed files with 128 additions and 6 deletions
|
@ -135,9 +135,6 @@
|
|||
margin: 2rem 0;
|
||||
}
|
||||
|
||||
span.log-details {
|
||||
font-size: 20%;
|
||||
}
|
||||
|
||||
@media (min-width: 769px) {
|
||||
|
||||
|
|
|
@ -11,6 +11,32 @@
|
|||
}
|
||||
}
|
||||
|
||||
#mark-history-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.log-info {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
#log-delete-all {
|
||||
margin-left: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
align-items: center;
|
||||
display: inline;
|
||||
padding: calc(var(--pico-spacing)/6);
|
||||
border-radius: calc(var(--pico-spacing)/4);
|
||||
border-width: 2px;
|
||||
font-size: 80%;
|
||||
font-weight: lighter;
|
||||
word-break: keep-all;
|
||||
opacity: 1;
|
||||
font-weight: 400;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.mark-line {
|
||||
|
||||
|
|
|
@ -1237,9 +1237,9 @@ class Mark:
|
|||
self.shelfmember.metadata["shared_link"] = None
|
||||
self.shelfmember.save()
|
||||
|
||||
def delete(self):
|
||||
def delete(self, silence=False):
|
||||
self.logs.delete() # When deleting a mark, all logs of the mark are deleted first.
|
||||
self.update(None, None, None, 0)
|
||||
self.update(None, None, None, 0, silence=silence)
|
||||
|
||||
def delete_log(self, log_id):
|
||||
ShelfLogEntry.objects.filter(
|
||||
|
|
76
journal/templates/mark_history.html
Normal file
76
journal/templates/mark_history.html
Normal file
|
@ -0,0 +1,76 @@
|
|||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load admin_url %}
|
||||
{% load mastodon %}
|
||||
{% load oauth_token %}
|
||||
{% load truncate %}
|
||||
{% load thumb %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" class="content-page">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ site_name }} - {{ item.title }} - {% trans '标记历史' %}</title>
|
||||
{% include "common_libs.html" with jquery=0 v2=1 %}
|
||||
<style type="text/css">#id_visibility, #id_visibility li {padding-left:0; margin-bottom:0; display: inline-block !important;}</style>
|
||||
</head>
|
||||
<body>
|
||||
{% include "_header.html" %}
|
||||
<main>
|
||||
<div>
|
||||
<div id="mark-history-header">
|
||||
<h3>标记历史</h3>
|
||||
{% if mark.logs %}
|
||||
<form id="mark_delete"
|
||||
action="{% url 'journal:mark' mark.item.uuid %}"
|
||||
method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="delete" value="1">
|
||||
<input type="hidden" name="silence" value="True">
|
||||
<a>
|
||||
<button class="secondary"
|
||||
id="log-delete-all"
|
||||
onclick="return confirm('确认清空标记历史?当前标记也会一并删除')">清空标记历史</button>
|
||||
</a>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if mark.logs %}
|
||||
<article>
|
||||
<div>
|
||||
{% for log in mark.logs %}
|
||||
<div>
|
||||
<form id="mark_log_delete_{{ log.id }}"
|
||||
action="{% url 'journal:mark_log' item.uuid log.id %}"
|
||||
method="post">
|
||||
{% csrf_token %}
|
||||
<span class="log-info">•</span>
|
||||
<span class="timestamp log-info">{{ log.timestamp|date }}</span>
|
||||
<span class="log-info">{{ log.action_label }}</span>
|
||||
<input type="hidden" name="delete" value="1">
|
||||
<input type="hidden" name="log_id" id="{{ log.id }}">
|
||||
<a href="javascript:$('#mark_log_delete_{{ log.id }}').submit()"
|
||||
class="delete">
|
||||
<i class="fa-solid fa-square-xmark"></i>
|
||||
</a>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</article>
|
||||
{% endif %}
|
||||
<br>
|
||||
<a href="{% url 'catalog:retrieve' item.url_path item.uuid %}">返回条目</a>
|
||||
</div>
|
||||
<aside>
|
||||
{% include "_sidebar_item.html" with item=item %}
|
||||
</aside>
|
||||
</main>
|
||||
<script>
|
||||
$(".spoiler").on('click', function(){
|
||||
$(this).toggleClass('revealed');
|
||||
})
|
||||
</script>
|
||||
{% include "_footer.html" %}
|
||||
</body>
|
||||
</html>
|
|
@ -23,6 +23,9 @@ urlpatterns = [
|
|||
path("mark/<str:item_uuid>", mark, name="mark"),
|
||||
path("comment/<str:item_uuid>", comment, name="comment"),
|
||||
path("mark_log/<str:item_uuid>/<str:log_id>", mark_log, name="mark_log"),
|
||||
path(
|
||||
"mark_history/<str:item_uuid>", mark_history, name="mark_history"
|
||||
),
|
||||
path(
|
||||
"add_to_collection/<str:item_uuid>", add_to_collection, name="add_to_collection"
|
||||
),
|
||||
|
|
|
@ -159,7 +159,12 @@ def mark(request, item_uuid):
|
|||
)
|
||||
elif request.method == "POST":
|
||||
if request.POST.get("delete", default=False):
|
||||
mark.delete()
|
||||
silence = request.POST.get("silence", False)
|
||||
mark.delete(silence=silence)
|
||||
if silence: # this means the mark is deleted from mark_history, thus redirect to item page
|
||||
return redirect(
|
||||
reverse("catalog:retrieve", args=[item.url_path, item.uuid])
|
||||
)
|
||||
return HttpResponseRedirect(request.META.get("HTTP_REFERER"))
|
||||
else:
|
||||
visibility = int(request.POST.get("visibility", default=0))
|
||||
|
@ -267,6 +272,21 @@ def mark_log(request, item_uuid, log_id):
|
|||
raise BadRequest()
|
||||
|
||||
|
||||
@login_required
|
||||
def mark_history(request, item_uuid):
|
||||
item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid))
|
||||
mark = Mark(request.user, item)
|
||||
if request.method == "GET":
|
||||
return render(
|
||||
request,
|
||||
"mark_history.html",
|
||||
{
|
||||
"item": item,
|
||||
"mark": mark,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def comment(request, item_uuid):
|
||||
item = get_object_or_404(Item, uid=get_uuid_or_404(item_uuid))
|
||||
|
|
Loading…
Add table
Reference in a new issue