Skip to content

Commit

Permalink
Merge pull request #394 from Gary-Community-Ventures/bug/document-inc…
Browse files Browse the repository at this point in the history
…orrect-redirect

Bug/Document Translate Page Incorrect Redirect
  • Loading branch information
msrezaie authored Jun 3, 2024
2 parents ed2ebd0 + d7c1155 commit 051acaf
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
25 changes: 25 additions & 0 deletions programs/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,31 @@ class FederalPovertyLimitAdmin(ModelAdmin):

class DocumentAdmin(ModelAdmin):
search_fields = ("external_name",)
list_display = ["get_str", "action_buttons"]

def get_str(self, obj):
return str(obj)

get_str.admin_order_field = "external_name"
get_str.short_description = "Document"

def action_buttons(self, obj):
text = obj.text

return format_html(
"""
<div class="dropdown">
<span class="dropdown-btn material-symbols-outlined"> menu </span>
<div class="dropdown-content">
<a href="{}">Document Text</a>
</div>
</div>
""",
reverse("translation_admin_url", args=[text.id]),
)

action_buttons.short_description = "Translate:"
action_buttons.allow_tags = True


class ReferrerAdmin(ModelAdmin):
Expand Down
6 changes: 3 additions & 3 deletions translations/templates/documents/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<tr>
<th>ID</th>
<th>External Name</th>
<th>External Name Label</th>
<th>Text Label</th>
<th>Actions</th>
</tr>
</thead>
Expand All @@ -17,7 +17,7 @@
<tr>
<td>{{ document.id }}</td>
<td>{{ document.external_name }}</td>
<td>{{ document.name }}</td>
<td>{{ document.text }}</td>
<td>
<div class="dropdown">
<div class="dropdown-trigger">
Expand All @@ -37,7 +37,7 @@
>
<div class="dropdown-content">
<a
href="/api/translations/admin/{{ document.id }}"
href="/api/translations/admin/{{ document.text.id }}"
class="dropdown-item"
>Edit</a
>
Expand Down
4 changes: 2 additions & 2 deletions translations/templates/navigators/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@
</tr>
{% empty %}
<tr>
<td colspan="5">No results</td>
<td colspan="6">No results</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="5">Total: {{ page_obj.paginator.count }}</td>
<td colspan="6">Total: {{ page_obj.paginator.count }}</td>
</tr>
</tfoot>
</table>
Expand Down
4 changes: 2 additions & 2 deletions translations/templates/urgent_needs/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@
</tr>
{% empty %}
<tr>
<td colspan="4">No results</td>
<td colspan="5">No results</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<td colspan="4">Total: {{ page_obj.paginator.count }}</td>
<td colspan="5">Total: {{ page_obj.paginator.count }}</td>
</tr>
</tfoot>
</table>
Expand Down

0 comments on commit 051acaf

Please sign in to comment.