mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-21 05:21:54 +00:00
Fix document usage url on the edit page
This commit is contained in:
parent
0c645db3fb
commit
4741f83333
4 changed files with 18 additions and 5 deletions
|
|
@ -55,7 +55,7 @@
|
|||
{% if uc_enabled %}
|
||||
<dt>{% trans "Usage" %}</dt>
|
||||
<dd>
|
||||
<a href="{{ image.usage_url }}">{% blocktrans count usage_count=document.get_usage.count %}Used {{ usage_count }} time{% plural %}Used {{ usage_count }} times{% endblocktrans %}</a>
|
||||
<a href="{{ document.usage_url }}">{% blocktrans count usage_count=document.get_usage.count %}Used {{ usage_count }} time{% plural %}Used {{ usage_count }} times{% endblocktrans %}</a>
|
||||
</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
|
|
|
|||
|
|
@ -271,6 +271,14 @@ class TestDocumentEditView(TestCase, WagtailTestUtils):
|
|||
|
||||
self.assertContains(response, 'File not found')
|
||||
|
||||
@override_settings(WAGTAIL_USAGE_COUNT_ENABLED=True)
|
||||
def test_usage_link(self):
|
||||
response = self.client.get(reverse('wagtaildocs:edit', args=(self.document.id,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'wagtaildocs/documents/edit.html')
|
||||
self.assertContains(response, self.document.usage_url)
|
||||
self.assertContains(response, 'Used 0 times')
|
||||
|
||||
|
||||
class TestDocumentDeleteView(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
|
|
@ -299,7 +307,8 @@ class TestDocumentDeleteView(TestCase, WagtailTestUtils):
|
|||
response = self.client.get(reverse('wagtaildocs:delete', args=(self.document.id,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'wagtaildocs/documents/confirm_delete.html')
|
||||
self.assertIn('Used 0 times', str(response.content))
|
||||
self.assertContains(response, self.document.usage_url)
|
||||
self.assertContains(response, 'Used 0 times')
|
||||
|
||||
|
||||
class TestMultipleDocumentUploader(TestCase, WagtailTestUtils):
|
||||
|
|
|
|||
|
|
@ -491,7 +491,9 @@ class TestImageDeleteView(TestCase, WagtailTestUtils):
|
|||
response = self.get()
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'wagtailimages/images/confirm_delete.html')
|
||||
self.assertIn('Used 0 times', str(response.content))
|
||||
self.assertContains(response, 'Used 0 times')
|
||||
expected_url = '/admin/images/usage/%d/' % self.image.id
|
||||
self.assertContains(response, expected_url)
|
||||
|
||||
def test_delete(self):
|
||||
response = self.post()
|
||||
|
|
|
|||
|
|
@ -362,7 +362,8 @@ class TestSnippetDelete(TestCase, WagtailTestUtils):
|
|||
response = self.client.get(reverse('wagtailsnippets:delete', args=('tests', 'advert', quote(self.test_snippet.pk), )))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'wagtailsnippets/snippets/confirm_delete.html')
|
||||
self.assertIn('Used 2 times', str(response.content))
|
||||
self.assertContains(response, 'Used 2 times')
|
||||
self.assertContains(response, self.test_snippet.usage_url())
|
||||
|
||||
|
||||
class TestSnippetChooserPanel(TestCase, WagtailTestUtils):
|
||||
|
|
@ -877,7 +878,8 @@ class TestSnippetViewWithCustomPrimaryKey(TestCase, WagtailTestUtils):
|
|||
response = self.client.get(reverse('wagtailsnippets:delete', args=('snippetstests', 'standardsnippetwithcustomprimarykey', quote(self.snippet_a.pk), )))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'wagtailsnippets/snippets/confirm_delete.html')
|
||||
self.assertIn('Used 0 times', str(response.content))
|
||||
self.assertContains(response, 'Used 0 times')
|
||||
self.assertContains(response, self.snippet_a.usage_url())
|
||||
|
||||
|
||||
class TestSnippetChooserBlockWithCustomPrimaryKey(TestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue