Skip to content

Commit

Permalink
add mark info to search results
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name authored and alphatownsman committed Jan 1, 2025
1 parent 11b2c74 commit 0dbc12e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion catalog/templates/_item_card_metadata_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h5>
</div>
{% endblock full %}
</div>
{% if show_tags %}
{% if not mark and not mark.shelf %}
<div class="tag-list solo-hidden">
{% for tag in item.tags %}
{% if forloop.counter <= 5 %}
Expand Down
4 changes: 2 additions & 2 deletions catalog/templates/search_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h5>{% trans 'tag' %}: “{{ request.GET.tag }}”</h5>
{% endif %}
<div class="item-card-list">
{% for item in items %}
{% include '_list_item.html' with show_tags=1 %}
{% include '_list_item.html' %}
{% empty %}
<p>
{% trans "No items matching your search query." %}
Expand All @@ -50,7 +50,7 @@ <h5>{% trans 'tag' %}: “{{ request.GET.tag }}”</h5>
</p>
<div class="item-card-list folded" id="dup">
{% for item in dup_items %}
{% include '_list_item.html' with show_tags=1 %}
{% include '_list_item.html' %}
{% endfor %}
</div>
{% endif %}
Expand Down
32 changes: 16 additions & 16 deletions journal/templates/_list_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{% load l10n %}
{% load user_actions %}
{% load duration %}
{% if not mark %}
{% get_mark_for_item item as mark %}
{% endif %}
<article class="entity-sort item-card"
{% if collection_edit %}data-member-id="{{ collection_member.id }}"{% endif %}>
<span class="action">
Expand All @@ -16,9 +19,8 @@
</a>
</span>
{% elif request.user.is_authenticated and item.class_name != 'collection' %}
{% wish_item_action item as action %}
<span>
{% if not action.taken %}
{% if not mark.shelf_type %}
<a title="{% trans "add mark" %}"
hx-get="{% url 'journal:mark' item.uuid %}?shelf_type=wishlist"
hx-target="body"
Expand All @@ -41,28 +43,26 @@
{% if mark or collection_edit or collection_member.note %}
<footer>
{% if mark %}
{% if mark.action_label %}
{% if mark.shelf %}
<section>
<div class="action">
<span class="timestamp">{{ mark.created_time|date }}</span>
</div>
<span class="tag-list">
{% for tag in mark.tags %}
{% if forloop.counter <= 5 %}
<span>
<a href="{% url 'common:search' %}?c=journal&amp;q=tag:{{ tag }}">{{ tag }}</a>
</span>
{% endif %}
{% endfor %}
</span>
<div>
{% comment %} <a href="{{mark.owner.url }}" title="@{{ mark.owner.handle }}">{{ mark.owner.display_name }}</a> {% endcomment %}
<span>{{ mark.action_label }}</span>
<span>{{ mark.status_label }}</span>
{% if mark.rating_grade %}{{ mark.rating_grade|rating_star }}{% endif %}
<span>{{ mark.comment.html|safe }}</span>
</div>
{% if mark.tags %}
<div class="tag-list">
{% for tag in mark.tags %}
{% if forloop.counter <= 5 %}
<span>
<a href="{% url 'common:search' %}?tag={{ tag }}">{{ tag }}</a>
</span>
{% endif %}
{% endfor %}
</div>
{% endif %}
<div>{{ mark.comment.html|safe }}</div>
</section>
{% endif %}
{% if mark.review %}
Expand Down
13 changes: 5 additions & 8 deletions journal/templatetags/user_actions.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
from django import template
from django.urls import reverse

from journal.models.mark import Mark
from takahe.utils import Takahe

register = template.Library()


@register.simple_tag(takes_context=True)
def wish_item_action(context, item):
def get_mark_for_item(context, item):
user = context["request"].user
action = {}
if user and user.is_authenticated and item:
action = {
"taken": user.shelf_manager.locate_item(item) is not None,
"url": reverse("journal:wish", args=[item.uuid]),
}
return action
return (
Mark(user.identity, item) if user and user.is_authenticated and item else None
)


@register.simple_tag(takes_context=True)
Expand Down

0 comments on commit 0dbc12e

Please sign in to comment.