diff --git a/src/postorius/templates/postorius/lists/summary.html b/src/postorius/templates/postorius/lists/summary.html index d9011ae..0576cb1 100644 --- a/src/postorius/templates/postorius/lists/summary.html +++ b/src/postorius/templates/postorius/lists/summary.html @@ -19,20 +19,10 @@ {% if hyperkitty_url %} {% url 'hk_list_overview' list.fqdn_listname as hyperkitty_list_url %} {% blocktrans %} - To see the prior postings to this list, visit - the archives. +

To see the prior postings to this list, visit + the archives.

{% endblocktrans %} {% endif %} - {% if user.is_authenticated %} - {% if user.is_list_owner or user.is_superuser %} -
-

{{ list.settings.created_at }}

-

{{ list.settings.last_post_at }}

-

{{ list.settings.digest_last_sent_at }}

-

{{ list.settings.volume }}

-
- {% endif %} - {% endif %} {% trans 'To contact the list owners, use the following email address' %}: {{ list.settings.owner_address }} {% if user.is_authenticated %} {% if userSubscribed %} @@ -81,6 +71,22 @@

{% trans 'You have to log in to subscribe to this list.' %}

{% trans 'Log In' %}

{% endif %} + {% if user.is_authenticated %} + {% if user.is_list_owner or user.is_superuser %} +
+
+
{% trans 'List metrics' %}
+
+
+
{% trans 'Created at' %}:
{{ list.settings.created_at }}
+
{% trans 'Last post at' %}:
{{ list.settings.last_post_at }}
+
{% trans 'Digest last sent at' %}:
{{ list.settings.digest_last_sent_at }}
+
{% trans 'Volume' %}:
{{ list.settings.volume }}
+
+
+
+ {% endif %} + {% endif %} {% endblock %} diff --git a/src/postorius/tests/mailman_api_tests/test_list_summary.py b/src/postorius/tests/mailman_api_tests/test_list_summary.py index b661688..b59fb93 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_summary.py +++ b/src/postorius/tests/mailman_api_tests/test_list_summary.py @@ -159,3 +159,32 @@ self.assertEqual(response.status_code, 200) self.assertContains(response, 'Held Messages') self.assertNotContains(response, 'Delete List') + + @MM_VCR.use_cassette('test_list_summary_metrics_anonymous.yaml') + def test_metrics_not_displayed_to_anonymous(self): + response = self.client.get(reverse('list_summary', args=('foo@example.com',))) + self.assertNotContains(response, 'List metrics') + + @MM_VCR.use_cassette('test_list_summary_metrics_moderator.yaml') + def test_list_metrics_not_displayed_to_moderator(self): + mlist = self.mmclient.get_list('foo@example.com') + mlist.add_moderator('test@example.com') + self.client.login(username='testuser', password='testpass') + response = self.client.get(reverse('list_summary', args=('foo@example.com',))) + self.assertNotContains(response, 'List metrics') + + @MM_VCR.use_cassette('test_list_summary_metrics_owner.yaml') + def test_list_metrics_displayed_to_owner(self): + mlist = self.mmclient.get_list('foo@example.com') + mlist.add_owner('test@example.com') + self.client.login(username='testuser', password='testpass') + response = self.client.get(reverse('list_summary', args=('foo@example.com',))) + self.assertContains(response, 'List metrics') + + @MM_VCR.use_cassette('test_list_summary_metrics_superuser.yaml') + def test_list_metrics_displayed_to_superuser(self): + mlist = self.mmclient.get_list('foo@example.com') + User.objects.create_superuser('testadminuser', 'testadmin@example.com', 'testpass') + self.assertTrue(self.client.login(username='testadminuser', password='testpass')) + response = self.client.get(reverse('list_summary', args=('foo@example.com',))) + self.assertContains(response, 'List metrics')