From 8f053238c209bb54650092aa571a69015257a681 Mon Sep 17 00:00:00 2001 From: qilinz Date: Sat, 15 Jul 2023 14:49:59 +0200 Subject: [PATCH] add new edit page for mark history. remove unused scss --- catalog/templates/_item_user_pieces.html | 18 +++--- common/static/scss/_mark.scss | 35 +++++----- journal/templates/mark_history.html | 64 +++++++++--------- journal/templates/mark_history_edit.html | 82 ++++++++++++++++++++++++ journal/urls.py | 1 + journal/views.py | 41 ++++++++---- 6 files changed, 169 insertions(+), 72 deletions(-) create mode 100644 journal/templates/mark_history_edit.html diff --git a/catalog/templates/_item_user_pieces.html b/catalog/templates/_item_user_pieces.html index 8d377e3f..7acc6981 100644 --- a/catalog/templates/_item_user_pieces.html +++ b/catalog/templates/_item_user_pieces.html @@ -169,17 +169,19 @@ {% endif %} {% if mark.logs %} -
+
+ {% else %} 暂无 {% endif %} diff --git a/common/static/scss/_mark.scss b/common/static/scss/_mark.scss index fdc1c06d..3f68276c 100644 --- a/common/static/scss/_mark.scss +++ b/common/static/scss/_mark.scss @@ -11,32 +11,29 @@ } } -#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; +ul.log-list { + padding-left: 20px; + + li { + list-style-type: disc; + } } +footer.log-command { + display: flex; + justify-content: flex-end; +// flex-direction: row-reverse; + .action { + display: flex; /* Align items within each span */ + align-items: center; /* Center items vertically */ + margin-right: 10px; /* Add some spacing between items */ + } +} @media (max-width: 768px) { .mark-line { diff --git a/journal/templates/mark_history.html b/journal/templates/mark_history.html index 71d6803e..cde59817 100644 --- a/journal/templates/mark_history.html +++ b/journal/templates/mark_history.html @@ -18,45 +18,34 @@ {% include "_header.html" %}
-
-

标记历史

- {% if mark.logs %} -
- {% csrf_token %} - - - - - -
- {% endif %} -
+

标记历史

{% if mark.logs %}
-
+
    {% for log in mark.logs %} -
    -
    + {{ log.timestamp|date }} + {{ log.action_label }} + + {% endfor %} +
+ {% if mark.logs %} +
- {% endfor %} -
+ + + {% endif %} {% endif %}
@@ -71,6 +60,17 @@ $(this).toggleClass('revealed'); }) + {% include "_footer.html" %} diff --git a/journal/templates/mark_history_edit.html b/journal/templates/mark_history_edit.html new file mode 100644 index 00000000..89e5f361 --- /dev/null +++ b/journal/templates/mark_history_edit.html @@ -0,0 +1,82 @@ +{% load static %} +{% load i18n %} +{% load admin_url %} +{% load mastodon %} +{% load oauth_token %} +{% load truncate %} +{% load thumb %} + + + + + + {{ site_name }} - {{ item.title }} - {% trans '标记历史' %} + {% include "common_libs.html" with jquery=0 v2=1 %} + + + + {% include "_header.html" %} +
+
+

标记历史

+ {% if mark.logs %} +
+
    + {% for log in mark.logs %} +
  • +
    + {% csrf_token %} + {{ log.timestamp|date }} + {{ log.action_label }} + + + + + +
    +
  • + {% endfor %} +
+ +
+ {% endif %} +
+ 返回条目 +
+ +
+ + + {% include "_footer.html" %} + + diff --git a/journal/urls.py b/journal/urls.py index a4a46daf..d76b3cc8 100644 --- a/journal/urls.py +++ b/journal/urls.py @@ -24,6 +24,7 @@ urlpatterns = [ path("comment/", comment, name="comment"), path("mark_log//", mark_log, name="mark_log"), path("mark_history/", mark_history, name="mark_history"), + path("mark_history/edit/", mark_history_edit, name="mark_history_edit"), path( "add_to_collection/", add_to_collection, name="add_to_collection" ), diff --git a/journal/views.py b/journal/views.py index f9248b9b..6106b025 100644 --- a/journal/views.py +++ b/journal/views.py @@ -162,7 +162,7 @@ def mark(request, item_uuid): silence = request.POST.get("silence", False) mark.delete(silence=silence) if ( - silence + 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]) @@ -289,6 +289,21 @@ def mark_history(request, item_uuid): ) +@login_required +def mark_history_edit(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_edit.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)) @@ -393,10 +408,10 @@ def collection_retrieve(request, collection_uuid): else None ) available_as_featured = ( - request.user.is_authenticated - and (following or request.user == collection.owner) - and not featured_since - and collection.members.all().exists() + request.user.is_authenticated + and (following or request.user == collection.owner) + and not featured_since + and collection.members.all().exists() ) stats = {} if featured_since: @@ -713,13 +728,13 @@ def render_list_not_fount(request): def _render_list( - request, user_name, type, shelf_type=None, item_category=None, tag_title=None + request, user_name, type, shelf_type=None, item_category=None, tag_title=None ): user = User.get(user_name) if user is None: return render_user_not_found(request) if user != request.user and ( - request.user.is_blocked_by(user) or request.user.is_blocking(user) + request.user.is_blocked_by(user) or request.user.is_blocking(user) ): return render_user_blocked(request) tag = None @@ -791,8 +806,8 @@ def user_tag_edit(request): reverse("journal:user_tag_list", args=[request.user.mastodon_acct]) ) elif ( - tag_title != tag.title - and Tag.objects.filter(owner=request.user, title=tag_title).exists() + tag_title != tag.title + and Tag.objects.filter(owner=request.user, title=tag_title).exists() ): msg.error(request.user, _("标签已存在")) return HttpResponseRedirect(request.META.get("HTTP_REFERER")) @@ -821,7 +836,7 @@ def user_tag_list(request, user_name): if user is None: return render_user_not_found(request) if user != request.user and ( - request.user.is_blocked_by(user) or request.user.is_blocking(user) + request.user.is_blocked_by(user) or request.user.is_blocking(user) ): return render_user_blocked(request) tags = Tag.objects.filter(owner=user) @@ -844,7 +859,7 @@ def user_collection_list(request, user_name): if user is None: return render_user_not_found(request) if user != request.user and ( - request.user.is_blocked_by(user) or request.user.is_blocking(user) + request.user.is_blocked_by(user) or request.user.is_blocking(user) ): return render_user_blocked(request) collections = Collection.objects.filter(owner=user) @@ -869,7 +884,7 @@ def user_liked_collection_list(request, user_name): if user is None: return render_user_not_found(request) if user != request.user and ( - request.user.is_blocked_by(user) or request.user.is_blocking(user) + request.user.is_blocked_by(user) or request.user.is_blocking(user) ): return render_user_blocked(request) collections = Collection.objects.filter(likes__owner=user) @@ -897,7 +912,7 @@ def profile(request, user_name): if not request.user.is_authenticated and user.get_preference().no_anonymous_view: return render(request, "users/home_anonymous.html", {"user": user}) if user != request.user and ( - user.is_blocked_by(request.user) or user.is_blocking(request.user) + user.is_blocked_by(request.user) or user.is_blocking(request.user) ): return render_user_blocked(request)