Skip to content

Commit

Permalink
Fix thumb and report url; tags display
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Bulat <obulat@gmail.com>
  • Loading branch information
obulat committed Apr 29, 2024
1 parent 38726b3 commit 17d69fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
10 changes: 1 addition & 9 deletions api/api/admin/media_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ def get_other_reports(self, obj):
.exclude(id=obj.id)
.order_by("created_at")
)
for report in reports:
report.href = reverse(
f"admin:api_{self.media_type}report_change", args=[report.id]
)
return reports

def get_exclude(self, request, obj=None):
Expand Down Expand Up @@ -104,7 +100,7 @@ def _get_media_obj_data(self, obj):
"creator": obj.media_obj.creator or obj.media_obj.creator_url,
"creator_url": obj.media_obj.creator_url,
"url": obj.media_obj.url,
"tags": None,
"tags": {},
"reverse_media_url": reverse(
f"admin:api_{self.media_type}_change", args=[obj.media_obj.identifier]
),
Expand All @@ -115,10 +111,6 @@ def _get_media_obj_data(self, obj):
for tag in obj.media_obj.tags:
tags_by_provider.setdefault(tag["provider"], []).append(tag["name"])
additional_data["tags"] = tags_by_provider
if self.media_type == "image":
additional_data["thumb_url"] = (
f"https://api.openverse.engineering{obj.media_url()}thumb/"
)
return additional_data

def change_view(self, request, object_id, form_url="", extra_context=None):
Expand Down
14 changes: 7 additions & 7 deletions api/api/templates/admin/api/media_report/change_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,13 @@
<fieldset class="module aligned">
<h2>Media details</h2>
{% if media_type == 'image' %}
{% if thumb_url %}
<div class="img-container">
<img src="{{ thumb_url }}" alt="Media Image" class="blur-image" height="300"
<img src="{% url media_type|add:'-thumb' identifier=identifier %}" alt="Media Image" class="blur-image" height="300"
onclick="toggleBlur(this)"
onerror="this.onerror=null;this.src='{{ url }}';"
style="cursor: pointer;">
<p>Show content</p>
</div>
{% else %}
<p>No Image Available</p>
{% endif %}

{% elif media_type == 'audio' %}
<audio controls>
Expand Down Expand Up @@ -87,7 +83,11 @@ <h2>Media details</h2>
<div class="flex-container">
<label>Tags</label>
<div class="readonly">
<p>{{ tags }}</div>
{% for provider, provider_tags in tags.items %}
<p><em>{{ provider }}</em></p>
<p> {% for tag in provider_tags %}{{ tag }}, {% endfor %}</p>
{% endfor %}
</div>
</div>
</div>
<div class="form-row field-created_at">
Expand Down Expand Up @@ -125,7 +125,7 @@ <h2>Other reports</h2>
<td>{{ report.created_at }}</td>
<td>{{ report.reason }}</td>
<td>{{ report.status }}</td>
<td><a href="{% url 'admin:api_imagereport_change' report.id %}">{{ report.id }}</a></td>
<td><a href="{% url 'admin:api_'|add:media_type|add:'report_change' report.id %}">{{ report.id }}</a></td>
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit 17d69fb

Please sign in to comment.