Skip to content

Commit

Permalink
Merge pull request #505 from UW-GAC/feature/workspace-pills-template-…
Browse files Browse the repository at this point in the history
…block

Add "extra_pills" template block to the workspace detail template
  • Loading branch information
amstilp committed Aug 7, 2024
2 parents 553eb9e + 7f47dea commit 500d6d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Add model class checks to adapter methods where appropriate.
* Drop support for MariaDB 10.4.
* Drop support for Python 3.8.
* Add a new `extra_pills` block to the workspace detail template, which allows users to add additional pills/badges to the workspace detail page for a given workspace type.


## 0.24.0 (2024-07-03)
Expand Down
2 changes: 1 addition & 1 deletion anvil_consortium_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.25.0.dev1"
__version__ = "0.25.0.dev2"
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
</span>
{% endif %}

{% block extra_pills %}
{% endblock extra_pills %}

{% if has_access or user.is_superuser %}
<a class="badge bg-light text-dark btn btn-light" href="{{ object.get_anvil_url }}" target="_blank" role="button">
<span class="fa-solid fa-arrow-up-right-from-square mx-1"></span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% block extra_pills %}
<span class="badge">Extra workspace pill</span>
{% endblock extra_pills %}
12 changes: 12 additions & 0 deletions anvil_consortium_manager/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7385,6 +7385,18 @@ def test_no_dates_for_view_permission(self):
self.assertNotContains(response, "Date added")
self.assertNotContains(response, "Date modified")

def test_template_block_extra_pills(self):
"""The extra_pills template block is shown on the detail page."""
# Overriding settings doesn't work, because appconfig.ready has already run and
# registered the default adapter. Instead, unregister the default and register the
# new adapter here.
workspace_adapter_registry.unregister(DefaultWorkspaceAdapter)
workspace_adapter_registry.register(TestWorkspaceAdapter)
workspace = TestWorkspaceDataFactory.create()
self.client.force_login(self.user)
response = self.client.get(workspace.get_absolute_url())
self.assertContains(response, """<span class="badge">Extra workspace pill</span>""")


class WorkspaceCreateTest(AnVILAPIMockTestMixin, TestCase):
api_success_code = 201
Expand Down

0 comments on commit 500d6d6

Please sign in to comment.