diff --git a/shopping_app/routes_secondary.py b/shopping_app/routes_secondary.py index 0b52be2..5149f2d 100644 --- a/shopping_app/routes_secondary.py +++ b/shopping_app/routes_secondary.py @@ -441,9 +441,9 @@ def shared_list(token=None, list_id=None): ] for item in items: - if item.added_by != shopping_list.owner_id: + if item.added_by and item.added_by != shopping_list.owner_id: item.added_by_display = ( - item.added_by_user.username if item.added_by_user else "?" + item.added_by_user.username if item.added_by_user else None ) else: item.added_by_display = None diff --git a/shopping_app/static/css/style.css b/shopping_app/static/css/style.css index 01ec2fc..6b6f747 100644 --- a/shopping_app/static/css/style.css +++ b/shopping_app/static/css/style.css @@ -4135,6 +4135,16 @@ input[type="checkbox"].form-check-input, display: inline; } +.shopping-item-text .item-added-by-meta { + color: currentColor; + opacity: .72; + font-size: .92em; +} + +.shopping-item-text .item-added-by-meta b { + font-weight: 600; +} + .shopping-item-name, .shopping-item-text .info-line { overflow-wrap: break-word; diff --git a/shopping_app/static/js/functions.js b/shopping_app/static/js/functions.js index d3d9d5c..74b8148 100644 --- a/shopping_app/static/js/functions.js +++ b/shopping_app/static/js/functions.js @@ -350,9 +350,12 @@ function renderItem(item, isShare = window.IS_SHARE, optionsOrShowEditOnly = fal if (item.not_purchased_reason) { infoParts.push(`[ Powód: ${escapeHtml(item.not_purchased_reason)} ]`); } - const addedByDisplay = item.added_by_display; - if (addedByDisplay) { - infoParts.push(`[ Dodał/a: ${escapeHtml(addedByDisplay)} ]`); + const addedByDisplay = item.added_by_display || (isShare ? item.added_by : ''); + const addedById = item.added_by_id != null ? Number(item.added_by_id) : null; + const ownerId = item.owner_id != null ? Number(item.owner_id) : null; + const shouldShowAddedBy = !!addedByDisplay && (addedById === null || ownerId === null || addedById !== ownerId); + if (shouldShowAddedBy) { + infoParts.push(`· dodał/a: ${escapeHtml(addedByDisplay)}`); } const infoHtml = infoParts.length ? `${infoParts.join(' ')}` @@ -375,7 +378,7 @@ function renderItem(item, isShare = window.IS_SHARE, optionsOrShowEditOnly = fal if (item.not_purchased) { actionButtons += ` - `; + `; } else if (!isShare || canShowShareActions || isOwner) { actionButtons += ` `; diff --git a/shopping_app/templates/base.html b/shopping_app/templates/base.html index 4bca44b..f721010 100644 --- a/shopping_app/templates/base.html +++ b/shopping_app/templates/base.html @@ -132,9 +132,8 @@

source code - + · v{{ APP_VERSION }}

-
v{{ APP_VERSION }}
diff --git a/shopping_app/templates/list.html b/shopping_app/templates/list.html index bd8fed9..4bb1259 100644 --- a/shopping_app/templates/list.html +++ b/shopping_app/templates/list.html @@ -121,7 +121,7 @@ {% set info_parts = [] %} {% if item.note %}{% set _ = info_parts.append('[ ' ~ item.note ~ ' ]') %}{% endif %} {% if item.not_purchased_reason %}{% set _ = info_parts.append('[ Powód: ' ~ item.not_purchased_reason ~ ' ]') %}{% endif %} - {% if item.added_by_display %}{% set _ = info_parts.append('[ Dodał/a: ' ~ item.added_by_display ~ ' ]') %}{% endif %} + {% if item.added_by_display %}{% set _ = info_parts.append('· dodał/a: ' ~ item.added_by_display ~ '') %}{% endif %} {% if info_parts %} {{ info_parts | join(' ') | safe }} {% endif %} @@ -136,7 +136,7 @@ {% if item.not_purchased %} + %}onclick="unmarkNotPurchased({{ item.id }})" {% endif %}>Przywróć {% elif not item.not_purchased %} diff --git a/shopping_app/templates/list_share.html b/shopping_app/templates/list_share.html index ae8d033..1d7f650 100644 --- a/shopping_app/templates/list_share.html +++ b/shopping_app/templates/list_share.html @@ -59,7 +59,7 @@ {% set info_parts = [] %} {% if item.note %}{% set _ = info_parts.append('[ ' ~ item.note ~ ' ]') %}{% endif %} {% if item.not_purchased_reason %}{% set _ = info_parts.append('[ Powód: ' ~ item.not_purchased_reason ~ ' ]') %}{% endif %} - {% if item.added_by_display %}{% set _ = info_parts.append('[ Dodał/a: ' ~ item.added_by_display ~ ' ]') %}{% endif %} + {% if item.added_by_display %}{% set _ = info_parts.append('· dodał/a: ' ~ item.added_by_display ~ '') %}{% endif %} {% if info_parts %} {{ info_parts | join(' ') | safe }} {% endif %} @@ -68,7 +68,7 @@ {% if item.not_purchased %} {% else %}